Merge changes from topic "am-40c467ee-c39c-4073-8110-b85bfe660cdb" into ub-launcher3-master

* changes:
  [automerger] Post at front of queue for app launch and recents launch am: 6e9f6838b8
  Post at front of queue for app launch and recents launch
This commit is contained in:
Jorim Jaggi
2018-04-25 14:16:28 +00:00
committed by Android (Google) Code Review
4 changed files with 22 additions and 7 deletions

View File

@@ -16,6 +16,7 @@
package com.android.launcher3;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.systemui.shared.recents.utilities.Utilities.postAtFrontOfQueueAsynchronously;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -35,20 +36,31 @@ public abstract class LauncherAnimationRunner implements RemoteAnimationRunnerCo
private static final int REFRESH_RATE_MS = 16;
private final Handler mHandler;
private final boolean mStartAtFrontOfQueue;
private AnimationResult mAnimationResult;
public LauncherAnimationRunner(Handler handler) {
/**
* @param startAtFrontOfQueue If true, the animation start will be posted at the front of the
* queue to minimize latency.
*/
public LauncherAnimationRunner(Handler handler, boolean startAtFrontOfQueue) {
mHandler = handler;
mStartAtFrontOfQueue = startAtFrontOfQueue;
}
@BinderThread
@Override
public void onAnimationStart(RemoteAnimationTargetCompat[] targetCompats, Runnable runnable) {
postAsyncCallback(mHandler, () -> {
Runnable r = () -> {
finishExistingAnimation();
mAnimationResult = new AnimationResult(runnable);
onCreateAnimation(targetCompats, mAnimationResult);
});
};
if (mStartAtFrontOfQueue) {
postAtFrontOfQueueAsynchronously(mHandler, r);
} else {
postAsyncCallback(mHandler, r);
}
}
/**

View File

@@ -162,7 +162,8 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
@Override
public ActivityOptions getActivityLaunchOptions(Launcher launcher, View v) {
if (hasControlRemoteAppTransitionPermission()) {
RemoteAnimationRunnerCompat runner = new LauncherAnimationRunner(mHandler) {
RemoteAnimationRunnerCompat runner = new LauncherAnimationRunner(mHandler,
true /* startAtFrontOfQueue */) {
@Override
public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats,
@@ -572,7 +573,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
* ie. pressing home, swiping up from nav bar.
*/
private RemoteAnimationRunnerCompat getWallpaperOpenRunner() {
return new LauncherAnimationRunner(mHandler) {
return new LauncherAnimationRunner(mHandler, false /* startAtFrontOfQueue */) {
@Override
public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats,
AnimationResult result) {

View File

@@ -172,7 +172,8 @@ public class RecentsActivity extends BaseDraggingActivity {
}
final TaskView taskView = (TaskView) v;
RemoteAnimationRunnerCompat runner = new LauncherAnimationRunner(mUiHandler) {
RemoteAnimationRunnerCompat runner = new LauncherAnimationRunner(mUiHandler,
true /* startAtFrontOfQueue */) {
@Override
public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats,

View File

@@ -31,7 +31,8 @@ public interface RemoteAnimationProvider {
AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] targets);
default ActivityOptions toActivityOptions(Handler handler, long duration) {
LauncherAnimationRunner runner = new LauncherAnimationRunner(handler) {
LauncherAnimationRunner runner = new LauncherAnimationRunner(handler,
false /* startAtFrontOfQueue */) {
@Override
public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats,