summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/AppDrawerScrubber.java
diff options
context:
space:
mode:
authorLinus Lee <llee@cyngn.com>2015-04-02 15:53:26 -0700
committerRajesh Yengisetty <rajesh@cyngn.com>2015-04-16 21:47:37 +0000
commitbdee9dd24e9bc46176463018881433a4715a0a7c (patch)
tree78de5c21dc2a79041ac4655424b05d3852f3d25b /src/com/android/launcher3/AppDrawerScrubber.java
parent60046217f7508a70f0b83a2fcba551f75fc67f2c (diff)
downloadandroid_packages_apps_Trebuchet-bdee9dd24e9bc46176463018881433a4715a0a7c.tar.gz
android_packages_apps_Trebuchet-bdee9dd24e9bc46176463018881433a4715a0a7c.tar.bz2
android_packages_apps_Trebuchet-bdee9dd24e9bc46176463018881433a4715a0a7c.zip
AppDrawer: Add highlighting scrubbing and offset
When you drag the scrubber it now highlights that section differently Also when you drag on the scrubber, instead of bringing the section into view at any point, it will try to make it the 3 row from the bottom Change-Id: I7cefaa24fb3c757f6e031247bb4a247473dde828 (cherry picked from commit 0ce1d70dffb2f19a8e2997f03556b46b44c57156)
Diffstat (limited to 'src/com/android/launcher3/AppDrawerScrubber.java')
-rw-r--r--src/com/android/launcher3/AppDrawerScrubber.java41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/com/android/launcher3/AppDrawerScrubber.java b/src/com/android/launcher3/AppDrawerScrubber.java
index 1670934d6..cafd00a18 100644
--- a/src/com/android/launcher3/AppDrawerScrubber.java
+++ b/src/com/android/launcher3/AppDrawerScrubber.java
@@ -20,9 +20,11 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.graphics.Color;
+import android.graphics.PointF;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.LinearSmoothScroller;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -256,8 +258,41 @@ public class AppDrawerScrubber extends LinearLayout {
// get the index of the underlying list
int adapterIndex = mSectionContainer.getAdapterIndex(mLastIndex, index);
- mLayoutManager.smoothScrollToPosition(mListView, null,
- mAdapter.getPositionForSection(adapterIndex));
+ int itemIndex = mAdapter.getPositionForSection(adapterIndex);
+
+ // get any child's height since all children are the same height
+ int itemHeight = 0;
+ View child = mLayoutManager.getChildAt(0);
+ if (child != null) {
+ itemHeight = child.getMeasuredHeight();
+ }
+
+ if (itemHeight != 0) {
+ // scroll to the item such that there are 2 rows beneath it from the bottom
+ final int itemDiff = 2 * itemHeight;
+ LinearSmoothScroller scroller = new LinearSmoothScroller(mListView.getContext()) {
+ @Override
+ protected int getVerticalSnapPreference() {
+ // position the item against the end of the list view
+ return SNAP_TO_END;
+ }
+
+ @Override
+ public PointF computeScrollVectorForPosition(int targetPosition) {
+ return mLayoutManager.computeScrollVectorForPosition(targetPosition);
+ }
+
+ @Override
+ public int calculateDyToMakeVisible(View view, int snapPreference) {
+ int dy = super.calculateDyToMakeVisible(view, snapPreference);
+ return dy - itemDiff;
+ }
+ };
+ scroller.setTargetPosition(itemIndex);
+ mLayoutManager.startSmoothScroll(scroller);
+ }
+
+ mAdapter.setSectionTarget(adapterIndex);
mLastIndex = index;
}
@@ -272,4 +307,4 @@ public class AppDrawerScrubber extends LinearLayout {
touchTrack(false);
}
}
-} \ No newline at end of file
+}