summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/CellLayout.java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-08-13 20:03:33 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-08-13 20:03:33 +0000
commitb6ecb17356da95cdc4c9d66d1a47024a38fc4d23 (patch)
tree607ea53757fa794b3402545fc78f0c2433a6553e /src/com/android/launcher3/CellLayout.java
parent3b5793fdf57e6b6f4fb3bf6211e38bffe29e8941 (diff)
parent849c6a2b1815ffc8dfeb6c64e16e85e11a99d179 (diff)
downloadandroid_packages_apps_Trebuchet-b6ecb17356da95cdc4c9d66d1a47024a38fc4d23.tar.gz
android_packages_apps_Trebuchet-b6ecb17356da95cdc4c9d66d1a47024a38fc4d23.tar.bz2
android_packages_apps_Trebuchet-b6ecb17356da95cdc4c9d66d1a47024a38fc4d23.zip
Merge "Removing Launcher activity dependency on various animations" into ub-launcher3-master
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();