summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps
diff options
context:
space:
mode:
authorAndroid Build Merger (Role) <noreply-android-build-merger@google.com>2018-05-23 16:15:25 +0000
committerAndroid Build Merger (Role) <noreply-android-build-merger@google.com>2018-05-23 16:15:25 +0000
commit44ac2a804cf6a2a4179a9cb79b9ba079244aef29 (patch)
treedddc5e6cc3903fbfa9c99193322a016e80103b38 /src/com/android/launcher3/allapps
parent2c4ce244e376cc04cea487f6102eeed4643c036b (diff)
parent1d19e2f152de0ff55a83a54d81311620d70883f1 (diff)
downloadandroid_packages_apps_Trebuchet-44ac2a804cf6a2a4179a9cb79b9ba079244aef29.tar.gz
android_packages_apps_Trebuchet-44ac2a804cf6a2a4179a9cb79b9ba079244aef29.tar.bz2
android_packages_apps_Trebuchet-44ac2a804cf6a2a4179a9cb79b9ba079244aef29.zip
[automerger] Start springs for All Apps when user flings up. am: 1d19e2f152
Change-Id: Idaf7781f00a23fe6281f481f593c885dd7dbe441
Diffstat (limited to 'src/com/android/launcher3/allapps')
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index f8648bba0..68ad6e346 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -15,12 +15,14 @@
*/
package com.android.launcher3.allapps;
+import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Process;
+import android.support.animation.DynamicAnimation;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
@@ -61,6 +63,10 @@ import com.android.launcher3.views.SpringRelativeLayout;
public class AllAppsContainerView extends SpringRelativeLayout implements DragSource,
Insettable, OnDeviceProfileChangeListener {
+ private static final float FLING_VELOCITY_MULTIPLIER = 135f;
+ // Starts the springs after at least 55% of the animation has passed.
+ private static final float FLING_ANIMATION_THRESHOLD = 0.55f;
+
private final Launcher mLauncher;
private final AdapterHolder[] mAH;
private final ItemInfoMatcher mPersonalMatcher = ItemInfoMatcher.ofUser(Process.myUserHandle());
@@ -455,6 +461,32 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
}
}
+ /**
+ * Adds an update listener to {@param animator} that adds springs to the animation.
+ */
+ public void addSpringFromFlingUpdateListener(ValueAnimator animator, float velocity) {
+ animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator valueAnimator) {
+ if (valueAnimator.getAnimatedFraction() >= FLING_ANIMATION_THRESHOLD) {
+ int searchViewId = getSearchView().getId();
+ addSpringView(searchViewId);
+
+ finishWithShiftAndVelocity(1, velocity * FLING_VELOCITY_MULTIPLIER,
+ new DynamicAnimation.OnAnimationEndListener() {
+ @Override
+ public void onAnimationEnd(DynamicAnimation animation,
+ boolean canceled, float value, float velocity) {
+ removeSpringView(searchViewId);
+ }
+ });
+
+ animator.removeUpdateListener(this);
+ }
+ }
+ });
+ }
+
public class AdapterHolder {
public static final int MAIN = 0;
public static final int WORK = 1;