Merge "Avoid re-adding to existing split" into sc-v2-dev am: ef81c4557f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15369314 Change-Id: I94d808038a7c833f3b057db388abf4a8ef1a4662
This commit is contained in:
@@ -149,6 +149,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
|||||||
* Checks if the activity start should be routed to a particular container. It can create a new
|
* Checks if the activity start should be routed to a particular container. It can create a new
|
||||||
* container for the activity and a new split container if necessary.
|
* container for the activity and a new split container if necessary.
|
||||||
*/
|
*/
|
||||||
|
// TODO(b/190433398): Break down into smaller functions.
|
||||||
void onActivityCreated(@NonNull Activity launchedActivity) {
|
void onActivityCreated(@NonNull Activity launchedActivity) {
|
||||||
final ComponentName componentName = launchedActivity.getComponentName();
|
final ComponentName componentName = launchedActivity.getComponentName();
|
||||||
|
|
||||||
@@ -202,6 +203,18 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the split is already set.
|
||||||
|
final TaskFragmentContainer activityBelowContainer = getContainerWithActivity(
|
||||||
|
activityBelow.getActivityToken());
|
||||||
|
if (currentContainer != null && activityBelowContainer != null) {
|
||||||
|
final SplitContainer existingSplit = getActiveSplitForContainers(currentContainer,
|
||||||
|
activityBelowContainer);
|
||||||
|
if (existingSplit != null) {
|
||||||
|
// There is already an active split with the activity below.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final ExtensionSplitPairRule splitPairRule = getSplitRule(
|
final ExtensionSplitPairRule splitPairRule = getSplitRule(
|
||||||
activityBelow.getComponentName(), componentName, splitRules);
|
activityBelow.getComponentName(), componentName, splitRules);
|
||||||
if (splitPairRule == null) {
|
if (splitPairRule == null) {
|
||||||
@@ -339,7 +352,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the top active split container that has the provided container.
|
* Returns the top active split container that has the provided container, if available.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
private SplitContainer getActiveSplitForContainer(@NonNull TaskFragmentContainer container) {
|
private SplitContainer getActiveSplitForContainer(@NonNull TaskFragmentContainer container) {
|
||||||
@@ -353,6 +366,26 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the active split that has the provided containers as primary and secondary or as
|
||||||
|
* secondary and primary, if available.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
private SplitContainer getActiveSplitForContainers(
|
||||||
|
@NonNull TaskFragmentContainer firstContainer,
|
||||||
|
@NonNull TaskFragmentContainer secondContainer) {
|
||||||
|
for (int i = mSplitContainers.size() - 1; i >= 0; i--) {
|
||||||
|
SplitContainer splitContainer = mSplitContainers.get(i);
|
||||||
|
final TaskFragmentContainer primary = splitContainer.getPrimaryContainer();
|
||||||
|
final TaskFragmentContainer secondary = splitContainer.getSecondaryContainer();
|
||||||
|
if ((firstContainer == secondary && secondContainer == primary)
|
||||||
|
|| (firstContainer == primary && secondContainer == secondary)) {
|
||||||
|
return splitContainer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the container requires a placeholder and launches it if necessary.
|
* Checks if the container requires a placeholder and launches it if necessary.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user