Fix jank in launcher
The icon grid was reappearing at the end of the animation, causing
slower frame draws at the end of the animation, possibly leading
to jank.
Fix this by waiting with resetting the alpha until the whole
animation is done.
Test: Open/close apps
Bug: 75985430
Change-Id: I8fa62c5f648335ce9d4c4450d52c46465e2d08bf
(cherry picked from commit 197808681d)
This commit is contained in:
@@ -50,7 +50,9 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -178,7 +180,15 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
|
||||
anim.play(getIconAnimator(v));
|
||||
if (launcherClosing) {
|
||||
anim.play(getLauncherContentAnimator(false /* show */));
|
||||
Pair<AnimatorSet, Runnable> launcherContentAnimator =
|
||||
getLauncherContentAnimator(false /* show */);
|
||||
anim.play(launcherContentAnimator.first);
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
launcherContentAnimator.second.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
anim.play(getWindowAnimators(v, targetCompats));
|
||||
}
|
||||
@@ -267,8 +277,9 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
* @param show If true: Animate the content so that it moves upwards and fades in.
|
||||
* Else: Animate the content so that it moves downwards and fades out.
|
||||
*/
|
||||
private AnimatorSet getLauncherContentAnimator(boolean show) {
|
||||
private Pair<AnimatorSet, Runnable> getLauncherContentAnimator(boolean show) {
|
||||
AnimatorSet launcherAnimator = new AnimatorSet();
|
||||
Runnable endListener;
|
||||
|
||||
float[] alphas = show
|
||||
? new float[] {0, 1}
|
||||
@@ -288,6 +299,13 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
ObjectAnimator alpha = ObjectAnimator.ofFloat(appsView, View.ALPHA, alphas);
|
||||
alpha.setDuration(217);
|
||||
alpha.setInterpolator(LINEAR);
|
||||
appsView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
alpha.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
appsView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
});
|
||||
ObjectAnimator transY = ObjectAnimator.ofFloat(appsView, View.TRANSLATION_Y, trans);
|
||||
transY.setInterpolator(AGGRESSIVE_EASE);
|
||||
transY.setDuration(350);
|
||||
@@ -295,13 +313,11 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
launcherAnimator.play(alpha);
|
||||
launcherAnimator.play(transY);
|
||||
|
||||
launcherAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
appsView.setAlpha(startAlpha);
|
||||
appsView.setTranslationY(startY);
|
||||
}
|
||||
});
|
||||
endListener = () -> {
|
||||
appsView.setAlpha(startAlpha);
|
||||
appsView.setTranslationY(startY);
|
||||
appsView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
};
|
||||
} else {
|
||||
mDragLayer.setAlpha(alphas[0]);
|
||||
mDragLayer.setTranslationY(trans[0]);
|
||||
@@ -316,15 +332,14 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
|
||||
launcherAnimator.play(dragLayerAlpha);
|
||||
launcherAnimator.play(dragLayerTransY);
|
||||
launcherAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mDragLayer.setAlpha(1);
|
||||
mDragLayer.setTranslationY(0);
|
||||
}
|
||||
});
|
||||
mDragLayer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
endListener = () -> {
|
||||
mDragLayer.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
mDragLayer.setAlpha(1);
|
||||
mDragLayer.setTranslationY(0);
|
||||
};
|
||||
}
|
||||
return launcherAnimator;
|
||||
return new Pair<>(launcherAnimator, endListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -658,9 +673,16 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
private void createLauncherResumeAnimation(AnimatorSet anim) {
|
||||
if (mLauncher.isInState(LauncherState.ALL_APPS)
|
||||
|| mLauncher.getDeviceProfile().isVerticalBarLayout()) {
|
||||
AnimatorSet contentAnimator = getLauncherContentAnimator(true /* show */);
|
||||
contentAnimator.setStartDelay(LAUNCHER_RESUME_START_DELAY);
|
||||
anim.play(contentAnimator);
|
||||
Pair<AnimatorSet, Runnable> contentAnimator =
|
||||
getLauncherContentAnimator(true /* show */);
|
||||
contentAnimator.first.setStartDelay(LAUNCHER_RESUME_START_DELAY);
|
||||
anim.play(contentAnimator.first);
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
contentAnimator.second.run();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
AnimatorSet workspaceAnimator = new AnimatorSet();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user