Add overscroll to the top of All Apps.

* Overscroll at the top of all apps will occur when the user scrolls
  up, hits the top, and continues to scroll up.
* Fixed bug where All Apps jumps when the user enters overscroll
  from a scroll that doesn't start at the bottom.
* Fix bug where AllAppsRecyclerView stays translated even after
  the user has finished dragging.

Bug: 62628421
Change-Id: Ia1d230a7cc07a7cf8c1a7c5211a025034ae5f6df
This commit is contained in:
Jon Miranda
2017-07-05 14:58:34 -07:00
parent 35005ef213
commit 2b35905ea7
2 changed files with 43 additions and 19 deletions

View File

@@ -410,22 +410,19 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (mScrollState == RecyclerView.SCROLL_STATE_DRAGGING
|| (dx == 0 && dy == 0)) {
if (mScrollState == RecyclerView.SCROLL_STATE_DRAGGING || (dx == 0 && dy == 0)) {
if (mSpringAnimationHandler.isRunning()){
mSpringAnimationHandler.skipToEnd();
}
return;
}
int first = mLayoutManager.findFirstVisibleItemPosition();
int last = mLayoutManager.findLastVisibleItemPosition();
// We only show the spring animation when at the top or bottom, so we wait until the
// first or last row is visible to ensure that all animations run in sync.
boolean scrollUp = dy < 0;
if ((first == 0 && scrollUp) || (last == mAdapter.getItemCount() - 1 && dy > 0)) {
mSpringAnimationHandler.animateToFinalPosition(0, scrollUp ? 1 : -1);
// We only start the spring animation when we fling and hit the top/bottom, to ensure
// that all of the animations start at the same time.
if (dy < 0 && !mAppsRecyclerView.canScrollVertically(-1)) {
mSpringAnimationHandler.animateToFinalPosition(0, 1);
} else if (dy > 0 && !mAppsRecyclerView.canScrollVertically(1)) {
mSpringAnimationHandler.animateToFinalPosition(0, -1);
}
}