If resume occurs, force finish of exiting activity.

Bug 27231404
Bug 27274246

Change-Id: Ia92fe6fdebced3e5a1fc9d165212ac1196f395bd
This commit is contained in:
George Mount
2016-03-23 13:10:13 -07:00
parent 52ff2b7798
commit bdc4d8dc96
4 changed files with 34 additions and 4 deletions

View File

@@ -1246,7 +1246,7 @@ public class Activity extends ContextThemeWrapper
protected void onResume() {
if (DEBUG_LIFECYCLE) Slog.v(TAG, "onResume " + this);
getApplication().dispatchActivityResumed(this);
mActivityTransitionState.onResume();
mActivityTransitionState.onResume(this, isTopOfTask());
mCalled = true;
}

View File

@@ -236,9 +236,27 @@ class ActivityTransitionState {
}
}
public void onResume() {
restoreExitedViews();
restoreReenteringViews();
public void onResume(Activity activity, boolean isTopOfTask) {
// After orientation change, the onResume can come in before the top Activity has
// left, so if the Activity is not top, wait a second for the top Activity to exit.
if (mCalledExitCoordinator == null) {
return; // This is the called activity
}
if (isTopOfTask || mEnterTransitionCoordinator == null) {
restoreExitedViews();
restoreReenteringViews();
} else {
activity.mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (mEnterTransitionCoordinator == null ||
mEnterTransitionCoordinator.isWaitingForRemoteExit()) {
restoreExitedViews();
restoreReenteringViews();
}
}
}, 1000);
}
}
public void clear() {

View File

@@ -244,6 +244,10 @@ class EnterTransitionCoordinator extends ActivityTransitionCoordinator {
}
}
public boolean isWaitingForRemoteExit() {
return mIsReturning && mResultReceiver != null;
}
/**
* This is called onResume. If an Activity is resuming and the transitions
* haven't started yet, force the views to appear. This is likely to be
@@ -288,6 +292,10 @@ class EnterTransitionCoordinator extends ActivityTransitionCoordinator {
cancelPendingTransitions();
}
mAreViewsReady = true;
if (mResultReceiver != null) {
mResultReceiver.send(MSG_CANCEL, null);
mResultReceiver = null;
}
}
private void cancel() {

View File

@@ -100,6 +100,10 @@ class ExitTransitionCoordinator extends ActivityTransitionCoordinator {
mExitSharedElementBundle = resultData;
sharedElementExitBack();
break;
case MSG_CANCEL:
mIsCanceled = true;
finish();
break;
}
}