summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt2
-rw-r--r--api/system-current.txt2
-rw-r--r--api/test-current.txt2
-rw-r--r--core/java/android/app/BackStackRecord.java28
-rw-r--r--core/java/android/app/Fragment.java2
-rw-r--r--core/java/android/app/FragmentManager.java61
-rw-r--r--core/java/android/app/FragmentTransaction.java23
-rw-r--r--core/java/android/app/FragmentTransition.java73
8 files changed, 99 insertions, 94 deletions
diff --git a/api/current.txt b/api/current.txt
index 0fbb51bf2bbb..a462379b9ab3 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -4852,7 +4852,6 @@ package android.app {
method public abstract android.app.FragmentTransaction remove(android.app.Fragment);
method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment);
method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment, java.lang.String);
- method public abstract android.app.FragmentTransaction setAllowOptimization(boolean);
method public abstract android.app.FragmentTransaction setBreadCrumbShortTitle(int);
method public abstract android.app.FragmentTransaction setBreadCrumbShortTitle(java.lang.CharSequence);
method public abstract android.app.FragmentTransaction setBreadCrumbTitle(int);
@@ -4860,6 +4859,7 @@ package android.app {
method public abstract android.app.FragmentTransaction setCustomAnimations(int, int);
method public abstract android.app.FragmentTransaction setCustomAnimations(int, int, int, int);
method public abstract android.app.FragmentTransaction setPrimaryNavigationFragment(android.app.Fragment);
+ method public abstract android.app.FragmentTransaction setReorderingAllowed(boolean);
method public abstract android.app.FragmentTransaction setTransition(int);
method public abstract android.app.FragmentTransaction setTransitionStyle(int);
method public abstract android.app.FragmentTransaction show(android.app.Fragment);
diff --git a/api/system-current.txt b/api/system-current.txt
index be1887da61b8..8994f6e1e120 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -5020,7 +5020,6 @@ package android.app {
method public abstract android.app.FragmentTransaction remove(android.app.Fragment);
method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment);
method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment, java.lang.String);
- method public abstract android.app.FragmentTransaction setAllowOptimization(boolean);
method public abstract android.app.FragmentTransaction setBreadCrumbShortTitle(int);
method public abstract android.app.FragmentTransaction setBreadCrumbShortTitle(java.lang.CharSequence);
method public abstract android.app.FragmentTransaction setBreadCrumbTitle(int);
@@ -5028,6 +5027,7 @@ package android.app {
method public abstract android.app.FragmentTransaction setCustomAnimations(int, int);
method public abstract android.app.FragmentTransaction setCustomAnimations(int, int, int, int);
method public abstract android.app.FragmentTransaction setPrimaryNavigationFragment(android.app.Fragment);
+ method public abstract android.app.FragmentTransaction setReorderingAllowed(boolean);
method public abstract android.app.FragmentTransaction setTransition(int);
method public abstract android.app.FragmentTransaction setTransitionStyle(int);
method public abstract android.app.FragmentTransaction show(android.app.Fragment);
diff --git a/api/test-current.txt b/api/test-current.txt
index 51314c9da96d..706a2c63fa9d 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -4865,7 +4865,6 @@ package android.app {
method public abstract android.app.FragmentTransaction remove(android.app.Fragment);
method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment);
method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment, java.lang.String);
- method public abstract android.app.FragmentTransaction setAllowOptimization(boolean);
method public abstract android.app.FragmentTransaction setBreadCrumbShortTitle(int);
method public abstract android.app.FragmentTransaction setBreadCrumbShortTitle(java.lang.CharSequence);
method public abstract android.app.FragmentTransaction setBreadCrumbTitle(int);
@@ -4873,6 +4872,7 @@ package android.app {
method public abstract android.app.FragmentTransaction setCustomAnimations(int, int);
method public abstract android.app.FragmentTransaction setCustomAnimations(int, int, int, int);
method public abstract android.app.FragmentTransaction setPrimaryNavigationFragment(android.app.Fragment);
+ method public abstract android.app.FragmentTransaction setReorderingAllowed(boolean);
method public abstract android.app.FragmentTransaction setTransition(int);
method public abstract android.app.FragmentTransaction setTransitionStyle(int);
method public abstract android.app.FragmentTransaction show(android.app.Fragment);
diff --git a/core/java/android/app/BackStackRecord.java b/core/java/android/app/BackStackRecord.java
index cf274b4127ef..65c5b4f702b2 100644
--- a/core/java/android/app/BackStackRecord.java
+++ b/core/java/android/app/BackStackRecord.java
@@ -16,8 +16,6 @@
package android.app;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
@@ -45,7 +43,7 @@ final class BackStackState implements Parcelable {
final CharSequence mBreadCrumbShortTitleText;
final ArrayList<String> mSharedElementSourceNames;
final ArrayList<String> mSharedElementTargetNames;
- final boolean mAllowOptimization;
+ final boolean mReorderingAllowed;
public BackStackState(FragmentManagerImpl fm, BackStackRecord bse) {
final int numOps = bse.mOps.size();
@@ -75,7 +73,7 @@ final class BackStackState implements Parcelable {
mBreadCrumbShortTitleText = bse.mBreadCrumbShortTitleText;
mSharedElementSourceNames = bse.mSharedElementSourceNames;
mSharedElementTargetNames = bse.mSharedElementTargetNames;
- mAllowOptimization = bse.mAllowOptimization;
+ mReorderingAllowed = bse.mReorderingAllowed;
}
public BackStackState(Parcel in) {
@@ -90,7 +88,7 @@ final class BackStackState implements Parcelable {
mBreadCrumbShortTitleText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
mSharedElementSourceNames = in.createStringArrayList();
mSharedElementTargetNames = in.createStringArrayList();
- mAllowOptimization = in.readInt() != 0;
+ mReorderingAllowed = in.readInt() != 0;
}
public BackStackRecord instantiate(FragmentManagerImpl fm) {
@@ -133,7 +131,7 @@ final class BackStackState implements Parcelable {
bse.mBreadCrumbShortTitleText = mBreadCrumbShortTitleText;
bse.mSharedElementSourceNames = mSharedElementSourceNames;
bse.mSharedElementTargetNames = mSharedElementTargetNames;
- bse.mAllowOptimization = mAllowOptimization;
+ bse.mReorderingAllowed = mReorderingAllowed;
bse.bumpBackStackNesting(1);
return bse;
}
@@ -154,7 +152,7 @@ final class BackStackState implements Parcelable {
TextUtils.writeToParcel(mBreadCrumbShortTitleText, dest, 0);
dest.writeStringList(mSharedElementSourceNames);
dest.writeStringList(mSharedElementTargetNames);
- dest.writeInt(mAllowOptimization ? 1 : 0);
+ dest.writeInt(mReorderingAllowed ? 1 : 0);
}
public static final Parcelable.Creator<BackStackState> CREATOR
@@ -218,7 +216,7 @@ final class BackStackRecord extends FragmentTransaction implements
String mName;
boolean mCommitted;
int mIndex = -1;
- boolean mAllowOptimization;
+ boolean mReorderingAllowed;
ArrayList<Runnable> mCommitRunnables;
@@ -370,7 +368,7 @@ final class BackStackRecord extends FragmentTransaction implements
public BackStackRecord(FragmentManagerImpl manager) {
mManager = manager;
- mAllowOptimization = mManager.getTargetSdk() > Build.VERSION_CODES.N_MR1;
+ mReorderingAllowed = mManager.getTargetSdk() > Build.VERSION_CODES.N_MR1;
}
public int getId() {
@@ -665,8 +663,8 @@ final class BackStackRecord extends FragmentTransaction implements
}
@Override
- public FragmentTransaction setAllowOptimization(boolean allowOptimization) {
- mAllowOptimization = allowOptimization;
+ public FragmentTransaction setReorderingAllowed(boolean reorderingAllowed) {
+ mReorderingAllowed = reorderingAllowed;
return this;
}
@@ -800,11 +798,11 @@ final class BackStackRecord extends FragmentTransaction implements
default:
throw new IllegalArgumentException("Unknown cmd: " + op.cmd);
}
- if (!mAllowOptimization && op.cmd != OP_ADD && f != null) {
+ if (!mReorderingAllowed && op.cmd != OP_ADD && f != null) {
mManager.moveFragmentToExpectedState(f);
}
}
- if (!mAllowOptimization) {
+ if (!mReorderingAllowed) {
// Added fragments are added at the end to comply with prior behavior.
mManager.moveToState(mManager.mCurState, true);
}
@@ -859,11 +857,11 @@ final class BackStackRecord extends FragmentTransaction implements
default:
throw new IllegalArgumentException("Unknown cmd: " + op.cmd);
}
- if (!mAllowOptimization && op.cmd != OP_REMOVE && f != null) {
+ if (!mReorderingAllowed && op.cmd != OP_REMOVE && f != null) {
mManager.moveFragmentToExpectedState(f);
}
}
- if (!mAllowOptimization && moveToState) {
+ if (!mReorderingAllowed && moveToState) {
mManager.moveToState(mManager.mCurState, true);
}
}
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index 759efdb5b87b..c2fd0071bb28 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -2417,7 +2417,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
* enabled.
*
* @see Activity#postponeEnterTransition()
- * @see FragmentTransaction#setAllowOptimization(boolean)
+ * @see FragmentTransaction#setReorderingAllowed(boolean)
*/
public void postponeEnterTransition() {
ensureAnimationInfo().mEnterTransitionPostponed = true;
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 9e8809aed583..fdd1b7e72352 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -54,7 +54,6 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -682,7 +681,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
String mNoTransactionsBecause;
boolean mHavePendingDeferredStart;
- // Temporary vars for optimizing execution of BackStackRecords:
+ // Temporary vars for removing redundant operations in BackStackRecords:
ArrayList<BackStackRecord> mTmpRecords;
ArrayList<Boolean> mTmpIsPop;
ArrayList<Fragment> mTmpAddedFragments;
@@ -853,7 +852,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
if (executePop) {
mExecutingActions = true;
try {
- optimizeAndExecuteOps(mTmpRecords, mTmpIsPop);
+ removeRedundantOperationsAndExecute(mTmpRecords, mTmpIsPop);
} finally {
cleanupExec();
}
@@ -2002,7 +2001,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
if (action.generateOps(mTmpRecords, mTmpIsPop)) {
mExecutingActions = true;
try {
- optimizeAndExecuteOps(mTmpRecords, mTmpIsPop);
+ removeRedundantOperationsAndExecute(mTmpRecords, mTmpIsPop);
} finally {
cleanupExec();
}
@@ -2032,7 +2031,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
while (generateOpsForPendingActions(mTmpRecords, mTmpIsPop)) {
mExecutingActions = true;
try {
- optimizeAndExecuteOps(mTmpRecords, mTmpIsPop);
+ removeRedundantOperationsAndExecute(mTmpRecords, mTmpIsPop);
} finally {
cleanupExec();
}
@@ -2080,19 +2079,20 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
}
/**
- * Optimizes BackStackRecord operations. This method merges operations of proximate records
- * that allow optimization. See {@link FragmentTransaction#setAllowOptimization(boolean)}.
+ * Remove redundant BackStackRecord operations and executes them. This method merges operations
+ * of proximate records that allow reordering. See
+ * {@link FragmentTransaction#setReorderingAllowed(boolean)}.
* <p>
* For example, a transaction that adds to the back stack and then another that pops that
- * back stack record will be optimized.
+ * back stack record will be optimized to remove the unnecessary operation.
* <p>
* Likewise, two transactions committed that are executed at the same time will be optimized
- * as well as two pop operations executed together.
+ * to remove the redundant operations as well as two pop operations executed together.
*
* @param records The records pending execution
* @param isRecordPop The direction that these records are being run.
*/
- private void optimizeAndExecuteOps(ArrayList<BackStackRecord> records,
+ private void removeRedundantOperationsAndExecute(ArrayList<BackStackRecord> records,
ArrayList<Boolean> isRecordPop) {
if (records == null || records.isEmpty()) {
return;
@@ -2108,24 +2108,25 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
final int numRecords = records.size();
int startIndex = 0;
for (int recordNum = 0; recordNum < numRecords; recordNum++) {
- final boolean canOptimize = records.get(recordNum).mAllowOptimization;
- if (!canOptimize) {
+ final boolean canReorder = records.get(recordNum).mReorderingAllowed;
+ if (!canReorder) {
// execute all previous transactions
if (startIndex != recordNum) {
executeOpsTogether(records, isRecordPop, startIndex, recordNum);
}
- // execute all unoptimized pop operations together or one add operation
- int optimizeEnd = recordNum + 1;
+ // execute all pop operations that don't allow reordering together or
+ // one add operation
+ int reorderingEnd = recordNum + 1;
if (isRecordPop.get(recordNum)) {
- while (optimizeEnd < numRecords
- && isRecordPop.get(optimizeEnd)
- && !records.get(optimizeEnd).mAllowOptimization) {
- optimizeEnd++;
+ while (reorderingEnd < numRecords
+ && isRecordPop.get(reorderingEnd)
+ && !records.get(reorderingEnd).mReorderingAllowed) {
+ reorderingEnd++;
}
}
- executeOpsTogether(records, isRecordPop, recordNum, optimizeEnd);
- startIndex = optimizeEnd;
- recordNum = optimizeEnd - 1;
+ executeOpsTogether(records, isRecordPop, recordNum, reorderingEnd);
+ startIndex = reorderingEnd;
+ recordNum = reorderingEnd - 1;
}
}
if (startIndex != numRecords) {
@@ -2134,16 +2135,16 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
}
/**
- * Optimizes a subset of a list of BackStackRecords, all of which either allow optimization or
- * do not allow optimization.
- * @param records A list of BackStackRecords that are to be optimized
+ * Executes a subset of a list of BackStackRecords, all of which either allow reordering or
+ * do not allow ordering.
+ * @param records A list of BackStackRecords that are to be executed together
* @param isRecordPop The direction that these records are being run.
- * @param startIndex The index of the first record in <code>records</code> to be optimized
- * @param endIndex One more than the final record index in <code>records</code> to optimize.
+ * @param startIndex The index of the first record in <code>records</code> to be executed
+ * @param endIndex One more than the final record index in <code>records</code> to executed.
*/
private void executeOpsTogether(ArrayList<BackStackRecord> records,
ArrayList<Boolean> isRecordPop, int startIndex, int endIndex) {
- final boolean allowOptimization = records.get(startIndex).mAllowOptimization;
+ final boolean allowReordering = records.get(startIndex).mReorderingAllowed;
boolean addToBackStack = false;
if (mTmpAddedFragments == null) {
mTmpAddedFragments = new ArrayList<>();
@@ -2166,14 +2167,14 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
}
mTmpAddedFragments.clear();
- if (!allowOptimization) {
+ if (!allowReordering) {
FragmentTransition.startTransitions(this, records, isRecordPop, startIndex, endIndex,
false);
}
executeOps(records, isRecordPop, startIndex, endIndex);
int postponeIndex = endIndex;
- if (allowOptimization) {
+ if (allowReordering) {
ArraySet<Fragment> addedFragments = new ArraySet<>();
addAddedFragments(addedFragments);
postponeIndex = postponePostponableTransactions(records, isRecordPop,
@@ -2181,7 +2182,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
makeRemovedFragmentsInvisible(addedFragments);
}
- if (postponeIndex != startIndex && allowOptimization) {
+ if (postponeIndex != startIndex && allowReordering) {
// need to run something now
FragmentTransition.startTransitions(this, records, isRecordPop, startIndex,
postponeIndex, true);
diff --git a/core/java/android/app/FragmentTransaction.java b/core/java/android/app/FragmentTransaction.java
index c938aa607e10..a0e5a4ec6f1f 100644
--- a/core/java/android/app/FragmentTransaction.java
+++ b/core/java/android/app/FragmentTransaction.java
@@ -6,6 +6,7 @@ import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.StringRes;
import android.annotation.StyleRes;
+import android.os.Bundle;
import android.view.View;
import java.lang.annotation.Retention;
@@ -279,33 +280,37 @@ public abstract class FragmentTransaction {
/**
* Sets whether or not to allow optimizing operations within and across
- * transactions. Optimizing fragment transaction's operations can eliminate
+ * transactions. This will remove redundant operations, eliminating
* operations that cancel. For example, if two transactions are executed
* together, one that adds a fragment A and the next replaces it with fragment B,
* the operations will cancel and only fragment B will be added. That means that
* fragment A may not go through the creation/destruction lifecycle.
* <p>
- * The side effect of optimization is that fragments may have state changes
+ * The side effect of removing redundant operations is that fragments may have state changes
* out of the expected order. For example, one transaction adds fragment A,
- * a second adds fragment B, then a third removes fragment A. Without optimization,
- * fragment B could expect that while it is being created, fragment A will also
+ * a second adds fragment B, then a third removes fragment A. Without removing the redundant
+ * operations, fragment B could expect that while it is being created, fragment A will also
* exist because fragment A will be removed after fragment B was added.
- * With optimization, fragment B cannot expect fragment A to exist when
+ * With removing redundant operations, fragment B cannot expect fragment A to exist when
* it has been created because fragment A's add/remove will be optimized out.
* <p>
+ * It can also reorder the state changes of Fragments to allow for better Transitions.
+ * Added Fragments may have {@link Fragment#onCreate(Bundle)} called before replaced
+ * Fragments have {@link Fragment#onDestroy()} called.
+ * <p>
* The default is {@code false} for applications targeting version
* versions prior to O and {@code true} for applications targeting O and
* later.
*
- * @param allowOptimization {@code true} to enable optimizing operations
- * or {@code false} to disable optimizing
+ * @param reorderingAllowed {@code true} to enable optimizing out redundant operations
+ * or {@code false} to disable optimizing out redundant
* operations on this transaction.
*/
- public abstract FragmentTransaction setAllowOptimization(boolean allowOptimization);
+ public abstract FragmentTransaction setReorderingAllowed(boolean reorderingAllowed);
/**
* Add a Runnable to this transaction that will be run after this transaction has
- * been committed. If fragment transactions are {@link #setAllowOptimization(boolean) optimized}
+ * been committed. If fragment transactions are {@link #setReorderingAllowed(boolean) optimized}
* this may be after other subsequent fragment operations have also taken place, or operations
* in this transaction may have been optimized out due to the presence of a subsequent
* fragment transaction in the batch.
diff --git a/core/java/android/app/FragmentTransition.java b/core/java/android/app/FragmentTransition.java
index b4c6dce91a48..ceb828b64add 100644
--- a/core/java/android/app/FragmentTransition.java
+++ b/core/java/android/app/FragmentTransition.java
@@ -34,9 +34,10 @@ import java.util.List;
import java.util.Map;
/**
- * Contains the Fragment Transition functionality for both optimized and unoptimized
- * Fragment Transactions. With optimized fragment transactions, all Views have been
- * added to the View hierarchy prior to calling startTransitions. With
+ * Contains the Fragment Transition functionality for both ordered and reordered
+ * Fragment Transactions. With reordered fragment transactions, all Views have been
+ * added to the View hierarchy prior to calling startTransitions. With ordered
+ * fragment transactions, Views will be removed and added after calling startTransitions.
*/
class FragmentTransition {
/**
@@ -65,9 +66,9 @@ class FragmentTransition {
* {@link Fragment#getSharedElementReturnTransition()} and the entering
* {@link Fragment#getReenterTransition()} will be run.
* <p>
- * With optimized Fragment Transitions, all Views have been added to the
+ * With reordered Fragment Transitions, all Views have been added to the
* View hierarchy prior to calling this method. The incoming Fragment's Views
- * will be INVISIBLE. With unoptimized Fragment Transitions, this method
+ * will be INVISIBLE. With ordered Fragment Transitions, this method
* is called before any change has been made to the hierarchy. That means
* that the added Fragments have not created their Views yet and the hierarchy
* is unknown.
@@ -79,13 +80,13 @@ class FragmentTransition {
* part of this transition.
* @param endIndex One past the last index into records and isRecordPop to execute
* as part of this transition.
- * @param isOptimized true if this is an optimized transaction, meaning that the
+ * @param isReordered true if this is a reordered transaction, meaning that the
* Views of incoming fragments have been added. false if the
* transaction has yet to be run and Views haven't been created.
*/
static void startTransitions(FragmentManagerImpl fragmentManager,
ArrayList<BackStackRecord> records, ArrayList<Boolean> isRecordPop,
- int startIndex, int endIndex, boolean isOptimized) {
+ int startIndex, int endIndex, boolean isReordered) {
if (fragmentManager.mCurState < Fragment.CREATED) {
return;
}
@@ -95,9 +96,9 @@ class FragmentTransition {
final BackStackRecord record = records.get(i);
final boolean isPop = isRecordPop.get(i);
if (isPop) {
- calculatePopFragments(record, transitioningFragments, isOptimized);
+ calculatePopFragments(record, transitioningFragments, isReordered);
} else {
- calculateFragments(record, transitioningFragments, isOptimized);
+ calculateFragments(record, transitioningFragments, isReordered);
}
}
@@ -111,11 +112,11 @@ class FragmentTransition {
FragmentContainerTransition containerTransition = transitioningFragments.valueAt(i);
- if (isOptimized) {
- configureTransitionsOptimized(fragmentManager, containerId,
+ if (isReordered) {
+ configureTransitionsReordered(fragmentManager, containerId,
containerTransition, nonExistentView, nameOverrides);
} else {
- configureTransitionsUnoptimized(fragmentManager, containerId,
+ configureTransitionsOrdered(fragmentManager, containerId,
containerTransition, nonExistentView, nameOverrides);
}
}
@@ -175,7 +176,7 @@ class FragmentTransition {
/**
* Configures a transition for a single fragment container for which the transaction was
- * optimized. That means that all Fragment Views have been added and incoming fragment
+ * reordered. That means that all Fragment Views have been added and incoming fragment
* Views are marked invisible.
*
* @param fragmentManager The executing FragmentManagerImpl
@@ -188,7 +189,7 @@ class FragmentTransition {
* the final fragment's Views as given in
* {@link FragmentTransaction#addSharedElement(View, String)}.
*/
- private static void configureTransitionsOptimized(FragmentManagerImpl fragmentManager,
+ private static void configureTransitionsReordered(FragmentManagerImpl fragmentManager,
int containerId, FragmentContainerTransition fragments,
View nonExistentView, ArrayMap<String, String> nameOverrides) {
ViewGroup sceneRoot = null;
@@ -208,7 +209,7 @@ class FragmentTransition {
Transition enterTransition = getEnterTransition(inFragment, inIsPop);
Transition exitTransition = getExitTransition(outFragment, outIsPop);
- TransitionSet sharedElementTransition = configureSharedElementsOptimized(sceneRoot,
+ TransitionSet sharedElementTransition = configureSharedElementsReordered(sceneRoot,
nonExistentView, nameOverrides, fragments, sharedElementsOut, sharedElementsIn,
enterTransition, exitTransition);
@@ -247,7 +248,7 @@ class FragmentTransition {
/**
* Configures a transition for a single fragment container for which the transaction was
- * not optimized. That means that the transaction has not been executed yet, so incoming
+ * ordered. That means that the transaction has not been executed yet, so incoming
* Views are not yet known.
*
* @param fragmentManager The executing FragmentManagerImpl
@@ -260,7 +261,7 @@ class FragmentTransition {
* the final fragment's Views as given in
* {@link FragmentTransaction#addSharedElement(View, String)}.
*/
- private static void configureTransitionsUnoptimized(FragmentManagerImpl fragmentManager,
+ private static void configureTransitionsOrdered(FragmentManagerImpl fragmentManager,
int containerId, FragmentContainerTransition fragments,
View nonExistentView, ArrayMap<String, String> nameOverrides) {
ViewGroup sceneRoot = null;
@@ -281,7 +282,7 @@ class FragmentTransition {
ArrayList<View> sharedElementsOut = new ArrayList<>();
ArrayList<View> sharedElementsIn = new ArrayList<>();
- TransitionSet sharedElementTransition = configureSharedElementsUnoptimized(sceneRoot,
+ TransitionSet sharedElementTransition = configureSharedElementsOrdered(sceneRoot,
nonExistentView, nameOverrides, fragments, sharedElementsOut, sharedElementsIn,
enterTransition, exitTransition);
@@ -345,7 +346,7 @@ class FragmentTransition {
}
/**
- * This method is used for fragment transitions for unoptimized transactions to change the
+ * This method is used for fragment transitions for ordered transactions to change the
* enter and exit transition targets after the call to
* {@link TransitionManager#beginDelayedTransition(ViewGroup, Transition)}. The exit transition
* must ensure that it does not target any Views and the enter transition must start targeting
@@ -448,7 +449,7 @@ class FragmentTransition {
}
/**
- * Configures the shared elements of an optimized fragment transaction's transition.
+ * Configures the shared elements of an reordered fragment transaction's transition.
* This retrieves the shared elements of the outgoing and incoming fragments, maps the
* views, and sets up the epicenter on the transitions.
* <p>
@@ -474,7 +475,7 @@ class FragmentTransition {
* epicenter
* @return The shared element transition or null if no shared elements exist
*/
- private static TransitionSet configureSharedElementsOptimized(final ViewGroup sceneRoot,
+ private static TransitionSet configureSharedElementsReordered(final ViewGroup sceneRoot,
final View nonExistentView, ArrayMap<String, String> nameOverrides,
final FragmentContainerTransition fragments,
final ArrayList<View> sharedElementsOut,
@@ -576,7 +577,7 @@ class FragmentTransition {
}
/**
- * Configures the shared elements of an unoptimized fragment transaction's transition.
+ * Configures the shared elements of an ordered fragment transaction's transition.
* This retrieves the shared elements of the incoming fragments, and schedules capturing
* the incoming fragment's shared elements. It also maps the views, and sets up the epicenter
* on the transitions.
@@ -603,7 +604,7 @@ class FragmentTransition {
* epicenter
* @return The shared element transition or null if no shared elements exist
*/
- private static TransitionSet configureSharedElementsUnoptimized(final ViewGroup sceneRoot,
+ private static TransitionSet configureSharedElementsOrdered(final ViewGroup sceneRoot,
final View nonExistentView, ArrayMap<String, String> nameOverrides,
final FragmentContainerTransition fragments,
final ArrayList<View> sharedElementsOut,
@@ -1195,11 +1196,11 @@ class FragmentTransition {
*/
public static void calculateFragments(BackStackRecord transaction,
SparseArray<FragmentContainerTransition> transitioningFragments,
- boolean isOptimized) {
+ boolean isReordered) {
final int numOps = transaction.mOps.size();
for (int opNum = 0; opNum < numOps; opNum++) {
final BackStackRecord.Op op = transaction.mOps.get(opNum);
- addToFirstInLastOut(transaction, op, transitioningFragments, false, isOptimized);
+ addToFirstInLastOut(transaction, op, transitioningFragments, false, isReordered);
}
}
@@ -1212,14 +1213,14 @@ class FragmentTransition {
* this method.
*/
public static void calculatePopFragments(BackStackRecord transaction,
- SparseArray<FragmentContainerTransition> transitioningFragments, boolean isOptimized) {
+ SparseArray<FragmentContainerTransition> transitioningFragments, boolean isReordered) {
if (!transaction.mManager.mContainer.onHasView()) {
return; // nothing to see, so no transitions
}
final int numOps = transaction.mOps.size();
for (int opNum = numOps - 1; opNum >= 0; opNum--) {
final BackStackRecord.Op op = transaction.mOps.get(opNum);
- addToFirstInLastOut(transaction, op, transitioningFragments, true, isOptimized);
+ addToFirstInLastOut(transaction, op, transitioningFragments, true, isReordered);
}
}
@@ -1232,14 +1233,14 @@ class FragmentTransition {
* @param transitioningFragments A structure holding the first in and last out fragments
* for each fragment container.
* @param isPop Is the operation a pop?
- * @param isOptimizedTransaction True if the operations have been partially executed and the
+ * @param isReorderedTransaction True if the operations have been partially executed and the
* added fragments have Views in the hierarchy or false if the
* operations haven't been executed yet.
*/
@SuppressWarnings("ReferenceEquality")
private static void addToFirstInLastOut(BackStackRecord transaction, BackStackRecord.Op op,
SparseArray<FragmentContainerTransition> transitioningFragments, boolean isPop,
- boolean isOptimizedTransaction) {
+ boolean isReorderedTransaction) {
final Fragment fragment = op.fragment;
if (fragment == null) {
return; // no fragment, no transition
@@ -1255,7 +1256,7 @@ class FragmentTransition {
boolean wasAdded = false;
switch (command) {
case BackStackRecord.OP_SHOW:
- if (isOptimizedTransaction) {
+ if (isReorderedTransaction) {
setLastIn = fragment.mHiddenChanged && !fragment.mHidden &&
fragment.mAdded;
} else {
@@ -1265,7 +1266,7 @@ class FragmentTransition {
break;
case BackStackRecord.OP_ADD:
case BackStackRecord.OP_ATTACH:
- if (isOptimizedTransaction) {
+ if (isReorderedTransaction) {
setLastIn = fragment.mIsNewlyAdded;
} else {
setLastIn = !fragment.mAdded && !fragment.mHidden;
@@ -1273,7 +1274,7 @@ class FragmentTransition {
wasAdded = true;
break;
case BackStackRecord.OP_HIDE:
- if (isOptimizedTransaction) {
+ if (isReorderedTransaction) {
setFirstOut = fragment.mHiddenChanged && fragment.mAdded &&
fragment.mHidden;
} else {
@@ -1283,7 +1284,7 @@ class FragmentTransition {
break;
case BackStackRecord.OP_REMOVE:
case BackStackRecord.OP_DETACH:
- if (isOptimizedTransaction) {
+ if (isReorderedTransaction) {
setFirstOut = !fragment.mAdded && fragment.mView != null
&& fragment.mView.getVisibility() == View.VISIBLE
&& fragment.mView.getTransitionAlpha() > 0;
@@ -1301,7 +1302,7 @@ class FragmentTransition {
containerTransition.lastInIsPop = isPop;
containerTransition.lastInTransaction = transaction;
}
- if (!isOptimizedTransaction && wasAdded) {
+ if (!isReorderedTransaction && wasAdded) {
if (containerTransition != null && containerTransition.firstOut == fragment) {
containerTransition.firstOut = null;
}
@@ -1313,7 +1314,7 @@ class FragmentTransition {
FragmentManagerImpl manager = transaction.mManager;
if (fragment.mState < Fragment.CREATED && manager.mCurState >= Fragment.CREATED &&
manager.mHost.getContext().getApplicationInfo().targetSdkVersion >=
- Build.VERSION_CODES.N && !transaction.mAllowOptimization) {
+ Build.VERSION_CODES.N && !transaction.mReorderingAllowed) {
manager.makeActive(fragment);
manager.moveToState(fragment, Fragment.CREATED, 0, 0, false);
}
@@ -1326,7 +1327,7 @@ class FragmentTransition {
containerTransition.firstOutTransaction = transaction;
}
- if (!isOptimizedTransaction && wasRemoved &&
+ if (!isReorderedTransaction && wasRemoved &&
(containerTransition != null && containerTransition.lastIn == fragment)) {
containerTransition.lastIn = null;
}