Cleaning up some animation states:

> When running one-off animations during quickstep, cancelling prevoisly
  running animations.
> Cancelling such one-off animations when state is reset
> Preventing touch proxied from recent transition to affect quickswitch
  (by affecting pagedView)

Bug: 135686388
Bug: 135571566
Change-Id: Id647015a583761d8fd46a02e3e2d88027e282a79
This commit is contained in:
Sunny Goyal
2019-06-20 11:34:14 -07:00
parent 06954c18fa
commit c4bb3739b1
10 changed files with 161 additions and 77 deletions

View File

@@ -111,6 +111,9 @@ public class LauncherStateManager {
private final Launcher mLauncher;
private final ArrayList<StateListener> mListeners = new ArrayList<>();
// Animators which are run on properties also controlled by state animations.
private Animator[] mStateElementAnimators;
private StateHandler[] mStateHandlers;
private LauncherState mState = NORMAL;
@@ -209,6 +212,7 @@ public class LauncherStateManager {
public void reapplyState(boolean cancelCurrentAnimation) {
boolean wasInAnimation = mConfig.mCurrentAnimation != null;
if (cancelCurrentAnimation) {
cancelAllStateElementAnimation();
cancelAnimation();
}
if (mConfig.mCurrentAnimation == null) {
@@ -250,6 +254,7 @@ public class LauncherStateManager {
mConfig.reset();
if (!animated) {
cancelAllStateElementAnimation();
onStateTransitionStart(state);
for (StateHandler handler : getStateHandlers()) {
handler.setState(state);
@@ -521,6 +526,47 @@ public class LauncherStateManager {
mConfig.setAnimation(anim, null);
}
private void cancelAllStateElementAnimation() {
if (mStateElementAnimators == null) {
return;
}
for (Animator animator : mStateElementAnimators) {
if (animator != null) {
animator.cancel();
}
}
}
/**
* Cancels a currently running gesture animation
*/
public void cancelStateElementAnimation(int index) {
if (mStateElementAnimators == null) {
return;
}
if (mStateElementAnimators[index] != null) {
mStateElementAnimators[index].cancel();
}
}
public Animator createStateElementAnimation(int index, float... values) {
cancelStateElementAnimation(index);
LauncherAppTransitionManager latm = mLauncher.getAppTransitionManager();
if (mStateElementAnimators == null) {
mStateElementAnimators = new Animator[latm.getStateElementAnimationsCount()];
}
Animator anim = latm.createStateElementAnimation(index, values);
mStateElementAnimators[index] = anim;
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mStateElementAnimators[index] = null;
}
});
return anim;
}
private void clearCurrentAnimation() {
if (mConfig.mCurrentAnimation != null) {
mConfig.mCurrentAnimation.removeListener(mConfig);