Make drag and drop also work when the widget tray is still in scroll mode.
b/20698514 Change-Id: Ic075f0016d5e00bbdec193bbcd2e311da1957388
This commit is contained in:
@@ -40,6 +40,11 @@ public class AppsContainerRecyclerView extends RecyclerView
|
||||
implements RecyclerView.OnItemTouchListener {
|
||||
|
||||
private static final float FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR = 1.5f;
|
||||
private static final int SCROLL_DELTA_THRESHOLD = 6;
|
||||
|
||||
/** Keeps the last known scrolling delta/velocity along y-axis. */
|
||||
private int mDy = 0;
|
||||
private float mDeltaThreshold;
|
||||
|
||||
private AlphabeticalAppsList mApps;
|
||||
private int mNumAppsPerRow;
|
||||
@@ -92,6 +97,7 @@ public class AppsContainerRecyclerView extends RecyclerView
|
||||
mScrollbarInset =
|
||||
res.getDimensionPixelSize(R.dimen.apps_view_fast_scroll_scrubber_touch_inset);
|
||||
setFastScrollerAlpha(getFastScrollerAlpha());
|
||||
mDeltaThreshold = getResources().getDisplayMetrics().density * SCROLL_DELTA_THRESHOLD;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,6 +138,7 @@ public class AppsContainerRecyclerView extends RecyclerView
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
addOnItemTouchListener(this);
|
||||
}
|
||||
|
||||
@@ -142,6 +149,11 @@ public class AppsContainerRecyclerView extends RecyclerView
|
||||
drawFastScrollerPopup(canvas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrolled(int dx, int dy) {
|
||||
mDy = dy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -175,7 +187,10 @@ public class AppsContainerRecyclerView extends RecyclerView
|
||||
// Keep track of the down positions
|
||||
mDownX = mLastX = x;
|
||||
mDownY = mLastY = y;
|
||||
stopScroll();
|
||||
if ((Math.abs(mDy) < mDeltaThreshold &&
|
||||
getScrollState() != RecyclerView.SCROLL_STATE_IDLE)) {
|
||||
stopScroll();
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
// Check if we are scrolling
|
||||
|
||||
Reference in New Issue
Block a user