@Override public void draw(Canvas canvas) { super.draw(canvas); if (mFastScroller != null) { final int scrollY = getScrollY(); if (scrollY != 0) { int restoreCount = canvas.save(); canvas.translate(0, scrollY); mFastScroller.draw(canvas); canvas.restoreToCount(restoreCount); } else { mFastScroller.draw(canvas); } } }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); if (mFastScroller != null) { mFastScroller.onSizeChanged(w, h, oldw, oldh); } }
@Override public boolean isFastScrollAlwaysVisible() { if (mForceFastScrollAlwaysVisibleDisable) { return false; } return mFastScrollEnabled && mFastScroller.isAlwaysShowEnabled(); }
@Override public void setVerticalScrollbarPosition(int position) { mVerticalScrollbarPosition = position; if (mFastScroller != null) { mFastScroller.setScrollbarPosition(position); } recomputePaddingFromScroller(); }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int mOldItemCount = getCount(); super.onLayout(changed, l, t, r, b); final int mItemCount = getCount(); if (mFastScroller != null && mItemCount != mOldItemCount) { mFastScroller.onItemCountChanged(mOldItemCount, mItemCount); } }
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (!mIsAttached) { return false; } if (mFastScroller != null && mFastScroller.onInterceptTouchEvent(ev)) { return true; } return super.onInterceptTouchEvent(ev); }
@Override public int getVerticalScrollbarWidth() { mForceFastScrollAlwaysVisibleDisable = true; final int superWidth = super.getVerticalScrollbarWidth(); mForceFastScrollAlwaysVisibleDisable = false; if (isFastScrollAlwaysVisible()) { return Math.max(superWidth, mFastScroller.getWidth()); } return superWidth; }
void invokeOnItemScrollListener() { final int mFirstPosition = getFirstVisiblePosition(); final int mItemCount = getCount(); if (mFastScroller != null) { mFastScroller.onScroll(this, mFirstPosition, getChildCount(), mItemCount); } if (mOnScrollListener != null) { mOnScrollListener.onScroll(this, mFirstPosition, getChildCount(), mItemCount); } onScrollChanged(0, 0, 0, 0); }
@Override public boolean onTouchEvent(MotionEvent ev) { if (!isEnabled()) { return isClickable() || isLongClickable(); } if (!mIsAttached) { return false; } if (mFastScroller != null && mFastScroller.onTouchEvent(ev)) { return true; } return super.onTouchEvent(ev); }
@Override public void setFastScrollEnabled(boolean enabled) { mFastScrollEnabled = enabled; if (enabled) { if (mFastScroller == null) { mFastScroller = new FastScroller(getContext(), this); } } else { if (mFastScroller != null) { mFastScroller.stop(); mFastScroller = null; } } }
@Override public void setFastScrollAlwaysVisible(boolean alwaysShow) { if (alwaysShow && !mFastScrollEnabled) { setFastScrollEnabled(true); } if (mFastScroller != null) { mFastScroller.setAlwaysShow(alwaysShow); } try { Method method = View.class.getDeclaredMethod("computeOpaqueFlags"); method.setAccessible(true); method.invoke(this); method = View.class.getDeclaredMethod("recomputePadding"); method.setAccessible(true); method.invoke(this); } catch (Exception e) { } if (alwaysShow) { setPaddingFromScroller(true); } }
protected boolean isVerticalScrollBarHidden() { return mFastScroller != null && mFastScroller.isVisible(); }
@Override public void onInvalidated() { if (mFastScroller != null) { mFastScroller.onSectionsChanged(); } }