Fix bug where floating view is removed before window animation is complete.

This fix attaches the AnimatorListenerAdapter on the parent AnimatorSet
to ensure all animations are complete before removing the floating view.

Bug: 110156760
Change-Id: I56638d745227e414583fa47a202c9aaa33874baa
This commit is contained in:
Jon Miranda
2018-06-19 14:16:58 -07:00
parent 3471127e8b
commit 53246e5fdc

View File

@@ -195,7 +195,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
mLauncher.getStateManager().setCurrentAnimation(anim);
Rect windowTargetBounds = getWindowTargetBounds(targetCompats);
anim.play(getIconAnimator(v, windowTargetBounds));
playIconAnimators(anim, v, windowTargetBounds);
if (launcherClosing) {
Pair<AnimatorSet, Runnable> launcherContentAnimator =
getLauncherContentAnimator(true /* isAppOpening */);
@@ -420,9 +420,9 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
}
/**
* @return Animator that controls the icon used to launch the target.
* Animators for the "floating view" of the view used to launch the target.
*/
private AnimatorSet getIconAnimator(View v, Rect windowTargetBounds) {
private void playIconAnimators(AnimatorSet appOpenAnimator, View v, Rect windowTargetBounds) {
final boolean isBubbleTextView = v instanceof BubbleTextView;
mFloatingView = new View(mLauncher);
if (isBubbleTextView && v.getTag() instanceof ItemInfoWithIcon ) {
@@ -477,7 +477,6 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
((ViewGroup) mDragLayer.getParent()).addView(mFloatingView);
v.setVisibility(View.INVISIBLE);
AnimatorSet appIconAnimatorSet = new AnimatorSet();
int[] dragLayerBounds = new int[2];
mDragLayer.getLocationOnScreen(dragLayerBounds);
@@ -507,8 +506,8 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
}
x.setInterpolator(AGGRESSIVE_EASE);
y.setInterpolator(AGGRESSIVE_EASE);
appIconAnimatorSet.play(x);
appIconAnimatorSet.play(y);
appOpenAnimator.play(x);
appOpenAnimator.play(y);
// Scale the app icon to take up the entire screen. This simplifies the math when
// animating the app window position / scale.
@@ -519,7 +518,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
.ofFloat(mFloatingView, SCALE_PROPERTY, startScale, scale);
scaleAnim.setDuration(APP_LAUNCH_DURATION)
.setInterpolator(Interpolators.EXAGGERATED_EASE);
appIconAnimatorSet.play(scaleAnim);
appOpenAnimator.play(scaleAnim);
// Fade out the app icon.
ObjectAnimator alpha = ObjectAnimator.ofFloat(mFloatingView, View.ALPHA, 1f, 0f);
@@ -532,9 +531,9 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
alpha.setDuration((long) (APP_LAUNCH_DOWN_DUR_SCALE_FACTOR * APP_LAUNCH_ALPHA_DURATION));
}
alpha.setInterpolator(LINEAR);
appIconAnimatorSet.play(alpha);
appOpenAnimator.play(alpha);
appIconAnimatorSet.addListener(new AnimatorListenerAdapter() {
appOpenAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
// Reset launcher to normal state
@@ -542,7 +541,6 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
((ViewGroup) mDragLayer.getParent()).removeView(mFloatingView);
}
});
return appIconAnimatorSet;
}
/**