Merge "Delete dependent TaskFragments in the same transaction" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f74b9ddc8a
@@ -128,7 +128,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
||||
// Check if there are no running activities - consider the container empty if there are no
|
||||
// non-finishing activities left.
|
||||
if (!taskFragmentInfo.hasRunningActivity()) {
|
||||
cleanupContainer(container, true /* shouldFinishDependent */);
|
||||
mPresenter.cleanupContainer(container, true /* shouldFinishDependent */);
|
||||
updateCallbackIfNecessary();
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
||||
return;
|
||||
}
|
||||
|
||||
cleanupContainer(container, true /* shouldFinishDependent */);
|
||||
mPresenter.cleanupContainer(container, true /* shouldFinishDependent */);
|
||||
updateCallbackIfNecessary();
|
||||
}
|
||||
|
||||
@@ -307,13 +307,10 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
||||
mSplitContainers.add(splitContainer);
|
||||
}
|
||||
|
||||
void cleanupContainer(@NonNull TaskFragmentContainer container, boolean shouldFinishDependent) {
|
||||
if (container.isFinished()) {
|
||||
return;
|
||||
}
|
||||
|
||||
container.finish(shouldFinishDependent);
|
||||
|
||||
/**
|
||||
* Removes the container from bookkeeping records.
|
||||
*/
|
||||
void removeContainer(@NonNull TaskFragmentContainer container) {
|
||||
// Remove all split containers that included this one
|
||||
mContainers.remove(container);
|
||||
List<SplitContainer> containersToRemove = new ArrayList<>();
|
||||
@@ -324,8 +321,6 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
||||
}
|
||||
}
|
||||
mSplitContainers.removeAll(containersToRemove);
|
||||
|
||||
mPresenter.deleteContainer(container);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -462,7 +457,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
||||
return false;
|
||||
}
|
||||
|
||||
cleanupContainer(splitContainer.getSecondaryContainer(),
|
||||
mPresenter.cleanupContainer(splitContainer.getSecondaryContainer(),
|
||||
false /* shouldFinishDependent */);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,11 +68,13 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the provided container and updates the presentation if necessary.
|
||||
* Deletes the specified container and all other associated and dependent containers in the same
|
||||
* transaction.
|
||||
*/
|
||||
void deleteContainer(TaskFragmentContainer container) {
|
||||
void cleanupContainer(@NonNull TaskFragmentContainer container, boolean shouldFinishDependent) {
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
deleteTaskFragment(wct, container.getTaskFragmentToken());
|
||||
|
||||
container.finish(shouldFinishDependent, this, wct, mController);
|
||||
|
||||
final TaskFragmentContainer newTopContainer = mController.getTopActiveContainer();
|
||||
if (newTopContainer != null) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.graphics.Rect;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.window.TaskFragmentInfo;
|
||||
import android.window.WindowContainerTransaction;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -179,7 +180,8 @@ class TaskFragmentContainer {
|
||||
* Removes all activities that belong to this process and finishes other containers/activities
|
||||
* configured to finish together.
|
||||
*/
|
||||
void finish(boolean shouldFinishDependent) {
|
||||
void finish(boolean shouldFinishDependent, @NonNull SplitPresenter presenter,
|
||||
@NonNull WindowContainerTransaction wct, @NonNull SplitController controller) {
|
||||
if (mIsFinished) {
|
||||
return;
|
||||
}
|
||||
@@ -190,13 +192,19 @@ class TaskFragmentContainer {
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
// Cleanup the visuals
|
||||
presenter.deleteTaskFragment(wct, getTaskFragmentToken());
|
||||
// Cleanup the records
|
||||
controller.removeContainer(this);
|
||||
|
||||
if (!shouldFinishDependent) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Finish dependent containers
|
||||
for (TaskFragmentContainer container : mContainersToFinishOnExit) {
|
||||
container.finish(true /* shouldFinishDependent */);
|
||||
container.finish(true /* shouldFinishDependent */, presenter,
|
||||
wct, controller);
|
||||
}
|
||||
mContainersToFinishOnExit.clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user