summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/allapps/AllAppsRecyclerView.java')
-rw-r--r--src/com/android/launcher3/allapps/AllAppsRecyclerView.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 25144584e..701402b02 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -103,7 +103,10 @@ public class AllAppsRecyclerView extends BaseRecyclerView implements LogContaine
}
public void setSpringAnimationHandler(SpringAnimationHandler springAnimationHandler) {
- mSpringAnimationHandler = springAnimationHandler;
+ if (FeatureFlags.LAUNCHER3_PHYSICS) {
+ mSpringAnimationHandler = springAnimationHandler;
+ addOnScrollListener(new SpringMotionOnScrollListener());
+ }
}
@Override
@@ -485,6 +488,25 @@ public class AllAppsRecyclerView extends BaseRecyclerView implements LogContaine
y + mEmptySearchBackground.getIntrinsicHeight());
}
+ private class SpringMotionOnScrollListener extends RecyclerView.OnScrollListener {
+
+ @Override
+ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
+ if (mOverScrollHelper.isInOverScroll()) {
+ // OverScroll will handle animating the springs.
+ return;
+ }
+
+ // We only start the spring animation when we hit the top/bottom, to ensure
+ // that all of the animations start at the same time.
+ if (dy < 0 && !canScrollVertically(-1)) {
+ mSpringAnimationHandler.animateToFinalPosition(0, 1);
+ } else if (dy > 0 && !canScrollVertically(1)) {
+ mSpringAnimationHandler.animateToFinalPosition(0, -1);
+ }
+ }
+ }
+
private class OverScrollHelper implements VerticalPullDetector.Listener {
private static final float MAX_RELEASE_VELOCITY = 5000; // px / s