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