mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 08:16:49 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user