summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/BaseRecyclerView.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-10-08 17:43:48 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-10-10 14:17:16 -0700
commit5d9fb0e92f2ef2b25f3aa93c1f89838ccc68aa88 (patch)
tree46764e909a89e51c294ca23b0eed69a481fa9333 /src/com/android/launcher3/BaseRecyclerView.java
parent631ffbda64b92b843f18af6756b52b1ac4c22461 (diff)
downloadandroid_packages_apps_Trebuchet-5d9fb0e92f2ef2b25f3aa93c1f89838ccc68aa88.tar.gz
android_packages_apps_Trebuchet-5d9fb0e92f2ef2b25f3aa93c1f89838ccc68aa88.tar.bz2
android_packages_apps_Trebuchet-5d9fb0e92f2ef2b25f3aa93c1f89838ccc68aa88.zip
Simplifying fast scroller logic
> Using a separate view for drawing the popup. This allows us to use elevation property instead of drawing the shadow as bitmap. > During the thumb animation, invalidating the full track width, instead of invalidating the track and thumb separately. > The thumb path is calculated at 0,0 and drawn using canvas.translate(). This avoids recalculating the path on every scroll. Change-Id: I48741e5b4432df0d939016db284d7aaf52cc2aa6
Diffstat (limited to 'src/com/android/launcher3/BaseRecyclerView.java')
-rw-r--r--src/com/android/launcher3/BaseRecyclerView.java25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/BaseRecyclerView.java
index 45bc94006..9bdbe2580 100644
--- a/src/com/android/launcher3/BaseRecyclerView.java
+++ b/src/com/android/launcher3/BaseRecyclerView.java
@@ -22,6 +22,8 @@ import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import android.view.ViewGroup;
+
import com.android.launcher3.util.Thunk;
@@ -41,7 +43,7 @@ public abstract class BaseRecyclerView extends RecyclerView
@Thunk int mDy = 0;
private float mDeltaThreshold;
- protected BaseRecyclerViewFastScrollBar mScrollbar;
+ protected final BaseRecyclerViewFastScrollBar mScrollbar;
private int mDownX;
private int mDownY;
@@ -92,6 +94,12 @@ public abstract class BaseRecyclerView extends RecyclerView
addOnItemTouchListener(this);
}
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ mScrollbar.setPopupView(((ViewGroup) getParent()).findViewById(R.id.fast_scroller_popup));
+ }
+
/**
* We intercept the touch handling only to support fast scrolling when initiated from the
* scroll bar. Otherwise, we fall back to the default RecyclerView touch handling.
@@ -235,7 +243,7 @@ public abstract class BaseRecyclerView extends RecyclerView
// Only show the scrollbar if there is height to be scrolled
int availableScrollBarHeight = getAvailableScrollBarHeight();
if (availableScrollHeight <= 0) {
- mScrollbar.setThumbOffset(-1, -1);
+ mScrollbar.setThumbOffsetY(-1);
return;
}
@@ -246,18 +254,7 @@ public abstract class BaseRecyclerView extends RecyclerView
(int) (((float) scrollY / availableScrollHeight) * availableScrollBarHeight);
// Calculate the position and size of the scroll bar
- mScrollbar.setThumbOffset(getScrollBarX(), scrollBarY);
- }
-
- /**
- * @return the x position for the scrollbar thumb
- */
- protected int getScrollBarX() {
- if (Utilities.isRtl(getResources())) {
- return mBackgroundPadding.left;
- } else {
- return getWidth() - mBackgroundPadding.right - mScrollbar.getThumbWidth();
- }
+ mScrollbar.setThumbOffsetY(scrollBarY);
}
/**