Handling activity recreate due to configuration changes

in the middle of the long fling

Bug: 77651657
Change-Id: I8107c424eb37512ce78c943da04a6e7faf33be65
This commit is contained in:
Sunny Goyal
2018-04-30 15:32:12 -07:00
parent 433ef09d29
commit 16593d7932
2 changed files with 15 additions and 8 deletions

View File

@@ -182,8 +182,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
return new AnimationFactory() {
@Override
public void createActivityController(long transitionLength) {
createActivityControllerInternal(activity, activityVisible, transitionLength,
callback);
createActivityControllerInternal(activity, activityVisible, startState,
transitionLength, callback);
}
@Override
@@ -194,10 +194,12 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
}
private void createActivityControllerInternal(Launcher activity, boolean wasVisible,
long transitionLength, Consumer<AnimatorPlaybackController> callback) {
LauncherState startState, long transitionLength,
Consumer<AnimatorPlaybackController> callback) {
if (wasVisible) {
DeviceProfile dp = activity.getDeviceProfile();
long accuracy = 2 * Math.max(dp.widthPx, dp.heightPx);
activity.getStateManager().goToState(startState, false);
callback.accept(activity.getStateManager()
.createAnimationToNewWorkspace(OVERVIEW, accuracy));
return;

View File

@@ -163,10 +163,12 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());
private final Context mContext;
private final int mRunningTaskId;
private final ActivityControlHelper<T> mActivityControlHelper;
private final ActivityInitListener mActivityInitListener;
private final int mRunningTaskId;
private ThumbnailData mTaskSnapshot;
private MultiStateCallback mStateCallback;
private AnimatorPlaybackController mLauncherTransitionController;
@@ -705,9 +707,11 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
synchronized (mRecentsAnimationWrapper) {
if (mRecentsAnimationWrapper.controller != null) {
// Update the screenshot of the task
ThumbnailData thumbnail =
mRecentsAnimationWrapper.controller.screenshotTask(mRunningTaskId);
final TaskView taskView = mRecentsView.updateThumbnail(mRunningTaskId, thumbnail);
if (mTaskSnapshot == null) {
mTaskSnapshot = mRecentsAnimationWrapper.controller
.screenshotTask(mRunningTaskId);
}
TaskView taskView = mRecentsView.updateThumbnail(mRunningTaskId, mTaskSnapshot);
mRecentsView.setRunningTaskHidden(false);
if (taskView != null) {
// Defer finishing the animation until the next launcher frame with the
@@ -880,10 +884,11 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
private void onLongSwipeGestureFinishUi(float velocity, boolean isFling) {
if (!mUiLongSwipeMode || mLongSwipeController == null) {
mUiLongSwipeMode = false;
handleNormalGestureEnd(velocity, isFling);
return;
}
mUiLongSwipeMode = false;
finishCurrentTransitionToHome();
mLongSwipeController.end(velocity, isFling,
() -> setStateOnUiThread(STATE_HANDLER_INVALIDATED));