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
This commit is contained in:
Sunny Goyal
2018-08-08 16:33:46 -07:00
parent 52b28f0926
commit 849c6a2b18
15 changed files with 149 additions and 257 deletions

View File

@@ -16,24 +16,21 @@
package com.android.launcher3;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import static com.android.launcher3.Utilities.SINGLE_FRAME_MS;
import android.animation.ValueAnimator;
import android.util.Log;
import android.view.View;
import android.view.ViewPropertyAnimator;
import android.view.ViewTreeObserver;
import com.android.launcher3.util.Thunk;
import static com.android.launcher3.Utilities.SINGLE_FRAME_MS;
import com.android.launcher3.util.Thunk;
/*
* This is a helper class that listens to updates from the corresponding animation.
* For the first two frames, it adjusts the current play time of the animation to
* prevent jank at the beginning of the animation
*/
public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter
implements ValueAnimator.AnimatorUpdateListener {
public class FirstFrameAnimatorHelper implements ValueAnimator.AnimatorUpdateListener {
private static final String TAG = "FirstFrameAnimatorHlpr";
private static final boolean DEBUG = false;
private static final int MAX_DELAY = 1000;
@@ -52,18 +49,6 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter
animator.addUpdateListener(this);
}
public FirstFrameAnimatorHelper(ViewPropertyAnimator vpa, View target) {
mTarget = target;
vpa.setListener(this);
}
// only used for ViewPropertyAnimators
public void onAnimationStart(Animator animation) {
final ValueAnimator va = (ValueAnimator) animation;
va.addUpdateListener(FirstFrameAnimatorHelper.this);
onAnimationUpdate(va);
}
public static void setIsVisible(boolean visible) {
sVisible = visible;
}
@@ -78,6 +63,7 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter
sVisible = true;
}
@Override
public void onAnimationUpdate(final ValueAnimator animation) {
final long currentTime = System.currentTimeMillis();
if (mStartTime == -1) {
@@ -115,11 +101,7 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter
mAdjustedSecondFrameTime = true;
} else {
if (frameNum > 1) {
mTarget.post(new Runnable() {
public void run() {
animation.removeUpdateListener(FirstFrameAnimatorHelper.this);
}
});
mTarget.post(() -> animation.removeUpdateListener(this));
}
if (DEBUG) print(animation);
}