summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/CellLayout.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2018-08-08 16:33:46 -0700
committerSunny Goyal <sunnygoyal@google.com>2018-08-10 13:31:46 -0700
commit849c6a2b1815ffc8dfeb6c64e16e85e11a99d179 (patch)
tree0f27488eedd03202232607f388aafbfad2315642 /src/com/android/launcher3/CellLayout.java
parent52b28f09264cb9689f3f88ca6d2f6f49ba654102 (diff)
downloadpackages_apps_Trebuchet-849c6a2b1815ffc8dfeb6c64e16e85e11a99d179.tar.gz
packages_apps_Trebuchet-849c6a2b1815ffc8dfeb6c64e16e85e11a99d179.tar.bz2
packages_apps_Trebuchet-849c6a2b1815ffc8dfeb6c64e16e85e11a99d179.zip
Removing Launcher activity dependency on various animations
(This cl reverts change-Id: I455edcd17bda83ab51c2c04fa40e66097a4d6975) Various animations were marked for cancellation when launcher activity is destroyed. This this does not work with multiple activities (Launcher, fallback recents, shortcut confirmation). Also since launcher activity handles configuration changes, the activity is not destroyed often. Instead associating a target with various animations which automatically cancels the animations when that target goes away. Change-Id: I64cd095a28075561a9e20c9dcdeb9f90c18e1047
Diffstat (limited to 'src/com/android/launcher3/CellLayout.java')
-rw-r--r--src/com/android/launcher3/CellLayout.java49
1 files changed, 32 insertions, 17 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 6c2fd8e53..260abd1aa 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -18,6 +18,7 @@ package com.android.launcher3;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
+import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
@@ -34,11 +35,13 @@ import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Parcelable;
+import android.os.SystemClock;
import android.support.annotation.IntDef;
import android.support.v4.view.ViewCompat;
import android.util.ArrayMap;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.Property;
import android.util.SparseArray;
import android.view.MotionEvent;
import android.view.View;
@@ -243,7 +246,7 @@ public class CellLayout extends ViewGroup {
for (int i = 0; i < mDragOutlineAnims.length; i++) {
final InterruptibleInOutAnimator anim =
- new InterruptibleInOutAnimator(this, duration, fromAlphaValue, toAlphaValue);
+ new InterruptibleInOutAnimator(duration, fromAlphaValue, toAlphaValue);
anim.getAnimator().setInterpolator(mEaseOutInterpolator);
final int thisIndex = i;
anim.getAnimator().addUpdateListener(new AnimatorUpdateListener() {
@@ -877,7 +880,7 @@ public class CellLayout extends ViewGroup {
return true;
}
- ValueAnimator va = LauncherAnimUtils.ofFloat(0f, 1f);
+ ValueAnimator va = ValueAnimator.ofFloat(0f, 1f);
va.setDuration(duration);
mReorderAnimators.put(lp, va);
@@ -1884,6 +1887,19 @@ public class CellLayout extends ViewGroup {
}
}
+ private static final Property<ReorderPreviewAnimation, Float> ANIMATION_PROGRESS =
+ new Property<ReorderPreviewAnimation, Float>(float.class, "animationProgress") {
+ @Override
+ public Float get(ReorderPreviewAnimation anim) {
+ return anim.animationProgress;
+ }
+
+ @Override
+ public void set(ReorderPreviewAnimation anim, Float progress) {
+ anim.setAnimationProgress(progress);
+ }
+ };
+
// Class which represents the reorder preview animations. These animations show that an item is
// in a temporary state, and hint at where the item will return to.
class ReorderPreviewAnimation {
@@ -1904,6 +1920,7 @@ public class CellLayout extends ViewGroup {
public static final int MODE_HINT = 0;
public static final int MODE_PREVIEW = 1;
+ float animationProgress = 0;
Animator a;
public ReorderPreviewAnimation(View child, int mode, int cellX0, int cellY0, int cellX1,
@@ -1974,7 +1991,7 @@ public class CellLayout extends ViewGroup {
if (noMovement) {
return;
}
- ValueAnimator va = LauncherAnimUtils.ofFloat(0f, 1f);
+ ValueAnimator va = ObjectAnimator.ofFloat(this, ANIMATION_PROGRESS, 0, 1);
a = va;
// Animations are disabled in power save mode, causing the repeated animation to jump
@@ -1987,20 +2004,6 @@ public class CellLayout extends ViewGroup {
va.setDuration(mode == MODE_HINT ? HINT_DURATION : PREVIEW_DURATION);
va.setStartDelay((int) (Math.random() * 60));
- va.addUpdateListener(new AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- float r = (Float) animation.getAnimatedValue();
- float r1 = (mode == MODE_HINT && repeating) ? 1.0f : r;
- float x = r1 * finalDeltaX + (1 - r1) * initDeltaX;
- float y = r1 * finalDeltaY + (1 - r1) * initDeltaY;
- child.setTranslationX(x);
- child.setTranslationY(y);
- float s = r * finalScale + (1 - r) * initScale;
- child.setScaleX(s);
- child.setScaleY(s);
- }
- });
va.addListener(new AnimatorListenerAdapter() {
public void onAnimationRepeat(Animator animation) {
// We make sure to end only after a full period
@@ -2012,6 +2015,18 @@ public class CellLayout extends ViewGroup {
va.start();
}
+ private void setAnimationProgress(float progress) {
+ animationProgress = progress;
+ float r1 = (mode == MODE_HINT && repeating) ? 1.0f : animationProgress;
+ float x = r1 * finalDeltaX + (1 - r1) * initDeltaX;
+ float y = r1 * finalDeltaY + (1 - r1) * initDeltaY;
+ child.setTranslationX(x);
+ child.setTranslationY(y);
+ float s = animationProgress * finalScale + (1 - animationProgress) * initScale;
+ child.setScaleX(s);
+ child.setScaleY(s);
+ }
+
private void cancel() {
if (a != null) {
a.cancel();