diff --git a/android/res/layout/fragment_search.xml b/android/res/layout/fragment_search.xml index b73c4b63e5..375f159df6 100644 --- a/android/res/layout/fragment_search.xml +++ b/android/res/layout/fragment_search.xml @@ -18,6 +18,7 @@ android:elevation="@dimen/margin_half_plus" tools:targetApi="lollipop"> diff --git a/android/res/layout/item_search_clear_history.xml b/android/res/layout/item_search_clear_history.xml index 61505cad19..06f2282c92 100644 --- a/android/res/layout/item_search_clear_history.xml +++ b/android/res/layout/item_search_clear_history.xml @@ -1,6 +1,5 @@ diff --git a/android/src/com/mapswithme/maps/search/SearchFragment.java b/android/src/com/mapswithme/maps/search/SearchFragment.java index 2a4fb0305b..65d37bfc3e 100644 --- a/android/src/com/mapswithme/maps/search/SearchFragment.java +++ b/android/src/com/mapswithme/maps/search/SearchFragment.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.design.widget.AppBarLayout; +import android.support.design.widget.CollapsingToolbarLayout; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; @@ -33,7 +34,6 @@ import com.mapswithme.maps.location.LocationListener; import com.mapswithme.maps.routing.RoutingController; import com.mapswithme.maps.widget.PlaceholderView; import com.mapswithme.maps.widget.SearchToolbarController; -import com.mapswithme.util.Animations; import com.mapswithme.util.UiUtils; import com.mapswithme.util.Utils; import com.mapswithme.util.log.LoggerFactory; @@ -51,8 +51,6 @@ public class SearchFragment extends BaseMwmFragment HotelsFilterHolder { public static final String PREFS_SHOW_ENABLE_LOGGING_SETTING = "ShowEnableLoggingSetting"; - private static final float NESTED_SCROLL_DELTA = - -MwmApplication.get().getResources().getDimension(R.dimen.margin_half); private long mLastQueryTimestamp; @@ -161,6 +159,7 @@ public class SearchFragment extends BaseMwmFragment private PlaceholderView mResultsPlaceholder; private RecyclerView mResults; private AppBarLayout mAppBarLayout; + private CollapsingToolbarLayout mToolbarLayout; private View mFilterElevation; @Nullable private SearchFilterController mFilterController; @@ -258,6 +257,10 @@ public class SearchFragment extends BaseMwmFragment { final boolean hasQuery = mToolbarController.hasQuery(); UiUtils.showIf(hasQuery, mResultsFrame); + AppBarLayout.LayoutParams lp = (AppBarLayout.LayoutParams) mToolbarLayout.getLayoutParams(); + lp.setScrollFlags(hasQuery ? AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS + | AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL : 0); + mToolbarLayout.setLayoutParams(lp); if (mFilterController != null) mFilterController.show(hasQuery && mSearchAdapter.getItemCount() != 0, mSearchAdapter.showPopulateButton()); @@ -295,6 +298,7 @@ public class SearchFragment extends BaseMwmFragment ViewGroup root = (ViewGroup) view; mAppBarLayout = (AppBarLayout) root.findViewById(R.id.app_bar); + mToolbarLayout = (CollapsingToolbarLayout) mAppBarLayout.findViewById(R.id.collapsing_toolbar); mTabFrame = root.findViewById(R.id.tab_frame); ViewPager pager = (ViewPager) mTabFrame.findViewById(R.id.pages); @@ -625,7 +629,6 @@ public class SearchFragment extends BaseMwmFragment if (mToolbarController.hasQuery()) { mToolbarController.clear(); - Animations.nestedScrollAnimation(mResults, (int) NESTED_SCROLL_DELTA, 0); return true; } diff --git a/android/src/com/mapswithme/util/Animations.java b/android/src/com/mapswithme/util/Animations.java index eebc782835..dfdfeeb25b 100644 --- a/android/src/com/mapswithme/util/Animations.java +++ b/android/src/com/mapswithme/util/Animations.java @@ -10,8 +10,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; import android.util.DisplayMetrics; -import android.support.v4.view.NestedScrollingChild; -import android.support.v4.view.ViewCompat; import android.view.View; import android.view.ViewGroup; import android.view.ViewPropertyAnimator; @@ -207,32 +205,6 @@ public final class Animations animator.start(); } - public static void nestedScrollAnimation( - @NonNull final T view, final int deltaY, final int deltaX) - { - ViewCompat.startNestedScroll(view, ViewCompat.SCROLL_AXIS_VERTICAL); - ValueAnimator animator = ValueAnimator.ofFloat(0.0f, 1.0f); - animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() - { - @Override - public void onAnimationUpdate(ValueAnimator animation) - { - ViewCompat.dispatchNestedPreScroll(view, deltaX, deltaY, null, null); - ViewCompat.dispatchNestedScroll(view, 0, 0, 0, 0, null); - } - }); - animator.addListener(new UiUtils.SimpleAnimatorListener() - { - @Override - public void onAnimationEnd(Animator animation) - { - ViewCompat.stopNestedScroll(view); - } - }); - animator.setDuration(DURATION_DEFAULT); - animator.start(); - } - private static void setCardBackgroundColor(@NonNull View view) { Context context = view.getContext();