From 42632befefd3f0b8e3901725a51c9a552add9c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=97=D0=B0=D1=86=D0=B5=D0=BF=D0=B8=D0=BD?= Date: Fri, 1 May 2020 20:10:14 +0300 Subject: [PATCH] [android] Extracted guides gallery snapping under the setting flag to disable it for wide screen --- android/res/layout/guides_discovery_item.xml | 1 + android/res/values-w400dp/values.xml | 4 + android/res/values/values.xml | 4 + .../placepage/GuidesGalleryViewRenderer.java | 119 ++++++++++++------ 4 files changed, 88 insertions(+), 40 deletions(-) create mode 100644 android/res/values-w400dp/values.xml create mode 100644 android/res/values/values.xml diff --git a/android/res/layout/guides_discovery_item.xml b/android/res/layout/guides_discovery_item.xml index 7b0539e417..405c535d60 100644 --- a/android/res/layout/guides_discovery_item.xml +++ b/android/res/layout/guides_discovery_item.xml @@ -6,6 +6,7 @@ android:layout_height="wrap_content" android:layout_width="wrap_content" android:stateListAnimator="@animator/pull_up_on_touch" + android:foreground="?selectableItemBackground" android:padding="@dimen/margin_eighth" android:clipToPadding="false"> + + false + diff --git a/android/res/values/values.xml b/android/res/values/values.xml new file mode 100644 index 0000000000..a5963811b3 --- /dev/null +++ b/android/res/values/values.xml @@ -0,0 +1,4 @@ + + + true + diff --git a/android/src/com/mapswithme/maps/widget/placepage/GuidesGalleryViewRenderer.java b/android/src/com/mapswithme/maps/widget/placepage/GuidesGalleryViewRenderer.java index 4f92db29ba..013cc72ce3 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/GuidesGalleryViewRenderer.java +++ b/android/src/com/mapswithme/maps/widget/placepage/GuidesGalleryViewRenderer.java @@ -1,5 +1,6 @@ package com.mapswithme.maps.widget.placepage; +import android.content.res.Resources; import android.os.Bundle; import android.view.View; import android.widget.Toast; @@ -25,17 +26,13 @@ import java.util.Objects; public class GuidesGalleryViewRenderer implements PlacePageViewRenderer, PlacePageStateObserver { - private static final String EXTRA_SNAP_VIEW_POSITION = "extra_snap_view_position"; + private static final String EXTRA_ACTIVE_POSITION = "extra_active_position"; @SuppressWarnings("NullableProblems") @NonNull private GuidesGallery mGallery; @SuppressWarnings("NullableProblems") @NonNull private RecyclerView mRecyclerView; - @SuppressWarnings("NullableProblems") - @NonNull - private SnapHelper mSnapHelper; - private int mSnapViewPosition; @Nullable private GuidesGallery.Item mActiveItem; @SuppressWarnings("NullableProblems") @@ -43,7 +40,7 @@ public class GuidesGalleryViewRenderer implements PlacePageViewRenderer mItemSelectedListener = new ItemSelectedListener() @@ -51,13 +48,20 @@ public class GuidesGalleryViewRenderer implements PlacePageViewRenderer= firstVisiblePosition && position <= lastVisiblePosition; + } + + private void setActiveGuide(int position) + { + mActivePosition = position; + GuidesGallery.Item item = mGallery.getItems().get(position); + if (mActiveItem == item) return; - } if (mActiveItem != null) mActiveItem.setActivated(false); + mActiveItem = item; mActiveItem.setActivated(true); if (mAdapter != null) @@ -128,14 +162,14 @@ public class GuidesGalleryViewRenderer implements PlacePageViewRenderer { - smoothScrollToPosition(mSnapViewPosition); - setActiveGuide(); + smoothScrollToPosition(mActivePosition); + setActiveGuide(mActivePosition); }); }