Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package com.android.launcher3; |
| 17 | |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 18 | import android.animation.ObjectAnimator; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 19 | import android.content.res.Resources; |
| 20 | import android.graphics.Canvas; |
| 21 | import android.graphics.Color; |
| 22 | import android.graphics.Paint; |
Winson | 6779595 | 2015-08-20 12:23:52 -0700 | [diff] [blame] | 23 | import android.graphics.Path; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 24 | import android.graphics.Rect; |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 25 | import android.util.Property; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 26 | import android.view.MotionEvent; |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 27 | import android.view.View; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 28 | import android.view.ViewConfiguration; |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 29 | import android.widget.TextView; |
Sunny Goyal | b713ad4 | 2015-06-24 11:45:32 -0700 | [diff] [blame] | 30 | |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 31 | /** |
| 32 | * The track and scrollbar that shows when you scroll the list. |
| 33 | */ |
| 34 | public class BaseRecyclerViewFastScrollBar { |
| 35 | |
| 36 | public interface FastScrollFocusableView { |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 37 | void setFastScrollFocusState(final FastBitmapDrawable.State focusState, boolean animated); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 38 | } |
| 39 | |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 40 | private static final Property<BaseRecyclerViewFastScrollBar, Integer> TRACK_WIDTH = |
| 41 | new Property<BaseRecyclerViewFastScrollBar, Integer>(Integer.class, "width") { |
| 42 | |
| 43 | @Override |
| 44 | public Integer get(BaseRecyclerViewFastScrollBar scrollBar) { |
| 45 | return scrollBar.mWidth; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public void set(BaseRecyclerViewFastScrollBar scrollBar, Integer value) { |
| 50 | scrollBar.setTrackWidth(value); |
| 51 | } |
| 52 | }; |
| 53 | |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 54 | private final static int MAX_TRACK_ALPHA = 30; |
| 55 | private final static int SCROLL_BAR_VIS_DURATION = 150; |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 56 | private static final float FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR = 1.5f; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 57 | |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 58 | private final Rect mTmpRect = new Rect(); |
| 59 | private final BaseRecyclerView mRv; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 60 | |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 61 | private final boolean mIsRtl; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 62 | |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 63 | // The inset is the buffer around which a point will still register as a click on the scrollbar |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 64 | private final int mTouchInset; |
| 65 | |
| 66 | private final int mMinWidth; |
| 67 | private final int mMaxWidth; |
| 68 | |
| 69 | // Current width of the track |
| 70 | private int mWidth; |
| 71 | private ObjectAnimator mWidthAnimator; |
| 72 | |
| 73 | private final Path mThumbPath = new Path(); |
| 74 | private final Paint mThumbPaint; |
| 75 | private final int mThumbHeight; |
| 76 | |
| 77 | private final Paint mTrackPaint; |
| 78 | |
| 79 | private float mLastTouchY; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 80 | private boolean mIsDragging; |
Winson | d2eb49e | 2015-08-18 17:43:02 -0700 | [diff] [blame] | 81 | private boolean mIsThumbDetached; |
| 82 | private boolean mCanThumbDetach; |
Winson | ec4845b | 2015-08-27 10:19:48 -0700 | [diff] [blame] | 83 | private boolean mIgnoreDragGesture; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 84 | |
| 85 | // This is the offset from the top of the scrollbar when the user first starts touching. To |
| 86 | // prevent jumping, this offset is applied as the user scrolls. |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 87 | private int mTouchOffsetY; |
| 88 | private int mThumbOffsetY; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 89 | |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 90 | // Fast scroller popup |
| 91 | private TextView mPopupView; |
| 92 | private boolean mPopupVisible; |
| 93 | private String mPopupSectionName; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 94 | |
| 95 | public BaseRecyclerViewFastScrollBar(BaseRecyclerView rv, Resources res) { |
| 96 | mRv = rv; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 97 | mTrackPaint = new Paint(); |
| 98 | mTrackPaint.setColor(rv.getFastScrollerTrackColor(Color.BLACK)); |
Winson | 6779595 | 2015-08-20 12:23:52 -0700 | [diff] [blame] | 99 | mTrackPaint.setAlpha(MAX_TRACK_ALPHA); |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 100 | |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 101 | mThumbPaint = new Paint(); |
Winson | 6779595 | 2015-08-20 12:23:52 -0700 | [diff] [blame] | 102 | mThumbPaint.setAntiAlias(true); |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 103 | mThumbPaint.setColor(Utilities.getColorAccent(rv.getContext())); |
Winson | 6779595 | 2015-08-20 12:23:52 -0700 | [diff] [blame] | 104 | mThumbPaint.setStyle(Paint.Style.FILL); |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 105 | |
| 106 | mWidth = mMinWidth = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_min_width); |
| 107 | mMaxWidth = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_max_width); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 108 | mThumbHeight = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_height); |
| 109 | mTouchInset = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_touch_inset); |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 110 | mIsRtl = Utilities.isRtl(res); |
| 111 | updateThumbPath(); |
| 112 | } |
| 113 | |
| 114 | public void setPopupView(View popup) { |
| 115 | mPopupView = (TextView) popup; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Winson | d2eb49e | 2015-08-18 17:43:02 -0700 | [diff] [blame] | 118 | public void setDetachThumbOnFastScroll() { |
| 119 | mCanThumbDetach = true; |
| 120 | } |
| 121 | |
| 122 | public void reattachThumbToScroll() { |
| 123 | mIsThumbDetached = false; |
| 124 | } |
| 125 | |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 126 | private int getDrawLeft() { |
| 127 | return mIsRtl ? 0 : (mRv.getWidth() - mMaxWidth); |
| 128 | } |
| 129 | |
| 130 | public void setThumbOffsetY(int y) { |
| 131 | if (mThumbOffsetY == y) { |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 132 | return; |
| 133 | } |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 134 | |
| 135 | // Invalidate the previous and new thumb area |
| 136 | int drawLeft = getDrawLeft(); |
| 137 | mTmpRect.set(drawLeft, mThumbOffsetY, drawLeft + mMaxWidth, mThumbOffsetY + mThumbHeight); |
| 138 | mThumbOffsetY = y; |
| 139 | mTmpRect.union(drawLeft, mThumbOffsetY, drawLeft + mMaxWidth, mThumbOffsetY + mThumbHeight); |
| 140 | mRv.invalidate(mTmpRect); |
| 141 | } |
| 142 | |
| 143 | public int getThumbOffsetY() { |
| 144 | return mThumbOffsetY; |
| 145 | } |
| 146 | |
| 147 | private void setTrackWidth(int width) { |
| 148 | if (mWidth == width) { |
| 149 | return; |
| 150 | } |
| 151 | int left = getDrawLeft(); |
| 152 | // Invalidate the whole scroll bar area. |
| 153 | mRv.invalidate(left, 0, left + mMaxWidth, mRv.getVisibleHeight()); |
| 154 | |
| 155 | mWidth = width; |
Winson | 6779595 | 2015-08-20 12:23:52 -0700 | [diff] [blame] | 156 | updateThumbPath(); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 159 | /** |
| 160 | * Updates the path for the thumb drawable. |
| 161 | */ |
| 162 | private void updateThumbPath() { |
| 163 | int smallWidth = mIsRtl ? mWidth : -mWidth; |
| 164 | int largeWidth = mIsRtl ? mMaxWidth : -mMaxWidth; |
Winson | d2eb49e | 2015-08-18 17:43:02 -0700 | [diff] [blame] | 165 | |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 166 | mThumbPath.reset(); |
| 167 | mThumbPath.moveTo(0, 0); |
| 168 | mThumbPath.lineTo(0, mThumbHeight); // Left edge |
| 169 | mThumbPath.lineTo(smallWidth, mThumbHeight); // bottom edge |
| 170 | mThumbPath.cubicTo(smallWidth, mThumbHeight, // right edge |
| 171 | largeWidth, mThumbHeight / 2, |
| 172 | smallWidth, 0); |
| 173 | mThumbPath.close(); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | public int getThumbHeight() { |
| 177 | return mThumbHeight; |
| 178 | } |
| 179 | |
| 180 | public int getThumbMaxWidth() { |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 181 | return mMaxWidth; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 182 | } |
| 183 | |
Winson | d2eb49e | 2015-08-18 17:43:02 -0700 | [diff] [blame] | 184 | public boolean isDraggingThumb() { |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 185 | return mIsDragging; |
| 186 | } |
| 187 | |
Winson | d2eb49e | 2015-08-18 17:43:02 -0700 | [diff] [blame] | 188 | public boolean isThumbDetached() { |
| 189 | return mIsThumbDetached; |
| 190 | } |
| 191 | |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 192 | /** |
| 193 | * Handles the touch event and determines whether to show the fast scroller (or updates it if |
| 194 | * it is already showing). |
| 195 | */ |
| 196 | public void handleTouchEvent(MotionEvent ev, int downX, int downY, int lastY) { |
| 197 | ViewConfiguration config = ViewConfiguration.get(mRv.getContext()); |
| 198 | |
| 199 | int action = ev.getAction(); |
| 200 | int y = (int) ev.getY(); |
| 201 | switch (action) { |
| 202 | case MotionEvent.ACTION_DOWN: |
Winson | ec4845b | 2015-08-27 10:19:48 -0700 | [diff] [blame] | 203 | if (isNearThumb(downX, downY)) { |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 204 | mTouchOffsetY = downY - mThumbOffsetY; |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 205 | } |
| 206 | break; |
| 207 | case MotionEvent.ACTION_MOVE: |
Winson | ec4845b | 2015-08-27 10:19:48 -0700 | [diff] [blame] | 208 | // Check if we should start scrolling, but ignore this fastscroll gesture if we have |
| 209 | // exceeded some fixed movement |
| 210 | mIgnoreDragGesture |= Math.abs(y - downY) > config.getScaledPagingTouchSlop(); |
Winson | 646c236 | 2015-09-03 11:46:11 -0700 | [diff] [blame] | 211 | if (!mIsDragging && !mIgnoreDragGesture && mRv.supportsFastScrolling() && |
| 212 | isNearThumb(downX, lastY) && |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 213 | Math.abs(y - downY) > config.getScaledTouchSlop()) { |
| 214 | mRv.getParent().requestDisallowInterceptTouchEvent(true); |
| 215 | mIsDragging = true; |
Winson | d2eb49e | 2015-08-18 17:43:02 -0700 | [diff] [blame] | 216 | if (mCanThumbDetach) { |
| 217 | mIsThumbDetached = true; |
| 218 | } |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 219 | mTouchOffsetY += (lastY - downY); |
| 220 | animatePopupVisibility(true); |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 221 | showActiveScrollbar(true); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 222 | } |
| 223 | if (mIsDragging) { |
| 224 | // Update the fastscroller section name at this touch position |
| 225 | int top = mRv.getBackgroundPadding().top; |
Hyunyoung Song | 4ebc3d0 | 2016-08-05 10:59:17 -0700 | [diff] [blame] | 226 | int bottom = top + mRv.getVisibleHeight() - mThumbHeight; |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 227 | float boundedY = (float) Math.max(top, Math.min(bottom, y - mTouchOffsetY)); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 228 | String sectionName = mRv.scrollToPositionAtProgress((boundedY - top) / |
| 229 | (bottom - top)); |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 230 | if (!sectionName.equals(mPopupSectionName)) { |
| 231 | mPopupSectionName = sectionName; |
| 232 | mPopupView.setText(sectionName); |
| 233 | } |
| 234 | animatePopupVisibility(!sectionName.isEmpty()); |
| 235 | updatePopupY(lastY); |
Winson | d2eb49e | 2015-08-18 17:43:02 -0700 | [diff] [blame] | 236 | mLastTouchY = boundedY; |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 237 | setThumbOffsetY((int) mLastTouchY); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 238 | } |
| 239 | break; |
| 240 | case MotionEvent.ACTION_UP: |
| 241 | case MotionEvent.ACTION_CANCEL: |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 242 | mTouchOffsetY = 0; |
Winson | d2eb49e | 2015-08-18 17:43:02 -0700 | [diff] [blame] | 243 | mLastTouchY = 0; |
Winson | ec4845b | 2015-08-27 10:19:48 -0700 | [diff] [blame] | 244 | mIgnoreDragGesture = false; |
Winson Chung | 4c7fc62 | 2015-06-24 16:59:31 -0700 | [diff] [blame] | 245 | if (mIsDragging) { |
| 246 | mIsDragging = false; |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 247 | animatePopupVisibility(false); |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 248 | showActiveScrollbar(false); |
Winson Chung | 4c7fc62 | 2015-06-24 16:59:31 -0700 | [diff] [blame] | 249 | } |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 250 | break; |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | public void draw(Canvas canvas) { |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 255 | if (mThumbOffsetY < 0) { |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 256 | return; |
| 257 | } |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 258 | int saveCount = canvas.save(Canvas.MATRIX_SAVE_FLAG); |
| 259 | if (!mIsRtl) { |
| 260 | canvas.translate(mRv.getWidth(), 0); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 261 | } |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 262 | // Draw the track |
| 263 | int thumbWidth = mIsRtl ? mWidth : -mWidth; |
| 264 | canvas.drawRect(0, 0, thumbWidth, mRv.getVisibleHeight(), mTrackPaint); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 265 | |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 266 | canvas.translate(0, mThumbOffsetY); |
| 267 | canvas.drawPath(mThumbPath, mThumbPaint); |
| 268 | canvas.restoreToCount(saveCount); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | /** |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 272 | * Animates the width of the scrollbar. |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 273 | */ |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 274 | private void showActiveScrollbar(boolean isScrolling) { |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 275 | if (mWidthAnimator != null) { |
| 276 | mWidthAnimator.cancel(); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 277 | } |
Winson | 6779595 | 2015-08-20 12:23:52 -0700 | [diff] [blame] | 278 | |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 279 | mWidthAnimator = ObjectAnimator.ofInt(this, TRACK_WIDTH, |
| 280 | isScrolling ? mMaxWidth : mMinWidth); |
| 281 | mWidthAnimator.setDuration(SCROLL_BAR_VIS_DURATION); |
| 282 | mWidthAnimator.start(); |
Winson | 6779595 | 2015-08-20 12:23:52 -0700 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | /** |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 286 | * Returns whether the specified points are near the scroll bar bounds. |
| 287 | */ |
Hyunyoung Song | f4cbb14 | 2016-06-10 12:00:02 -0700 | [diff] [blame] | 288 | public boolean isNearThumb(int x, int y) { |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 289 | int left = getDrawLeft(); |
| 290 | mTmpRect.set(left, mThumbOffsetY, left + mMaxWidth, mThumbOffsetY + mThumbHeight); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 291 | mTmpRect.inset(mTouchInset, mTouchInset); |
| 292 | return mTmpRect.contains(x, y); |
| 293 | } |
Sunny Goyal | 5d9fb0e | 2016-10-08 17:43:48 -0700 | [diff] [blame^] | 294 | |
| 295 | private void animatePopupVisibility(boolean visible) { |
| 296 | if (mPopupVisible != visible) { |
| 297 | mPopupVisible = visible; |
| 298 | mPopupView.animate().cancel(); |
| 299 | mPopupView.animate().alpha(visible ? 1f : 0f).setDuration(visible ? 200 : 150).start(); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | private void updatePopupY(int lastTouchY) { |
| 304 | int height = mPopupView.getHeight(); |
| 305 | float top = lastTouchY - (FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR * height); |
| 306 | top = Math.max(mMaxWidth, Math.min(top, mRv.getVisibleHeight() - mMaxWidth - height)); |
| 307 | mPopupView.setTranslationY(top); |
| 308 | } |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 309 | } |