2270 lines
92 KiB
Java
2270 lines
92 KiB
Java
package androidx.fragment.app;
|
|
|
|
import android.animation.Animator;
|
|
import android.animation.AnimatorListenerAdapter;
|
|
import android.content.Context;
|
|
import android.content.ContextWrapper;
|
|
import android.content.Intent;
|
|
import android.content.IntentSender;
|
|
import android.content.res.Configuration;
|
|
import android.os.Bundle;
|
|
import android.os.Looper;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.Menu;
|
|
import android.view.MenuInflater;
|
|
import android.view.MenuItem;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.activity.OnBackPressedCallback;
|
|
import androidx.activity.OnBackPressedDispatcher;
|
|
import androidx.activity.OnBackPressedDispatcherOwner;
|
|
import androidx.activity.result.ActivityResult;
|
|
import androidx.activity.result.ActivityResultCallback;
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
import androidx.activity.result.ActivityResultRegistry;
|
|
import androidx.activity.result.ActivityResultRegistryOwner;
|
|
import androidx.activity.result.IntentSenderRequest;
|
|
import androidx.activity.result.contract.ActivityResultContract;
|
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
import androidx.collection.ArraySet;
|
|
import androidx.core.os.CancellationSignal;
|
|
import androidx.fragment.R;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentAnim;
|
|
import androidx.fragment.app.FragmentTransaction;
|
|
import androidx.fragment.app.FragmentTransition;
|
|
import androidx.lifecycle.Lifecycle;
|
|
import androidx.lifecycle.LifecycleEventObserver;
|
|
import androidx.lifecycle.LifecycleOwner;
|
|
import androidx.lifecycle.ViewModelStore;
|
|
import androidx.lifecycle.ViewModelStoreOwner;
|
|
import java.io.FileDescriptor;
|
|
import java.io.PrintWriter;
|
|
import java.util.ArrayDeque;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class FragmentManager implements FragmentResultOwner {
|
|
private static boolean DEBUG = false;
|
|
private static final String EXTRA_CREATED_FILLIN_INTENT = "androidx.fragment.extra.ACTIVITY_OPTIONS_BUNDLE";
|
|
public static final int POP_BACK_STACK_INCLUSIVE = 1;
|
|
static final String TAG = "FragmentManager";
|
|
static boolean USE_STATE_MANAGER = true;
|
|
ArrayList<BackStackRecord> mBackStack;
|
|
private ArrayList<OnBackStackChangedListener> mBackStackChangeListeners;
|
|
private FragmentContainer mContainer;
|
|
private ArrayList<Fragment> mCreatedMenus;
|
|
private boolean mDestroyed;
|
|
private boolean mExecutingActions;
|
|
private boolean mHavePendingDeferredStart;
|
|
private FragmentHostCallback<?> mHost;
|
|
private boolean mNeedMenuInvalidate;
|
|
private FragmentManagerViewModel mNonConfig;
|
|
private OnBackPressedDispatcher mOnBackPressedDispatcher;
|
|
private Fragment mParent;
|
|
private ArrayList<StartEnterTransitionListener> mPostponedTransactions;
|
|
Fragment mPrimaryNav;
|
|
private ActivityResultLauncher<String[]> mRequestPermissions;
|
|
private ActivityResultLauncher<Intent> mStartActivityForResult;
|
|
private ActivityResultLauncher<IntentSenderRequest> mStartIntentSenderForResult;
|
|
private boolean mStateSaved;
|
|
private boolean mStopped;
|
|
private ArrayList<Fragment> mTmpAddedFragments;
|
|
private ArrayList<Boolean> mTmpIsPop;
|
|
private ArrayList<BackStackRecord> mTmpRecords;
|
|
private final ArrayList<OpGenerator> mPendingActions = new ArrayList<>();
|
|
private final FragmentStore mFragmentStore = new FragmentStore();
|
|
private final FragmentLayoutInflaterFactory mLayoutInflaterFactory = new FragmentLayoutInflaterFactory(this);
|
|
private final OnBackPressedCallback mOnBackPressedCallback = new OnBackPressedCallback(false) { // from class: androidx.fragment.app.FragmentManager.1
|
|
@Override // androidx.activity.OnBackPressedCallback
|
|
public void handleOnBackPressed() {
|
|
FragmentManager.this.handleOnBackPressed();
|
|
}
|
|
};
|
|
private final AtomicInteger mBackStackIndex = new AtomicInteger();
|
|
private final Map<String, Bundle> mResults = Collections.synchronizedMap(new HashMap());
|
|
private final Map<String, LifecycleAwareResultListener> mResultListeners = Collections.synchronizedMap(new HashMap());
|
|
private Map<Fragment, HashSet<CancellationSignal>> mExitAnimationCancellationSignals = Collections.synchronizedMap(new HashMap());
|
|
private final FragmentTransition.Callback mFragmentTransitionCallback = new FragmentTransition.Callback() { // from class: androidx.fragment.app.FragmentManager.2
|
|
@Override // androidx.fragment.app.FragmentTransition.Callback
|
|
public void onStart(Fragment fragment, CancellationSignal cancellationSignal) {
|
|
FragmentManager.this.addCancellationSignal(fragment, cancellationSignal);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentTransition.Callback
|
|
public void onComplete(Fragment fragment, CancellationSignal cancellationSignal) {
|
|
if (cancellationSignal.isCanceled()) {
|
|
return;
|
|
}
|
|
FragmentManager.this.removeCancellationSignal(fragment, cancellationSignal);
|
|
}
|
|
};
|
|
private final FragmentLifecycleCallbacksDispatcher mLifecycleCallbacksDispatcher = new FragmentLifecycleCallbacksDispatcher(this);
|
|
private final CopyOnWriteArrayList<FragmentOnAttachListener> mOnAttachListeners = new CopyOnWriteArrayList<>();
|
|
int mCurState = -1;
|
|
private FragmentFactory mFragmentFactory = null;
|
|
private FragmentFactory mHostFragmentFactory = new FragmentFactory() { // from class: androidx.fragment.app.FragmentManager.3
|
|
@Override // androidx.fragment.app.FragmentFactory
|
|
public Fragment instantiate(ClassLoader classLoader, String str) {
|
|
return FragmentManager.this.getHost().instantiate(FragmentManager.this.getHost().getContext(), str, null);
|
|
}
|
|
};
|
|
private SpecialEffectsControllerFactory mSpecialEffectsControllerFactory = null;
|
|
private SpecialEffectsControllerFactory mDefaultSpecialEffectsControllerFactory = new SpecialEffectsControllerFactory() { // from class: androidx.fragment.app.FragmentManager.4
|
|
@Override // androidx.fragment.app.SpecialEffectsControllerFactory
|
|
public SpecialEffectsController createController(ViewGroup viewGroup) {
|
|
return new DefaultSpecialEffectsController(viewGroup);
|
|
}
|
|
};
|
|
ArrayDeque<LaunchedFragmentInfo> mLaunchedFragments = new ArrayDeque<>();
|
|
private Runnable mExecCommit = new Runnable() { // from class: androidx.fragment.app.FragmentManager.5
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
FragmentManager.this.execPendingActions(true);
|
|
}
|
|
};
|
|
|
|
public interface BackStackEntry {
|
|
@Deprecated
|
|
CharSequence getBreadCrumbShortTitle();
|
|
|
|
@Deprecated
|
|
int getBreadCrumbShortTitleRes();
|
|
|
|
@Deprecated
|
|
CharSequence getBreadCrumbTitle();
|
|
|
|
@Deprecated
|
|
int getBreadCrumbTitleRes();
|
|
|
|
int getId();
|
|
|
|
String getName();
|
|
}
|
|
|
|
public static abstract class FragmentLifecycleCallbacks {
|
|
@Deprecated
|
|
public void onFragmentActivityCreated(FragmentManager fragmentManager, Fragment fragment, Bundle bundle) {
|
|
}
|
|
|
|
public void onFragmentAttached(FragmentManager fragmentManager, Fragment fragment, Context context) {
|
|
}
|
|
|
|
public void onFragmentCreated(FragmentManager fragmentManager, Fragment fragment, Bundle bundle) {
|
|
}
|
|
|
|
public void onFragmentDestroyed(FragmentManager fragmentManager, Fragment fragment) {
|
|
}
|
|
|
|
public void onFragmentDetached(FragmentManager fragmentManager, Fragment fragment) {
|
|
}
|
|
|
|
public void onFragmentPaused(FragmentManager fragmentManager, Fragment fragment) {
|
|
}
|
|
|
|
public void onFragmentPreAttached(FragmentManager fragmentManager, Fragment fragment, Context context) {
|
|
}
|
|
|
|
public void onFragmentPreCreated(FragmentManager fragmentManager, Fragment fragment, Bundle bundle) {
|
|
}
|
|
|
|
public void onFragmentResumed(FragmentManager fragmentManager, Fragment fragment) {
|
|
}
|
|
|
|
public void onFragmentSaveInstanceState(FragmentManager fragmentManager, Fragment fragment, Bundle bundle) {
|
|
}
|
|
|
|
public void onFragmentStarted(FragmentManager fragmentManager, Fragment fragment) {
|
|
}
|
|
|
|
public void onFragmentStopped(FragmentManager fragmentManager, Fragment fragment) {
|
|
}
|
|
|
|
public void onFragmentViewCreated(FragmentManager fragmentManager, Fragment fragment, View view, Bundle bundle) {
|
|
}
|
|
|
|
public void onFragmentViewDestroyed(FragmentManager fragmentManager, Fragment fragment) {
|
|
}
|
|
}
|
|
|
|
public interface OnBackStackChangedListener {
|
|
void onBackStackChanged();
|
|
}
|
|
|
|
interface OpGenerator {
|
|
boolean generateOps(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2);
|
|
}
|
|
|
|
@Deprecated
|
|
public static void enableDebugLogging(boolean z) {
|
|
DEBUG = z;
|
|
}
|
|
|
|
public static void enableNewStateManager(boolean z) {
|
|
USE_STATE_MANAGER = z;
|
|
}
|
|
|
|
static int reverseTransit(int i) {
|
|
if (i == 4097) {
|
|
return 8194;
|
|
}
|
|
if (i == 4099) {
|
|
return FragmentTransaction.TRANSIT_FRAGMENT_FADE;
|
|
}
|
|
if (i != 8194) {
|
|
return 0;
|
|
}
|
|
return FragmentTransaction.TRANSIT_FRAGMENT_OPEN;
|
|
}
|
|
|
|
FragmentContainer getContainer() {
|
|
return this.mContainer;
|
|
}
|
|
|
|
FragmentStore getFragmentStore() {
|
|
return this.mFragmentStore;
|
|
}
|
|
|
|
FragmentHostCallback<?> getHost() {
|
|
return this.mHost;
|
|
}
|
|
|
|
LayoutInflater.Factory2 getLayoutInflaterFactory() {
|
|
return this.mLayoutInflaterFactory;
|
|
}
|
|
|
|
FragmentLifecycleCallbacksDispatcher getLifecycleCallbacksDispatcher() {
|
|
return this.mLifecycleCallbacksDispatcher;
|
|
}
|
|
|
|
Fragment getParent() {
|
|
return this.mParent;
|
|
}
|
|
|
|
public Fragment getPrimaryNavigationFragment() {
|
|
return this.mPrimaryNav;
|
|
}
|
|
|
|
public boolean isDestroyed() {
|
|
return this.mDestroyed;
|
|
}
|
|
|
|
boolean isStateAtLeast(int i) {
|
|
return this.mCurState >= i;
|
|
}
|
|
|
|
public boolean isStateSaved() {
|
|
return this.mStateSaved || this.mStopped;
|
|
}
|
|
|
|
public void setFragmentFactory(FragmentFactory fragmentFactory) {
|
|
this.mFragmentFactory = fragmentFactory;
|
|
}
|
|
|
|
void setSpecialEffectsControllerFactory(SpecialEffectsControllerFactory specialEffectsControllerFactory) {
|
|
this.mSpecialEffectsControllerFactory = specialEffectsControllerFactory;
|
|
}
|
|
|
|
static boolean isLoggingEnabled(int i) {
|
|
return DEBUG || Log.isLoggable(TAG, i);
|
|
}
|
|
|
|
private static class LifecycleAwareResultListener implements FragmentResultListener {
|
|
private final Lifecycle mLifecycle;
|
|
private final FragmentResultListener mListener;
|
|
private final LifecycleEventObserver mObserver;
|
|
|
|
LifecycleAwareResultListener(Lifecycle lifecycle, FragmentResultListener fragmentResultListener, LifecycleEventObserver lifecycleEventObserver) {
|
|
this.mLifecycle = lifecycle;
|
|
this.mListener = fragmentResultListener;
|
|
this.mObserver = lifecycleEventObserver;
|
|
}
|
|
|
|
public boolean isAtLeast(Lifecycle.State state) {
|
|
return this.mLifecycle.getState().isAtLeast(state);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentResultListener
|
|
public void onFragmentResult(String str, Bundle bundle) {
|
|
this.mListener.onFragmentResult(str, bundle);
|
|
}
|
|
|
|
public void removeObserver() {
|
|
this.mLifecycle.removeObserver(this.mObserver);
|
|
}
|
|
}
|
|
|
|
private void throwException(RuntimeException runtimeException) {
|
|
Log.e(TAG, runtimeException.getMessage());
|
|
Log.e(TAG, "Activity state:");
|
|
PrintWriter printWriter = new PrintWriter(new LogWriter(TAG));
|
|
FragmentHostCallback<?> fragmentHostCallback = this.mHost;
|
|
if (fragmentHostCallback != null) {
|
|
try {
|
|
fragmentHostCallback.onDump(" ", null, printWriter, new String[0]);
|
|
throw runtimeException;
|
|
} catch (Exception e) {
|
|
Log.e(TAG, "Failed dumping state", e);
|
|
throw runtimeException;
|
|
}
|
|
}
|
|
try {
|
|
dump(" ", null, printWriter, new String[0]);
|
|
throw runtimeException;
|
|
} catch (Exception e2) {
|
|
Log.e(TAG, "Failed dumping state", e2);
|
|
throw runtimeException;
|
|
}
|
|
}
|
|
|
|
@Deprecated
|
|
public FragmentTransaction openTransaction() {
|
|
return beginTransaction();
|
|
}
|
|
|
|
public FragmentTransaction beginTransaction() {
|
|
return new BackStackRecord(this);
|
|
}
|
|
|
|
public boolean executePendingTransactions() {
|
|
boolean execPendingActions = execPendingActions(true);
|
|
forcePostponedTransactions();
|
|
return execPendingActions;
|
|
}
|
|
|
|
private void updateOnBackPressedCallbackEnabled() {
|
|
synchronized (this.mPendingActions) {
|
|
if (!this.mPendingActions.isEmpty()) {
|
|
this.mOnBackPressedCallback.setEnabled(true);
|
|
} else {
|
|
this.mOnBackPressedCallback.setEnabled(getBackStackEntryCount() > 0 && isPrimaryNavigation(this.mParent));
|
|
}
|
|
}
|
|
}
|
|
|
|
boolean isPrimaryNavigation(Fragment fragment) {
|
|
if (fragment == null) {
|
|
return true;
|
|
}
|
|
FragmentManager fragmentManager = fragment.mFragmentManager;
|
|
return fragment.equals(fragmentManager.getPrimaryNavigationFragment()) && isPrimaryNavigation(fragmentManager.mParent);
|
|
}
|
|
|
|
boolean isParentMenuVisible(Fragment fragment) {
|
|
if (fragment == null) {
|
|
return true;
|
|
}
|
|
return fragment.isMenuVisible();
|
|
}
|
|
|
|
void handleOnBackPressed() {
|
|
execPendingActions(true);
|
|
if (this.mOnBackPressedCallback.getIsEnabled()) {
|
|
popBackStackImmediate();
|
|
} else {
|
|
this.mOnBackPressedDispatcher.onBackPressed();
|
|
}
|
|
}
|
|
|
|
public void popBackStack() {
|
|
enqueueAction(new PopBackStackState(null, -1, 0), false);
|
|
}
|
|
|
|
public boolean popBackStackImmediate() {
|
|
return popBackStackImmediate(null, -1, 0);
|
|
}
|
|
|
|
public void popBackStack(String str, int i) {
|
|
enqueueAction(new PopBackStackState(str, -1, i), false);
|
|
}
|
|
|
|
public boolean popBackStackImmediate(String str, int i) {
|
|
return popBackStackImmediate(str, -1, i);
|
|
}
|
|
|
|
public void popBackStack(int i, int i2) {
|
|
if (i < 0) {
|
|
throw new IllegalArgumentException("Bad id: " + i);
|
|
}
|
|
enqueueAction(new PopBackStackState(null, i, i2), false);
|
|
}
|
|
|
|
public boolean popBackStackImmediate(int i, int i2) {
|
|
if (i < 0) {
|
|
throw new IllegalArgumentException("Bad id: " + i);
|
|
}
|
|
return popBackStackImmediate(null, i, i2);
|
|
}
|
|
|
|
private boolean popBackStackImmediate(String str, int i, int i2) {
|
|
execPendingActions(false);
|
|
ensureExecReady(true);
|
|
Fragment fragment = this.mPrimaryNav;
|
|
if (fragment != null && i < 0 && str == null && fragment.getChildFragmentManager().popBackStackImmediate()) {
|
|
return true;
|
|
}
|
|
boolean popBackStackState = popBackStackState(this.mTmpRecords, this.mTmpIsPop, str, i, i2);
|
|
if (popBackStackState) {
|
|
this.mExecutingActions = true;
|
|
try {
|
|
removeRedundantOperationsAndExecute(this.mTmpRecords, this.mTmpIsPop);
|
|
} finally {
|
|
cleanupExec();
|
|
}
|
|
}
|
|
updateOnBackPressedCallbackEnabled();
|
|
doPendingDeferredStart();
|
|
this.mFragmentStore.burpActive();
|
|
return popBackStackState;
|
|
}
|
|
|
|
public int getBackStackEntryCount() {
|
|
ArrayList<BackStackRecord> arrayList = this.mBackStack;
|
|
if (arrayList != null) {
|
|
return arrayList.size();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public BackStackEntry getBackStackEntryAt(int i) {
|
|
return this.mBackStack.get(i);
|
|
}
|
|
|
|
public void addOnBackStackChangedListener(OnBackStackChangedListener onBackStackChangedListener) {
|
|
if (this.mBackStackChangeListeners == null) {
|
|
this.mBackStackChangeListeners = new ArrayList<>();
|
|
}
|
|
this.mBackStackChangeListeners.add(onBackStackChangedListener);
|
|
}
|
|
|
|
public void removeOnBackStackChangedListener(OnBackStackChangedListener onBackStackChangedListener) {
|
|
ArrayList<OnBackStackChangedListener> arrayList = this.mBackStackChangeListeners;
|
|
if (arrayList != null) {
|
|
arrayList.remove(onBackStackChangedListener);
|
|
}
|
|
}
|
|
|
|
void addCancellationSignal(Fragment fragment, CancellationSignal cancellationSignal) {
|
|
if (this.mExitAnimationCancellationSignals.get(fragment) == null) {
|
|
this.mExitAnimationCancellationSignals.put(fragment, new HashSet<>());
|
|
}
|
|
this.mExitAnimationCancellationSignals.get(fragment).add(cancellationSignal);
|
|
}
|
|
|
|
void removeCancellationSignal(Fragment fragment, CancellationSignal cancellationSignal) {
|
|
HashSet<CancellationSignal> hashSet = this.mExitAnimationCancellationSignals.get(fragment);
|
|
if (hashSet != null && hashSet.remove(cancellationSignal) && hashSet.isEmpty()) {
|
|
this.mExitAnimationCancellationSignals.remove(fragment);
|
|
if (fragment.mState < 5) {
|
|
destroyFragmentView(fragment);
|
|
moveToState(fragment);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentResultOwner
|
|
public final void setFragmentResult(String str, Bundle bundle) {
|
|
LifecycleAwareResultListener lifecycleAwareResultListener = this.mResultListeners.get(str);
|
|
if (lifecycleAwareResultListener != null && lifecycleAwareResultListener.isAtLeast(Lifecycle.State.STARTED)) {
|
|
lifecycleAwareResultListener.onFragmentResult(str, bundle);
|
|
} else {
|
|
this.mResults.put(str, bundle);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentResultOwner
|
|
public final void clearFragmentResult(String str) {
|
|
this.mResults.remove(str);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentResultOwner
|
|
public final void setFragmentResultListener(final String str, LifecycleOwner lifecycleOwner, final FragmentResultListener fragmentResultListener) {
|
|
final Lifecycle lifecycle = lifecycleOwner.getLifecycle();
|
|
if (lifecycle.getState() == Lifecycle.State.DESTROYED) {
|
|
return;
|
|
}
|
|
LifecycleEventObserver lifecycleEventObserver = new LifecycleEventObserver() { // from class: androidx.fragment.app.FragmentManager.6
|
|
@Override // androidx.lifecycle.LifecycleEventObserver
|
|
public void onStateChanged(LifecycleOwner lifecycleOwner2, Lifecycle.Event event) {
|
|
Bundle bundle;
|
|
if (event == Lifecycle.Event.ON_START && (bundle = (Bundle) FragmentManager.this.mResults.get(str)) != null) {
|
|
fragmentResultListener.onFragmentResult(str, bundle);
|
|
FragmentManager.this.clearFragmentResult(str);
|
|
}
|
|
if (event == Lifecycle.Event.ON_DESTROY) {
|
|
lifecycle.removeObserver(this);
|
|
FragmentManager.this.mResultListeners.remove(str);
|
|
}
|
|
}
|
|
};
|
|
lifecycle.addObserver(lifecycleEventObserver);
|
|
LifecycleAwareResultListener put = this.mResultListeners.put(str, new LifecycleAwareResultListener(lifecycle, fragmentResultListener, lifecycleEventObserver));
|
|
if (put != null) {
|
|
put.removeObserver();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentResultOwner
|
|
public final void clearFragmentResultListener(String str) {
|
|
LifecycleAwareResultListener remove = this.mResultListeners.remove(str);
|
|
if (remove != null) {
|
|
remove.removeObserver();
|
|
}
|
|
}
|
|
|
|
public void putFragment(Bundle bundle, String str, Fragment fragment) {
|
|
if (fragment.mFragmentManager != this) {
|
|
throwException(new IllegalStateException("Fragment " + fragment + " is not currently in the FragmentManager"));
|
|
}
|
|
bundle.putString(str, fragment.mWho);
|
|
}
|
|
|
|
public Fragment getFragment(Bundle bundle, String str) {
|
|
String string = bundle.getString(str);
|
|
if (string == null) {
|
|
return null;
|
|
}
|
|
Fragment findActiveFragment = findActiveFragment(string);
|
|
if (findActiveFragment == null) {
|
|
throwException(new IllegalStateException("Fragment no longer exists for key " + str + ": unique id " + string));
|
|
}
|
|
return findActiveFragment;
|
|
}
|
|
|
|
public static <F extends Fragment> F findFragment(View view) {
|
|
F f = (F) findViewFragment(view);
|
|
if (f != null) {
|
|
return f;
|
|
}
|
|
throw new IllegalStateException("View " + view + " does not have a Fragment set");
|
|
}
|
|
|
|
private static Fragment findViewFragment(View view) {
|
|
while (view != null) {
|
|
Fragment viewFragment = getViewFragment(view);
|
|
if (viewFragment != null) {
|
|
return viewFragment;
|
|
}
|
|
Object parent = view.getParent();
|
|
view = parent instanceof View ? (View) parent : null;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static Fragment getViewFragment(View view) {
|
|
Object tag = view.getTag(R.id.fragment_container_view_tag);
|
|
if (tag instanceof Fragment) {
|
|
return (Fragment) tag;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
void onContainerAvailable(FragmentContainerView fragmentContainerView) {
|
|
for (FragmentStateManager fragmentStateManager : this.mFragmentStore.getActiveFragmentStateManagers()) {
|
|
Fragment fragment = fragmentStateManager.getFragment();
|
|
if (fragment.mContainerId == fragmentContainerView.getId() && fragment.mView != null && fragment.mView.getParent() == null) {
|
|
fragment.mContainer = fragmentContainerView;
|
|
fragmentStateManager.addViewToContainer();
|
|
}
|
|
}
|
|
}
|
|
|
|
static FragmentManager findFragmentManager(View view) {
|
|
FragmentActivity fragmentActivity;
|
|
Fragment findViewFragment = findViewFragment(view);
|
|
if (findViewFragment != null) {
|
|
if (!findViewFragment.isAdded()) {
|
|
throw new IllegalStateException("The Fragment " + findViewFragment + " that owns View " + view + " has already been destroyed. Nested fragments should always use the child FragmentManager.");
|
|
}
|
|
return findViewFragment.getChildFragmentManager();
|
|
}
|
|
Context context = view.getContext();
|
|
while (true) {
|
|
if (!(context instanceof ContextWrapper)) {
|
|
fragmentActivity = null;
|
|
break;
|
|
}
|
|
if (context instanceof FragmentActivity) {
|
|
fragmentActivity = (FragmentActivity) context;
|
|
break;
|
|
}
|
|
context = ((ContextWrapper) context).getBaseContext();
|
|
}
|
|
if (fragmentActivity != null) {
|
|
return fragmentActivity.getSupportFragmentManager();
|
|
}
|
|
throw new IllegalStateException("View " + view + " is not within a subclass of FragmentActivity.");
|
|
}
|
|
|
|
public List<Fragment> getFragments() {
|
|
return this.mFragmentStore.getFragments();
|
|
}
|
|
|
|
ViewModelStore getViewModelStore(Fragment fragment) {
|
|
return this.mNonConfig.getViewModelStore(fragment);
|
|
}
|
|
|
|
private FragmentManagerViewModel getChildNonConfig(Fragment fragment) {
|
|
return this.mNonConfig.getChildNonConfig(fragment);
|
|
}
|
|
|
|
void addRetainedFragment(Fragment fragment) {
|
|
this.mNonConfig.addRetainedFragment(fragment);
|
|
}
|
|
|
|
void removeRetainedFragment(Fragment fragment) {
|
|
this.mNonConfig.removeRetainedFragment(fragment);
|
|
}
|
|
|
|
List<Fragment> getActiveFragments() {
|
|
return this.mFragmentStore.getActiveFragments();
|
|
}
|
|
|
|
int getActiveFragmentCount() {
|
|
return this.mFragmentStore.getActiveFragmentCount();
|
|
}
|
|
|
|
public Fragment.SavedState saveFragmentInstanceState(Fragment fragment) {
|
|
FragmentStateManager fragmentStateManager = this.mFragmentStore.getFragmentStateManager(fragment.mWho);
|
|
if (fragmentStateManager == null || !fragmentStateManager.getFragment().equals(fragment)) {
|
|
throwException(new IllegalStateException("Fragment " + fragment + " is not currently in the FragmentManager"));
|
|
}
|
|
return fragmentStateManager.saveInstanceState();
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder(128);
|
|
sb.append("FragmentManager{");
|
|
sb.append(Integer.toHexString(System.identityHashCode(this)));
|
|
sb.append(" in ");
|
|
Fragment fragment = this.mParent;
|
|
if (fragment != null) {
|
|
sb.append(fragment.getClass().getSimpleName());
|
|
sb.append("{");
|
|
sb.append(Integer.toHexString(System.identityHashCode(this.mParent)));
|
|
sb.append("}");
|
|
} else {
|
|
FragmentHostCallback<?> fragmentHostCallback = this.mHost;
|
|
if (fragmentHostCallback != null) {
|
|
sb.append(fragmentHostCallback.getClass().getSimpleName());
|
|
sb.append("{");
|
|
sb.append(Integer.toHexString(System.identityHashCode(this.mHost)));
|
|
sb.append("}");
|
|
} else {
|
|
sb.append("null");
|
|
}
|
|
}
|
|
sb.append("}}");
|
|
return sb.toString();
|
|
}
|
|
|
|
public void dump(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
|
|
int size;
|
|
int size2;
|
|
String str2 = str + " ";
|
|
this.mFragmentStore.dump(str, fileDescriptor, printWriter, strArr);
|
|
ArrayList<Fragment> arrayList = this.mCreatedMenus;
|
|
if (arrayList != null && (size2 = arrayList.size()) > 0) {
|
|
printWriter.print(str);
|
|
printWriter.println("Fragments Created Menus:");
|
|
for (int i = 0; i < size2; i++) {
|
|
Fragment fragment = this.mCreatedMenus.get(i);
|
|
printWriter.print(str);
|
|
printWriter.print(" #");
|
|
printWriter.print(i);
|
|
printWriter.print(": ");
|
|
printWriter.println(fragment.toString());
|
|
}
|
|
}
|
|
ArrayList<BackStackRecord> arrayList2 = this.mBackStack;
|
|
if (arrayList2 != null && (size = arrayList2.size()) > 0) {
|
|
printWriter.print(str);
|
|
printWriter.println("Back Stack:");
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
BackStackRecord backStackRecord = this.mBackStack.get(i2);
|
|
printWriter.print(str);
|
|
printWriter.print(" #");
|
|
printWriter.print(i2);
|
|
printWriter.print(": ");
|
|
printWriter.println(backStackRecord.toString());
|
|
backStackRecord.dump(str2, printWriter);
|
|
}
|
|
}
|
|
printWriter.print(str);
|
|
printWriter.println("Back Stack Index: " + this.mBackStackIndex.get());
|
|
synchronized (this.mPendingActions) {
|
|
int size3 = this.mPendingActions.size();
|
|
if (size3 > 0) {
|
|
printWriter.print(str);
|
|
printWriter.println("Pending Actions:");
|
|
for (int i3 = 0; i3 < size3; i3++) {
|
|
OpGenerator opGenerator = this.mPendingActions.get(i3);
|
|
printWriter.print(str);
|
|
printWriter.print(" #");
|
|
printWriter.print(i3);
|
|
printWriter.print(": ");
|
|
printWriter.println(opGenerator);
|
|
}
|
|
}
|
|
}
|
|
printWriter.print(str);
|
|
printWriter.println("FragmentManager misc state:");
|
|
printWriter.print(str);
|
|
printWriter.print(" mHost=");
|
|
printWriter.println(this.mHost);
|
|
printWriter.print(str);
|
|
printWriter.print(" mContainer=");
|
|
printWriter.println(this.mContainer);
|
|
if (this.mParent != null) {
|
|
printWriter.print(str);
|
|
printWriter.print(" mParent=");
|
|
printWriter.println(this.mParent);
|
|
}
|
|
printWriter.print(str);
|
|
printWriter.print(" mCurState=");
|
|
printWriter.print(this.mCurState);
|
|
printWriter.print(" mStateSaved=");
|
|
printWriter.print(this.mStateSaved);
|
|
printWriter.print(" mStopped=");
|
|
printWriter.print(this.mStopped);
|
|
printWriter.print(" mDestroyed=");
|
|
printWriter.println(this.mDestroyed);
|
|
if (this.mNeedMenuInvalidate) {
|
|
printWriter.print(str);
|
|
printWriter.print(" mNeedMenuInvalidate=");
|
|
printWriter.println(this.mNeedMenuInvalidate);
|
|
}
|
|
}
|
|
|
|
void performPendingDeferredStart(FragmentStateManager fragmentStateManager) {
|
|
Fragment fragment = fragmentStateManager.getFragment();
|
|
if (fragment.mDeferStart) {
|
|
if (this.mExecutingActions) {
|
|
this.mHavePendingDeferredStart = true;
|
|
return;
|
|
}
|
|
fragment.mDeferStart = false;
|
|
if (USE_STATE_MANAGER) {
|
|
fragmentStateManager.moveToExpectedState();
|
|
} else {
|
|
moveToState(fragment);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:24:0x0055, code lost:
|
|
|
|
if (r2 != 5) goto L105;
|
|
*/
|
|
/* JADX WARN: Removed duplicated region for block: B:107:0x0165 */
|
|
/* JADX WARN: Removed duplicated region for block: B:26:0x0079 */
|
|
/* JADX WARN: Removed duplicated region for block: B:37:0x0074 */
|
|
/* JADX WARN: Removed duplicated region for block: B:39:0x006f */
|
|
/* JADX WARN: Removed duplicated region for block: B:41:0x0065 */
|
|
/* JADX WARN: Removed duplicated region for block: B:43:0x006a */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
void moveToState(androidx.fragment.app.Fragment r11, int r12) {
|
|
/*
|
|
Method dump skipped, instructions count: 409
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.fragment.app.FragmentManager.moveToState(androidx.fragment.app.Fragment, int):void");
|
|
}
|
|
|
|
private void cancelExitAnimation(Fragment fragment) {
|
|
HashSet<CancellationSignal> hashSet = this.mExitAnimationCancellationSignals.get(fragment);
|
|
if (hashSet != null) {
|
|
Iterator<CancellationSignal> it = hashSet.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().cancel();
|
|
}
|
|
hashSet.clear();
|
|
destroyFragmentView(fragment);
|
|
this.mExitAnimationCancellationSignals.remove(fragment);
|
|
}
|
|
}
|
|
|
|
void setExitAnimationOrder(Fragment fragment, boolean z) {
|
|
ViewGroup fragmentContainer = getFragmentContainer(fragment);
|
|
if (fragmentContainer == null || !(fragmentContainer instanceof FragmentContainerView)) {
|
|
return;
|
|
}
|
|
((FragmentContainerView) fragmentContainer).setDrawDisappearingViewsLast(!z);
|
|
}
|
|
|
|
private void destroyFragmentView(Fragment fragment) {
|
|
fragment.performDestroyView();
|
|
this.mLifecycleCallbacksDispatcher.dispatchOnFragmentViewDestroyed(fragment, false);
|
|
fragment.mContainer = null;
|
|
fragment.mView = null;
|
|
fragment.mViewLifecycleOwner = null;
|
|
fragment.mViewLifecycleOwnerLiveData.setValue(null);
|
|
fragment.mInLayout = false;
|
|
}
|
|
|
|
void moveToState(Fragment fragment) {
|
|
moveToState(fragment, this.mCurState);
|
|
}
|
|
|
|
private void completeShowHideFragment(final Fragment fragment) {
|
|
if (fragment.mView != null) {
|
|
FragmentAnim.AnimationOrAnimator loadAnimation = FragmentAnim.loadAnimation(this.mHost.getContext(), fragment, !fragment.mHidden, fragment.getPopDirection());
|
|
if (loadAnimation != null && loadAnimation.animator != null) {
|
|
loadAnimation.animator.setTarget(fragment.mView);
|
|
if (fragment.mHidden) {
|
|
if (fragment.isHideReplaced()) {
|
|
fragment.setHideReplaced(false);
|
|
} else {
|
|
final ViewGroup viewGroup = fragment.mContainer;
|
|
final View view = fragment.mView;
|
|
viewGroup.startViewTransition(view);
|
|
loadAnimation.animator.addListener(new AnimatorListenerAdapter() { // from class: androidx.fragment.app.FragmentManager.7
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationEnd(Animator animator) {
|
|
viewGroup.endViewTransition(view);
|
|
animator.removeListener(this);
|
|
if (fragment.mView == null || !fragment.mHidden) {
|
|
return;
|
|
}
|
|
fragment.mView.setVisibility(8);
|
|
}
|
|
});
|
|
}
|
|
} else {
|
|
fragment.mView.setVisibility(0);
|
|
}
|
|
loadAnimation.animator.start();
|
|
} else {
|
|
if (loadAnimation != null) {
|
|
fragment.mView.startAnimation(loadAnimation.animation);
|
|
loadAnimation.animation.start();
|
|
}
|
|
fragment.mView.setVisibility((!fragment.mHidden || fragment.isHideReplaced()) ? 0 : 8);
|
|
if (fragment.isHideReplaced()) {
|
|
fragment.setHideReplaced(false);
|
|
}
|
|
}
|
|
}
|
|
invalidateMenuForFragment(fragment);
|
|
fragment.mHiddenChanged = false;
|
|
fragment.onHiddenChanged(fragment.mHidden);
|
|
}
|
|
|
|
void moveFragmentToExpectedState(Fragment fragment) {
|
|
if (!this.mFragmentStore.containsActiveFragment(fragment.mWho)) {
|
|
if (isLoggingEnabled(3)) {
|
|
Log.d(TAG, "Ignoring moving " + fragment + " to state " + this.mCurState + "since it is not added to " + this);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
moveToState(fragment);
|
|
if (fragment.mView != null && fragment.mIsNewlyAdded && fragment.mContainer != null) {
|
|
if (fragment.mPostponedAlpha > 0.0f) {
|
|
fragment.mView.setAlpha(fragment.mPostponedAlpha);
|
|
}
|
|
fragment.mPostponedAlpha = 0.0f;
|
|
fragment.mIsNewlyAdded = false;
|
|
FragmentAnim.AnimationOrAnimator loadAnimation = FragmentAnim.loadAnimation(this.mHost.getContext(), fragment, true, fragment.getPopDirection());
|
|
if (loadAnimation != null) {
|
|
if (loadAnimation.animation != null) {
|
|
fragment.mView.startAnimation(loadAnimation.animation);
|
|
} else {
|
|
loadAnimation.animator.setTarget(fragment.mView);
|
|
loadAnimation.animator.start();
|
|
}
|
|
}
|
|
}
|
|
if (fragment.mHiddenChanged) {
|
|
completeShowHideFragment(fragment);
|
|
}
|
|
}
|
|
|
|
void moveToState(int i, boolean z) {
|
|
FragmentHostCallback<?> fragmentHostCallback;
|
|
if (this.mHost == null && i != -1) {
|
|
throw new IllegalStateException("No activity");
|
|
}
|
|
if (z || i != this.mCurState) {
|
|
this.mCurState = i;
|
|
if (USE_STATE_MANAGER) {
|
|
this.mFragmentStore.moveToExpectedState();
|
|
} else {
|
|
Iterator<Fragment> it = this.mFragmentStore.getFragments().iterator();
|
|
while (it.hasNext()) {
|
|
moveFragmentToExpectedState(it.next());
|
|
}
|
|
for (FragmentStateManager fragmentStateManager : this.mFragmentStore.getActiveFragmentStateManagers()) {
|
|
Fragment fragment = fragmentStateManager.getFragment();
|
|
if (!fragment.mIsNewlyAdded) {
|
|
moveFragmentToExpectedState(fragment);
|
|
}
|
|
if (fragment.mRemoving && !fragment.isInBackStack()) {
|
|
this.mFragmentStore.makeInactive(fragmentStateManager);
|
|
}
|
|
}
|
|
}
|
|
startPendingDeferredFragments();
|
|
if (this.mNeedMenuInvalidate && (fragmentHostCallback = this.mHost) != null && this.mCurState == 7) {
|
|
fragmentHostCallback.onSupportInvalidateOptionsMenu();
|
|
this.mNeedMenuInvalidate = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void startPendingDeferredFragments() {
|
|
Iterator<FragmentStateManager> it = this.mFragmentStore.getActiveFragmentStateManagers().iterator();
|
|
while (it.hasNext()) {
|
|
performPendingDeferredStart(it.next());
|
|
}
|
|
}
|
|
|
|
FragmentStateManager createOrGetFragmentStateManager(Fragment fragment) {
|
|
FragmentStateManager fragmentStateManager = this.mFragmentStore.getFragmentStateManager(fragment.mWho);
|
|
if (fragmentStateManager != null) {
|
|
return fragmentStateManager;
|
|
}
|
|
FragmentStateManager fragmentStateManager2 = new FragmentStateManager(this.mLifecycleCallbacksDispatcher, this.mFragmentStore, fragment);
|
|
fragmentStateManager2.restoreState(this.mHost.getContext().getClassLoader());
|
|
fragmentStateManager2.setFragmentManagerState(this.mCurState);
|
|
return fragmentStateManager2;
|
|
}
|
|
|
|
FragmentStateManager addFragment(Fragment fragment) {
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "add: " + fragment);
|
|
}
|
|
FragmentStateManager createOrGetFragmentStateManager = createOrGetFragmentStateManager(fragment);
|
|
fragment.mFragmentManager = this;
|
|
this.mFragmentStore.makeActive(createOrGetFragmentStateManager);
|
|
if (!fragment.mDetached) {
|
|
this.mFragmentStore.addFragment(fragment);
|
|
fragment.mRemoving = false;
|
|
if (fragment.mView == null) {
|
|
fragment.mHiddenChanged = false;
|
|
}
|
|
if (isMenuAvailable(fragment)) {
|
|
this.mNeedMenuInvalidate = true;
|
|
}
|
|
}
|
|
return createOrGetFragmentStateManager;
|
|
}
|
|
|
|
void removeFragment(Fragment fragment) {
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "remove: " + fragment + " nesting=" + fragment.mBackStackNesting);
|
|
}
|
|
boolean z = !fragment.isInBackStack();
|
|
if (!fragment.mDetached || z) {
|
|
this.mFragmentStore.removeFragment(fragment);
|
|
if (isMenuAvailable(fragment)) {
|
|
this.mNeedMenuInvalidate = true;
|
|
}
|
|
fragment.mRemoving = true;
|
|
setVisibleRemovingFragment(fragment);
|
|
}
|
|
}
|
|
|
|
void hideFragment(Fragment fragment) {
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "hide: " + fragment);
|
|
}
|
|
if (fragment.mHidden) {
|
|
return;
|
|
}
|
|
fragment.mHidden = true;
|
|
fragment.mHiddenChanged = true ^ fragment.mHiddenChanged;
|
|
setVisibleRemovingFragment(fragment);
|
|
}
|
|
|
|
void showFragment(Fragment fragment) {
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "show: " + fragment);
|
|
}
|
|
if (fragment.mHidden) {
|
|
fragment.mHidden = false;
|
|
fragment.mHiddenChanged = !fragment.mHiddenChanged;
|
|
}
|
|
}
|
|
|
|
void detachFragment(Fragment fragment) {
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "detach: " + fragment);
|
|
}
|
|
if (fragment.mDetached) {
|
|
return;
|
|
}
|
|
fragment.mDetached = true;
|
|
if (fragment.mAdded) {
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "remove from detach: " + fragment);
|
|
}
|
|
this.mFragmentStore.removeFragment(fragment);
|
|
if (isMenuAvailable(fragment)) {
|
|
this.mNeedMenuInvalidate = true;
|
|
}
|
|
setVisibleRemovingFragment(fragment);
|
|
}
|
|
}
|
|
|
|
void attachFragment(Fragment fragment) {
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "attach: " + fragment);
|
|
}
|
|
if (fragment.mDetached) {
|
|
fragment.mDetached = false;
|
|
if (fragment.mAdded) {
|
|
return;
|
|
}
|
|
this.mFragmentStore.addFragment(fragment);
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "add from attach: " + fragment);
|
|
}
|
|
if (isMenuAvailable(fragment)) {
|
|
this.mNeedMenuInvalidate = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public Fragment findFragmentById(int i) {
|
|
return this.mFragmentStore.findFragmentById(i);
|
|
}
|
|
|
|
public Fragment findFragmentByTag(String str) {
|
|
return this.mFragmentStore.findFragmentByTag(str);
|
|
}
|
|
|
|
Fragment findFragmentByWho(String str) {
|
|
return this.mFragmentStore.findFragmentByWho(str);
|
|
}
|
|
|
|
Fragment findActiveFragment(String str) {
|
|
return this.mFragmentStore.findActiveFragment(str);
|
|
}
|
|
|
|
private void checkStateLoss() {
|
|
if (isStateSaved()) {
|
|
throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
|
|
}
|
|
}
|
|
|
|
void enqueueAction(OpGenerator opGenerator, boolean z) {
|
|
if (!z) {
|
|
if (this.mHost == null) {
|
|
if (this.mDestroyed) {
|
|
throw new IllegalStateException("FragmentManager has been destroyed");
|
|
}
|
|
throw new IllegalStateException("FragmentManager has not been attached to a host.");
|
|
}
|
|
checkStateLoss();
|
|
}
|
|
synchronized (this.mPendingActions) {
|
|
if (this.mHost == null) {
|
|
if (!z) {
|
|
throw new IllegalStateException("Activity has been destroyed");
|
|
}
|
|
} else {
|
|
this.mPendingActions.add(opGenerator);
|
|
scheduleCommit();
|
|
}
|
|
}
|
|
}
|
|
|
|
void scheduleCommit() {
|
|
synchronized (this.mPendingActions) {
|
|
ArrayList<StartEnterTransitionListener> arrayList = this.mPostponedTransactions;
|
|
boolean z = (arrayList == null || arrayList.isEmpty()) ? false : true;
|
|
boolean z2 = this.mPendingActions.size() == 1;
|
|
if (z || z2) {
|
|
this.mHost.getHandler().removeCallbacks(this.mExecCommit);
|
|
this.mHost.getHandler().post(this.mExecCommit);
|
|
updateOnBackPressedCallbackEnabled();
|
|
}
|
|
}
|
|
}
|
|
|
|
int allocBackStackIndex() {
|
|
return this.mBackStackIndex.getAndIncrement();
|
|
}
|
|
|
|
private void ensureExecReady(boolean z) {
|
|
if (this.mExecutingActions) {
|
|
throw new IllegalStateException("FragmentManager is already executing transactions");
|
|
}
|
|
if (this.mHost == null) {
|
|
if (this.mDestroyed) {
|
|
throw new IllegalStateException("FragmentManager has been destroyed");
|
|
}
|
|
throw new IllegalStateException("FragmentManager has not been attached to a host.");
|
|
}
|
|
if (Looper.myLooper() != this.mHost.getHandler().getLooper()) {
|
|
throw new IllegalStateException("Must be called from main thread of fragment host");
|
|
}
|
|
if (!z) {
|
|
checkStateLoss();
|
|
}
|
|
if (this.mTmpRecords == null) {
|
|
this.mTmpRecords = new ArrayList<>();
|
|
this.mTmpIsPop = new ArrayList<>();
|
|
}
|
|
this.mExecutingActions = true;
|
|
try {
|
|
executePostponedTransaction(null, null);
|
|
} finally {
|
|
this.mExecutingActions = false;
|
|
}
|
|
}
|
|
|
|
void execSingleAction(OpGenerator opGenerator, boolean z) {
|
|
if (z && (this.mHost == null || this.mDestroyed)) {
|
|
return;
|
|
}
|
|
ensureExecReady(z);
|
|
if (opGenerator.generateOps(this.mTmpRecords, this.mTmpIsPop)) {
|
|
this.mExecutingActions = true;
|
|
try {
|
|
removeRedundantOperationsAndExecute(this.mTmpRecords, this.mTmpIsPop);
|
|
} finally {
|
|
cleanupExec();
|
|
}
|
|
}
|
|
updateOnBackPressedCallbackEnabled();
|
|
doPendingDeferredStart();
|
|
this.mFragmentStore.burpActive();
|
|
}
|
|
|
|
private void cleanupExec() {
|
|
this.mExecutingActions = false;
|
|
this.mTmpIsPop.clear();
|
|
this.mTmpRecords.clear();
|
|
}
|
|
|
|
boolean execPendingActions(boolean z) {
|
|
ensureExecReady(z);
|
|
boolean z2 = false;
|
|
while (generateOpsForPendingActions(this.mTmpRecords, this.mTmpIsPop)) {
|
|
z2 = true;
|
|
this.mExecutingActions = true;
|
|
try {
|
|
removeRedundantOperationsAndExecute(this.mTmpRecords, this.mTmpIsPop);
|
|
} finally {
|
|
cleanupExec();
|
|
}
|
|
}
|
|
updateOnBackPressedCallbackEnabled();
|
|
doPendingDeferredStart();
|
|
this.mFragmentStore.burpActive();
|
|
return z2;
|
|
}
|
|
|
|
private void executePostponedTransaction(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2) {
|
|
int indexOf;
|
|
int indexOf2;
|
|
ArrayList<StartEnterTransitionListener> arrayList3 = this.mPostponedTransactions;
|
|
int size = arrayList3 == null ? 0 : arrayList3.size();
|
|
int i = 0;
|
|
while (i < size) {
|
|
StartEnterTransitionListener startEnterTransitionListener = this.mPostponedTransactions.get(i);
|
|
if (arrayList != null && !startEnterTransitionListener.mIsBack && (indexOf2 = arrayList.indexOf(startEnterTransitionListener.mRecord)) != -1 && arrayList2 != null && arrayList2.get(indexOf2).booleanValue()) {
|
|
this.mPostponedTransactions.remove(i);
|
|
i--;
|
|
size--;
|
|
startEnterTransitionListener.cancelTransaction();
|
|
} else if (startEnterTransitionListener.isReady() || (arrayList != null && startEnterTransitionListener.mRecord.interactsWith(arrayList, 0, arrayList.size()))) {
|
|
this.mPostponedTransactions.remove(i);
|
|
i--;
|
|
size--;
|
|
if (arrayList != null && !startEnterTransitionListener.mIsBack && (indexOf = arrayList.indexOf(startEnterTransitionListener.mRecord)) != -1 && arrayList2 != null && arrayList2.get(indexOf).booleanValue()) {
|
|
startEnterTransitionListener.cancelTransaction();
|
|
} else {
|
|
startEnterTransitionListener.completeTransaction();
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
private void removeRedundantOperationsAndExecute(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2) {
|
|
if (arrayList.isEmpty()) {
|
|
return;
|
|
}
|
|
if (arrayList.size() != arrayList2.size()) {
|
|
throw new IllegalStateException("Internal error with the back stack records");
|
|
}
|
|
executePostponedTransaction(arrayList, arrayList2);
|
|
int size = arrayList.size();
|
|
int i = 0;
|
|
int i2 = 0;
|
|
while (i < size) {
|
|
if (!arrayList.get(i).mReorderingAllowed) {
|
|
if (i2 != i) {
|
|
executeOpsTogether(arrayList, arrayList2, i2, i);
|
|
}
|
|
i2 = i + 1;
|
|
if (arrayList2.get(i).booleanValue()) {
|
|
while (i2 < size && arrayList2.get(i2).booleanValue() && !arrayList.get(i2).mReorderingAllowed) {
|
|
i2++;
|
|
}
|
|
}
|
|
executeOpsTogether(arrayList, arrayList2, i, i2);
|
|
i = i2 - 1;
|
|
}
|
|
i++;
|
|
}
|
|
if (i2 != size) {
|
|
executeOpsTogether(arrayList, arrayList2, i2, size);
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARN: Removed duplicated region for block: B:48:0x00c5 */
|
|
/* JADX WARN: Removed duplicated region for block: B:82:0x019d */
|
|
/* JADX WARN: Removed duplicated region for block: B:93:0x01be */
|
|
/* JADX WARN: Removed duplicated region for block: B:96:? A[RETURN, SYNTHETIC] */
|
|
/* JADX WARN: Removed duplicated region for block: B:97:0x0143 */
|
|
/* JADX WARN: Type inference failed for: r1v17 */
|
|
/* JADX WARN: Type inference failed for: r1v3 */
|
|
/* JADX WARN: Type inference failed for: r1v4, types: [boolean, int] */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
private void executeOpsTogether(java.util.ArrayList<androidx.fragment.app.BackStackRecord> r18, java.util.ArrayList<java.lang.Boolean> r19, int r20, int r21) {
|
|
/*
|
|
Method dump skipped, instructions count: 450
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.fragment.app.FragmentManager.executeOpsTogether(java.util.ArrayList, java.util.ArrayList, int, int):void");
|
|
}
|
|
|
|
private Set<SpecialEffectsController> collectChangedControllers(ArrayList<BackStackRecord> arrayList, int i, int i2) {
|
|
ViewGroup viewGroup;
|
|
HashSet hashSet = new HashSet();
|
|
while (i < i2) {
|
|
Iterator<FragmentTransaction.Op> it = arrayList.get(i).mOps.iterator();
|
|
while (it.hasNext()) {
|
|
Fragment fragment = it.next().mFragment;
|
|
if (fragment != null && (viewGroup = fragment.mContainer) != null) {
|
|
hashSet.add(SpecialEffectsController.getOrCreateController(viewGroup, this));
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
return hashSet;
|
|
}
|
|
|
|
private void makeRemovedFragmentsInvisible(ArraySet<Fragment> arraySet) {
|
|
int size = arraySet.size();
|
|
for (int i = 0; i < size; i++) {
|
|
Fragment valueAt = arraySet.valueAt(i);
|
|
if (!valueAt.mAdded) {
|
|
View requireView = valueAt.requireView();
|
|
valueAt.mPostponedAlpha = requireView.getAlpha();
|
|
requireView.setAlpha(0.0f);
|
|
}
|
|
}
|
|
}
|
|
|
|
private int postponePostponableTransactions(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2, int i, int i2, ArraySet<Fragment> arraySet) {
|
|
int i3 = i2;
|
|
for (int i4 = i2 - 1; i4 >= i; i4--) {
|
|
BackStackRecord backStackRecord = arrayList.get(i4);
|
|
boolean booleanValue = arrayList2.get(i4).booleanValue();
|
|
if (backStackRecord.isPostponed() && !backStackRecord.interactsWith(arrayList, i4 + 1, i2)) {
|
|
if (this.mPostponedTransactions == null) {
|
|
this.mPostponedTransactions = new ArrayList<>();
|
|
}
|
|
StartEnterTransitionListener startEnterTransitionListener = new StartEnterTransitionListener(backStackRecord, booleanValue);
|
|
this.mPostponedTransactions.add(startEnterTransitionListener);
|
|
backStackRecord.setOnStartPostponedListener(startEnterTransitionListener);
|
|
if (booleanValue) {
|
|
backStackRecord.executeOps();
|
|
} else {
|
|
backStackRecord.executePopOps(false);
|
|
}
|
|
i3--;
|
|
if (i4 != i3) {
|
|
arrayList.remove(i4);
|
|
arrayList.add(i3, backStackRecord);
|
|
}
|
|
addAddedFragments(arraySet);
|
|
}
|
|
}
|
|
return i3;
|
|
}
|
|
|
|
void completeExecute(BackStackRecord backStackRecord, boolean z, boolean z2, boolean z3) {
|
|
if (z) {
|
|
backStackRecord.executePopOps(z3);
|
|
} else {
|
|
backStackRecord.executeOps();
|
|
}
|
|
ArrayList arrayList = new ArrayList(1);
|
|
ArrayList arrayList2 = new ArrayList(1);
|
|
arrayList.add(backStackRecord);
|
|
arrayList2.add(Boolean.valueOf(z));
|
|
if (z2 && this.mCurState >= 1) {
|
|
FragmentTransition.startTransitions(this.mHost.getContext(), this.mContainer, arrayList, arrayList2, 0, 1, true, this.mFragmentTransitionCallback);
|
|
}
|
|
if (z3) {
|
|
moveToState(this.mCurState, true);
|
|
}
|
|
for (Fragment fragment : this.mFragmentStore.getActiveFragments()) {
|
|
if (fragment != null && fragment.mView != null && fragment.mIsNewlyAdded && backStackRecord.interactsWith(fragment.mContainerId)) {
|
|
if (fragment.mPostponedAlpha > 0.0f) {
|
|
fragment.mView.setAlpha(fragment.mPostponedAlpha);
|
|
}
|
|
if (z3) {
|
|
fragment.mPostponedAlpha = 0.0f;
|
|
} else {
|
|
fragment.mPostponedAlpha = -1.0f;
|
|
fragment.mIsNewlyAdded = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void executeOps(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2, int i, int i2) {
|
|
while (i < i2) {
|
|
BackStackRecord backStackRecord = arrayList.get(i);
|
|
if (arrayList2.get(i).booleanValue()) {
|
|
backStackRecord.bumpBackStackNesting(-1);
|
|
backStackRecord.executePopOps(i == i2 + (-1));
|
|
} else {
|
|
backStackRecord.bumpBackStackNesting(1);
|
|
backStackRecord.executeOps();
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
private void setVisibleRemovingFragment(Fragment fragment) {
|
|
ViewGroup fragmentContainer = getFragmentContainer(fragment);
|
|
if (fragmentContainer == null || fragment.getEnterAnim() + fragment.getExitAnim() + fragment.getPopEnterAnim() + fragment.getPopExitAnim() <= 0) {
|
|
return;
|
|
}
|
|
if (fragmentContainer.getTag(R.id.visible_removing_fragment_view_tag) == null) {
|
|
fragmentContainer.setTag(R.id.visible_removing_fragment_view_tag, fragment);
|
|
}
|
|
((Fragment) fragmentContainer.getTag(R.id.visible_removing_fragment_view_tag)).setPopDirection(fragment.getPopDirection());
|
|
}
|
|
|
|
private ViewGroup getFragmentContainer(Fragment fragment) {
|
|
if (fragment.mContainer != null) {
|
|
return fragment.mContainer;
|
|
}
|
|
if (fragment.mContainerId > 0 && this.mContainer.onHasView()) {
|
|
View onFindViewById = this.mContainer.onFindViewById(fragment.mContainerId);
|
|
if (onFindViewById instanceof ViewGroup) {
|
|
return (ViewGroup) onFindViewById;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void addAddedFragments(ArraySet<Fragment> arraySet) {
|
|
int i = this.mCurState;
|
|
if (i < 1) {
|
|
return;
|
|
}
|
|
int min = Math.min(i, 5);
|
|
for (Fragment fragment : this.mFragmentStore.getFragments()) {
|
|
if (fragment.mState < min) {
|
|
moveToState(fragment, min);
|
|
if (fragment.mView != null && !fragment.mHidden && fragment.mIsNewlyAdded) {
|
|
arraySet.add(fragment);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void forcePostponedTransactions() {
|
|
if (USE_STATE_MANAGER) {
|
|
Iterator<SpecialEffectsController> it = collectAllSpecialEffectsController().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().forcePostponedExecutePendingOperations();
|
|
}
|
|
} else if (this.mPostponedTransactions != null) {
|
|
while (!this.mPostponedTransactions.isEmpty()) {
|
|
this.mPostponedTransactions.remove(0).completeTransaction();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void endAnimatingAwayFragments() {
|
|
if (USE_STATE_MANAGER) {
|
|
Iterator<SpecialEffectsController> it = collectAllSpecialEffectsController().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().forceCompleteAllOperations();
|
|
}
|
|
} else {
|
|
if (this.mExitAnimationCancellationSignals.isEmpty()) {
|
|
return;
|
|
}
|
|
for (Fragment fragment : this.mExitAnimationCancellationSignals.keySet()) {
|
|
cancelExitAnimation(fragment);
|
|
moveToState(fragment);
|
|
}
|
|
}
|
|
}
|
|
|
|
private Set<SpecialEffectsController> collectAllSpecialEffectsController() {
|
|
HashSet hashSet = new HashSet();
|
|
Iterator<FragmentStateManager> it = this.mFragmentStore.getActiveFragmentStateManagers().iterator();
|
|
while (it.hasNext()) {
|
|
ViewGroup viewGroup = it.next().getFragment().mContainer;
|
|
if (viewGroup != null) {
|
|
hashSet.add(SpecialEffectsController.getOrCreateController(viewGroup, getSpecialEffectsControllerFactory()));
|
|
}
|
|
}
|
|
return hashSet;
|
|
}
|
|
|
|
private boolean generateOpsForPendingActions(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2) {
|
|
synchronized (this.mPendingActions) {
|
|
if (this.mPendingActions.isEmpty()) {
|
|
return false;
|
|
}
|
|
int size = this.mPendingActions.size();
|
|
boolean z = false;
|
|
for (int i = 0; i < size; i++) {
|
|
z |= this.mPendingActions.get(i).generateOps(arrayList, arrayList2);
|
|
}
|
|
this.mPendingActions.clear();
|
|
this.mHost.getHandler().removeCallbacks(this.mExecCommit);
|
|
return z;
|
|
}
|
|
}
|
|
|
|
private void doPendingDeferredStart() {
|
|
if (this.mHavePendingDeferredStart) {
|
|
this.mHavePendingDeferredStart = false;
|
|
startPendingDeferredFragments();
|
|
}
|
|
}
|
|
|
|
private void reportBackStackChanged() {
|
|
if (this.mBackStackChangeListeners != null) {
|
|
for (int i = 0; i < this.mBackStackChangeListeners.size(); i++) {
|
|
this.mBackStackChangeListeners.get(i).onBackStackChanged();
|
|
}
|
|
}
|
|
}
|
|
|
|
void addBackStackState(BackStackRecord backStackRecord) {
|
|
if (this.mBackStack == null) {
|
|
this.mBackStack = new ArrayList<>();
|
|
}
|
|
this.mBackStack.add(backStackRecord);
|
|
}
|
|
|
|
boolean popBackStackState(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2, String str, int i, int i2) {
|
|
int i3;
|
|
ArrayList<BackStackRecord> arrayList3 = this.mBackStack;
|
|
if (arrayList3 == null) {
|
|
return false;
|
|
}
|
|
if (str == null && i < 0 && (i2 & 1) == 0) {
|
|
int size = arrayList3.size() - 1;
|
|
if (size < 0) {
|
|
return false;
|
|
}
|
|
arrayList.add(this.mBackStack.remove(size));
|
|
arrayList2.add(true);
|
|
} else {
|
|
if (str != null || i >= 0) {
|
|
int size2 = arrayList3.size() - 1;
|
|
while (size2 >= 0) {
|
|
BackStackRecord backStackRecord = this.mBackStack.get(size2);
|
|
if ((str != null && str.equals(backStackRecord.getName())) || (i >= 0 && i == backStackRecord.mIndex)) {
|
|
break;
|
|
}
|
|
size2--;
|
|
}
|
|
if (size2 < 0) {
|
|
return false;
|
|
}
|
|
if ((i2 & 1) != 0) {
|
|
while (true) {
|
|
size2--;
|
|
if (size2 < 0) {
|
|
break;
|
|
}
|
|
BackStackRecord backStackRecord2 = this.mBackStack.get(size2);
|
|
if (str == null || !str.equals(backStackRecord2.getName())) {
|
|
if (i < 0 || i != backStackRecord2.mIndex) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
i3 = size2;
|
|
} else {
|
|
i3 = -1;
|
|
}
|
|
if (i3 == this.mBackStack.size() - 1) {
|
|
return false;
|
|
}
|
|
for (int size3 = this.mBackStack.size() - 1; size3 > i3; size3--) {
|
|
arrayList.add(this.mBackStack.remove(size3));
|
|
arrayList2.add(true);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Deprecated
|
|
FragmentManagerNonConfig retainNonConfig() {
|
|
if (this.mHost instanceof ViewModelStoreOwner) {
|
|
throwException(new IllegalStateException("You cannot use retainNonConfig when your FragmentHostCallback implements ViewModelStoreOwner."));
|
|
}
|
|
return this.mNonConfig.getSnapshot();
|
|
}
|
|
|
|
Parcelable saveAllState() {
|
|
int size;
|
|
forcePostponedTransactions();
|
|
endAnimatingAwayFragments();
|
|
execPendingActions(true);
|
|
this.mStateSaved = true;
|
|
this.mNonConfig.setIsStateSaved(true);
|
|
ArrayList<FragmentState> saveActiveFragments = this.mFragmentStore.saveActiveFragments();
|
|
BackStackState[] backStackStateArr = null;
|
|
if (saveActiveFragments.isEmpty()) {
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "saveAllState: no fragments!");
|
|
}
|
|
return null;
|
|
}
|
|
ArrayList<String> saveAddedFragments = this.mFragmentStore.saveAddedFragments();
|
|
ArrayList<BackStackRecord> arrayList = this.mBackStack;
|
|
if (arrayList != null && (size = arrayList.size()) > 0) {
|
|
backStackStateArr = new BackStackState[size];
|
|
for (int i = 0; i < size; i++) {
|
|
backStackStateArr[i] = new BackStackState(this.mBackStack.get(i));
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "saveAllState: adding back stack #" + i + ": " + this.mBackStack.get(i));
|
|
}
|
|
}
|
|
}
|
|
FragmentManagerState fragmentManagerState = new FragmentManagerState();
|
|
fragmentManagerState.mActive = saveActiveFragments;
|
|
fragmentManagerState.mAdded = saveAddedFragments;
|
|
fragmentManagerState.mBackStack = backStackStateArr;
|
|
fragmentManagerState.mBackStackIndex = this.mBackStackIndex.get();
|
|
Fragment fragment = this.mPrimaryNav;
|
|
if (fragment != null) {
|
|
fragmentManagerState.mPrimaryNavActiveWho = fragment.mWho;
|
|
}
|
|
fragmentManagerState.mResultKeys.addAll(this.mResults.keySet());
|
|
fragmentManagerState.mResults.addAll(this.mResults.values());
|
|
fragmentManagerState.mLaunchedFragments = new ArrayList<>(this.mLaunchedFragments);
|
|
return fragmentManagerState;
|
|
}
|
|
|
|
void restoreAllState(Parcelable parcelable, FragmentManagerNonConfig fragmentManagerNonConfig) {
|
|
if (this.mHost instanceof ViewModelStoreOwner) {
|
|
throwException(new IllegalStateException("You must use restoreSaveState when your FragmentHostCallback implements ViewModelStoreOwner"));
|
|
}
|
|
this.mNonConfig.restoreFromSnapshot(fragmentManagerNonConfig);
|
|
restoreSaveState(parcelable);
|
|
}
|
|
|
|
void restoreSaveState(Parcelable parcelable) {
|
|
FragmentStateManager fragmentStateManager;
|
|
if (parcelable == null) {
|
|
return;
|
|
}
|
|
FragmentManagerState fragmentManagerState = (FragmentManagerState) parcelable;
|
|
if (fragmentManagerState.mActive == null) {
|
|
return;
|
|
}
|
|
this.mFragmentStore.resetActiveFragments();
|
|
Iterator<FragmentState> it = fragmentManagerState.mActive.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentState next = it.next();
|
|
if (next != null) {
|
|
Fragment findRetainedFragmentByWho = this.mNonConfig.findRetainedFragmentByWho(next.mWho);
|
|
if (findRetainedFragmentByWho != null) {
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "restoreSaveState: re-attaching retained " + findRetainedFragmentByWho);
|
|
}
|
|
fragmentStateManager = new FragmentStateManager(this.mLifecycleCallbacksDispatcher, this.mFragmentStore, findRetainedFragmentByWho, next);
|
|
} else {
|
|
fragmentStateManager = new FragmentStateManager(this.mLifecycleCallbacksDispatcher, this.mFragmentStore, this.mHost.getContext().getClassLoader(), getFragmentFactory(), next);
|
|
}
|
|
Fragment fragment = fragmentStateManager.getFragment();
|
|
fragment.mFragmentManager = this;
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "restoreSaveState: active (" + fragment.mWho + "): " + fragment);
|
|
}
|
|
fragmentStateManager.restoreState(this.mHost.getContext().getClassLoader());
|
|
this.mFragmentStore.makeActive(fragmentStateManager);
|
|
fragmentStateManager.setFragmentManagerState(this.mCurState);
|
|
}
|
|
}
|
|
for (Fragment fragment2 : this.mNonConfig.getRetainedFragments()) {
|
|
if (!this.mFragmentStore.containsActiveFragment(fragment2.mWho)) {
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "Discarding retained Fragment " + fragment2 + " that was not found in the set of active Fragments " + fragmentManagerState.mActive);
|
|
}
|
|
this.mNonConfig.removeRetainedFragment(fragment2);
|
|
fragment2.mFragmentManager = this;
|
|
FragmentStateManager fragmentStateManager2 = new FragmentStateManager(this.mLifecycleCallbacksDispatcher, this.mFragmentStore, fragment2);
|
|
fragmentStateManager2.setFragmentManagerState(1);
|
|
fragmentStateManager2.moveToExpectedState();
|
|
fragment2.mRemoving = true;
|
|
fragmentStateManager2.moveToExpectedState();
|
|
}
|
|
}
|
|
this.mFragmentStore.restoreAddedFragments(fragmentManagerState.mAdded);
|
|
if (fragmentManagerState.mBackStack != null) {
|
|
this.mBackStack = new ArrayList<>(fragmentManagerState.mBackStack.length);
|
|
for (int i = 0; i < fragmentManagerState.mBackStack.length; i++) {
|
|
BackStackRecord instantiate = fragmentManagerState.mBackStack[i].instantiate(this);
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "restoreAllState: back stack #" + i + " (index " + instantiate.mIndex + "): " + instantiate);
|
|
PrintWriter printWriter = new PrintWriter(new LogWriter(TAG));
|
|
instantiate.dump(" ", printWriter, false);
|
|
printWriter.close();
|
|
}
|
|
this.mBackStack.add(instantiate);
|
|
}
|
|
} else {
|
|
this.mBackStack = null;
|
|
}
|
|
this.mBackStackIndex.set(fragmentManagerState.mBackStackIndex);
|
|
if (fragmentManagerState.mPrimaryNavActiveWho != null) {
|
|
Fragment findActiveFragment = findActiveFragment(fragmentManagerState.mPrimaryNavActiveWho);
|
|
this.mPrimaryNav = findActiveFragment;
|
|
dispatchParentPrimaryNavigationFragmentChanged(findActiveFragment);
|
|
}
|
|
ArrayList<String> arrayList = fragmentManagerState.mResultKeys;
|
|
if (arrayList != null) {
|
|
for (int i2 = 0; i2 < arrayList.size(); i2++) {
|
|
Bundle bundle = fragmentManagerState.mResults.get(i2);
|
|
bundle.setClassLoader(this.mHost.getContext().getClassLoader());
|
|
this.mResults.put(arrayList.get(i2), bundle);
|
|
}
|
|
}
|
|
this.mLaunchedFragments = new ArrayDeque<>(fragmentManagerState.mLaunchedFragments);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
void attachController(FragmentHostCallback<?> fragmentHostCallback, FragmentContainer fragmentContainer, final Fragment fragment) {
|
|
String str;
|
|
if (this.mHost != null) {
|
|
throw new IllegalStateException("Already attached");
|
|
}
|
|
this.mHost = fragmentHostCallback;
|
|
this.mContainer = fragmentContainer;
|
|
this.mParent = fragment;
|
|
if (fragment != null) {
|
|
addFragmentOnAttachListener(new FragmentOnAttachListener() { // from class: androidx.fragment.app.FragmentManager.8
|
|
@Override // androidx.fragment.app.FragmentOnAttachListener
|
|
public void onAttachFragment(FragmentManager fragmentManager, Fragment fragment2) {
|
|
fragment.onAttachFragment(fragment2);
|
|
}
|
|
});
|
|
} else if (fragmentHostCallback instanceof FragmentOnAttachListener) {
|
|
addFragmentOnAttachListener((FragmentOnAttachListener) fragmentHostCallback);
|
|
}
|
|
if (this.mParent != null) {
|
|
updateOnBackPressedCallbackEnabled();
|
|
}
|
|
if (fragmentHostCallback instanceof OnBackPressedDispatcherOwner) {
|
|
OnBackPressedDispatcherOwner onBackPressedDispatcherOwner = (OnBackPressedDispatcherOwner) fragmentHostCallback;
|
|
OnBackPressedDispatcher onBackPressedDispatcher = onBackPressedDispatcherOwner.getOnBackPressedDispatcher();
|
|
this.mOnBackPressedDispatcher = onBackPressedDispatcher;
|
|
LifecycleOwner lifecycleOwner = onBackPressedDispatcherOwner;
|
|
if (fragment != null) {
|
|
lifecycleOwner = fragment;
|
|
}
|
|
onBackPressedDispatcher.addCallback(lifecycleOwner, this.mOnBackPressedCallback);
|
|
}
|
|
if (fragment != null) {
|
|
this.mNonConfig = fragment.mFragmentManager.getChildNonConfig(fragment);
|
|
} else if (fragmentHostCallback instanceof ViewModelStoreOwner) {
|
|
this.mNonConfig = FragmentManagerViewModel.getInstance(((ViewModelStoreOwner) fragmentHostCallback).getViewModelStore());
|
|
} else {
|
|
this.mNonConfig = new FragmentManagerViewModel(false);
|
|
}
|
|
this.mNonConfig.setIsStateSaved(isStateSaved());
|
|
this.mFragmentStore.setNonConfig(this.mNonConfig);
|
|
Object obj = this.mHost;
|
|
if (obj instanceof ActivityResultRegistryOwner) {
|
|
ActivityResultRegistry activityResultRegistry = ((ActivityResultRegistryOwner) obj).getActivityResultRegistry();
|
|
if (fragment != null) {
|
|
str = fragment.mWho + ":";
|
|
} else {
|
|
str = "";
|
|
}
|
|
String str2 = "FragmentManager:" + str;
|
|
this.mStartActivityForResult = activityResultRegistry.register(str2 + "StartActivityForResult", new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() { // from class: androidx.fragment.app.FragmentManager.9
|
|
@Override // androidx.activity.result.ActivityResultCallback
|
|
public void onActivityResult(ActivityResult activityResult) {
|
|
LaunchedFragmentInfo pollFirst = FragmentManager.this.mLaunchedFragments.pollFirst();
|
|
if (pollFirst == null) {
|
|
Log.w(FragmentManager.TAG, "No Activities were started for result for " + this);
|
|
return;
|
|
}
|
|
String str3 = pollFirst.mWho;
|
|
int i = pollFirst.mRequestCode;
|
|
Fragment findFragmentByWho = FragmentManager.this.mFragmentStore.findFragmentByWho(str3);
|
|
if (findFragmentByWho == null) {
|
|
Log.w(FragmentManager.TAG, "Activity result delivered for unknown Fragment " + str3);
|
|
return;
|
|
}
|
|
findFragmentByWho.onActivityResult(i, activityResult.getResultCode(), activityResult.getData());
|
|
}
|
|
});
|
|
this.mStartIntentSenderForResult = activityResultRegistry.register(str2 + "StartIntentSenderForResult", new FragmentIntentSenderContract(), new ActivityResultCallback<ActivityResult>() { // from class: androidx.fragment.app.FragmentManager.10
|
|
@Override // androidx.activity.result.ActivityResultCallback
|
|
public void onActivityResult(ActivityResult activityResult) {
|
|
LaunchedFragmentInfo pollFirst = FragmentManager.this.mLaunchedFragments.pollFirst();
|
|
if (pollFirst == null) {
|
|
Log.w(FragmentManager.TAG, "No IntentSenders were started for " + this);
|
|
return;
|
|
}
|
|
String str3 = pollFirst.mWho;
|
|
int i = pollFirst.mRequestCode;
|
|
Fragment findFragmentByWho = FragmentManager.this.mFragmentStore.findFragmentByWho(str3);
|
|
if (findFragmentByWho == null) {
|
|
Log.w(FragmentManager.TAG, "Intent Sender result delivered for unknown Fragment " + str3);
|
|
return;
|
|
}
|
|
findFragmentByWho.onActivityResult(i, activityResult.getResultCode(), activityResult.getData());
|
|
}
|
|
});
|
|
this.mRequestPermissions = activityResultRegistry.register(str2 + "RequestPermissions", new ActivityResultContracts.RequestMultiplePermissions(), new ActivityResultCallback<Map<String, Boolean>>() { // from class: androidx.fragment.app.FragmentManager.11
|
|
@Override // androidx.activity.result.ActivityResultCallback
|
|
public void onActivityResult(Map<String, Boolean> map) {
|
|
String[] strArr = (String[]) map.keySet().toArray(new String[0]);
|
|
ArrayList arrayList = new ArrayList(map.values());
|
|
int[] iArr = new int[arrayList.size()];
|
|
for (int i = 0; i < arrayList.size(); i++) {
|
|
iArr[i] = ((Boolean) arrayList.get(i)).booleanValue() ? 0 : -1;
|
|
}
|
|
LaunchedFragmentInfo pollFirst = FragmentManager.this.mLaunchedFragments.pollFirst();
|
|
if (pollFirst == null) {
|
|
Log.w(FragmentManager.TAG, "No permissions were requested for " + this);
|
|
return;
|
|
}
|
|
String str3 = pollFirst.mWho;
|
|
int i2 = pollFirst.mRequestCode;
|
|
Fragment findFragmentByWho = FragmentManager.this.mFragmentStore.findFragmentByWho(str3);
|
|
if (findFragmentByWho == null) {
|
|
Log.w(FragmentManager.TAG, "Permission request result delivered for unknown Fragment " + str3);
|
|
return;
|
|
}
|
|
findFragmentByWho.onRequestPermissionsResult(i2, strArr, iArr);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
void noteStateNotSaved() {
|
|
if (this.mHost == null) {
|
|
return;
|
|
}
|
|
this.mStateSaved = false;
|
|
this.mStopped = false;
|
|
this.mNonConfig.setIsStateSaved(false);
|
|
for (Fragment fragment : this.mFragmentStore.getFragments()) {
|
|
if (fragment != null) {
|
|
fragment.noteStateNotSaved();
|
|
}
|
|
}
|
|
}
|
|
|
|
void launchStartActivityForResult(Fragment fragment, Intent intent, int i, Bundle bundle) {
|
|
if (this.mStartActivityForResult != null) {
|
|
this.mLaunchedFragments.addLast(new LaunchedFragmentInfo(fragment.mWho, i));
|
|
if (intent != null && bundle != null) {
|
|
intent.putExtra(ActivityResultContracts.StartActivityForResult.EXTRA_ACTIVITY_OPTIONS_BUNDLE, bundle);
|
|
}
|
|
this.mStartActivityForResult.launch(intent);
|
|
return;
|
|
}
|
|
this.mHost.onStartActivityFromFragment(fragment, intent, i, bundle);
|
|
}
|
|
|
|
void launchStartIntentSenderForResult(Fragment fragment, IntentSender intentSender, int i, Intent intent, int i2, int i3, int i4, Bundle bundle) throws IntentSender.SendIntentException {
|
|
Intent intent2;
|
|
if (this.mStartIntentSenderForResult != null) {
|
|
if (bundle != null) {
|
|
if (intent == null) {
|
|
intent2 = new Intent();
|
|
intent2.putExtra(EXTRA_CREATED_FILLIN_INTENT, true);
|
|
} else {
|
|
intent2 = intent;
|
|
}
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "ActivityOptions " + bundle + " were added to fillInIntent " + intent2 + " for fragment " + fragment);
|
|
}
|
|
intent2.putExtra(ActivityResultContracts.StartActivityForResult.EXTRA_ACTIVITY_OPTIONS_BUNDLE, bundle);
|
|
} else {
|
|
intent2 = intent;
|
|
}
|
|
IntentSenderRequest build = new IntentSenderRequest.Builder(intentSender).setFillInIntent(intent2).setFlags(i3, i2).build();
|
|
this.mLaunchedFragments.addLast(new LaunchedFragmentInfo(fragment.mWho, i));
|
|
if (isLoggingEnabled(2)) {
|
|
Log.v(TAG, "Fragment " + fragment + "is launching an IntentSender for result ");
|
|
}
|
|
this.mStartIntentSenderForResult.launch(build);
|
|
return;
|
|
}
|
|
this.mHost.onStartIntentSenderFromFragment(fragment, intentSender, i, intent, i2, i3, i4, bundle);
|
|
}
|
|
|
|
void launchRequestPermissions(Fragment fragment, String[] strArr, int i) {
|
|
if (this.mRequestPermissions != null) {
|
|
this.mLaunchedFragments.addLast(new LaunchedFragmentInfo(fragment.mWho, i));
|
|
this.mRequestPermissions.launch(strArr);
|
|
return;
|
|
}
|
|
this.mHost.onRequestPermissionsFromFragment(fragment, strArr, i);
|
|
}
|
|
|
|
void dispatchAttach() {
|
|
this.mStateSaved = false;
|
|
this.mStopped = false;
|
|
this.mNonConfig.setIsStateSaved(false);
|
|
dispatchStateChange(0);
|
|
}
|
|
|
|
void dispatchCreate() {
|
|
this.mStateSaved = false;
|
|
this.mStopped = false;
|
|
this.mNonConfig.setIsStateSaved(false);
|
|
dispatchStateChange(1);
|
|
}
|
|
|
|
void dispatchViewCreated() {
|
|
dispatchStateChange(2);
|
|
}
|
|
|
|
void dispatchActivityCreated() {
|
|
this.mStateSaved = false;
|
|
this.mStopped = false;
|
|
this.mNonConfig.setIsStateSaved(false);
|
|
dispatchStateChange(4);
|
|
}
|
|
|
|
void dispatchStart() {
|
|
this.mStateSaved = false;
|
|
this.mStopped = false;
|
|
this.mNonConfig.setIsStateSaved(false);
|
|
dispatchStateChange(5);
|
|
}
|
|
|
|
void dispatchResume() {
|
|
this.mStateSaved = false;
|
|
this.mStopped = false;
|
|
this.mNonConfig.setIsStateSaved(false);
|
|
dispatchStateChange(7);
|
|
}
|
|
|
|
void dispatchPause() {
|
|
dispatchStateChange(5);
|
|
}
|
|
|
|
void dispatchStop() {
|
|
this.mStopped = true;
|
|
this.mNonConfig.setIsStateSaved(true);
|
|
dispatchStateChange(4);
|
|
}
|
|
|
|
void dispatchDestroyView() {
|
|
dispatchStateChange(1);
|
|
}
|
|
|
|
void dispatchDestroy() {
|
|
this.mDestroyed = true;
|
|
execPendingActions(true);
|
|
endAnimatingAwayFragments();
|
|
dispatchStateChange(-1);
|
|
this.mHost = null;
|
|
this.mContainer = null;
|
|
this.mParent = null;
|
|
if (this.mOnBackPressedDispatcher != null) {
|
|
this.mOnBackPressedCallback.remove();
|
|
this.mOnBackPressedDispatcher = null;
|
|
}
|
|
ActivityResultLauncher<Intent> activityResultLauncher = this.mStartActivityForResult;
|
|
if (activityResultLauncher != null) {
|
|
activityResultLauncher.unregister();
|
|
this.mStartIntentSenderForResult.unregister();
|
|
this.mRequestPermissions.unregister();
|
|
}
|
|
}
|
|
|
|
private void dispatchStateChange(int i) {
|
|
try {
|
|
this.mExecutingActions = true;
|
|
this.mFragmentStore.dispatchStateChange(i);
|
|
moveToState(i, false);
|
|
if (USE_STATE_MANAGER) {
|
|
Iterator<SpecialEffectsController> it = collectAllSpecialEffectsController().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().forceCompleteAllOperations();
|
|
}
|
|
}
|
|
this.mExecutingActions = false;
|
|
execPendingActions(true);
|
|
} catch (Throwable th) {
|
|
this.mExecutingActions = false;
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
void dispatchMultiWindowModeChanged(boolean z) {
|
|
for (Fragment fragment : this.mFragmentStore.getFragments()) {
|
|
if (fragment != null) {
|
|
fragment.performMultiWindowModeChanged(z);
|
|
}
|
|
}
|
|
}
|
|
|
|
void dispatchPictureInPictureModeChanged(boolean z) {
|
|
for (Fragment fragment : this.mFragmentStore.getFragments()) {
|
|
if (fragment != null) {
|
|
fragment.performPictureInPictureModeChanged(z);
|
|
}
|
|
}
|
|
}
|
|
|
|
void dispatchConfigurationChanged(Configuration configuration) {
|
|
for (Fragment fragment : this.mFragmentStore.getFragments()) {
|
|
if (fragment != null) {
|
|
fragment.performConfigurationChanged(configuration);
|
|
}
|
|
}
|
|
}
|
|
|
|
void dispatchLowMemory() {
|
|
for (Fragment fragment : this.mFragmentStore.getFragments()) {
|
|
if (fragment != null) {
|
|
fragment.performLowMemory();
|
|
}
|
|
}
|
|
}
|
|
|
|
boolean dispatchCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
|
|
if (this.mCurState < 1) {
|
|
return false;
|
|
}
|
|
ArrayList<Fragment> arrayList = null;
|
|
boolean z = false;
|
|
for (Fragment fragment : this.mFragmentStore.getFragments()) {
|
|
if (fragment != null && isParentMenuVisible(fragment) && fragment.performCreateOptionsMenu(menu, menuInflater)) {
|
|
if (arrayList == null) {
|
|
arrayList = new ArrayList<>();
|
|
}
|
|
arrayList.add(fragment);
|
|
z = true;
|
|
}
|
|
}
|
|
if (this.mCreatedMenus != null) {
|
|
for (int i = 0; i < this.mCreatedMenus.size(); i++) {
|
|
Fragment fragment2 = this.mCreatedMenus.get(i);
|
|
if (arrayList == null || !arrayList.contains(fragment2)) {
|
|
fragment2.onDestroyOptionsMenu();
|
|
}
|
|
}
|
|
}
|
|
this.mCreatedMenus = arrayList;
|
|
return z;
|
|
}
|
|
|
|
boolean dispatchPrepareOptionsMenu(Menu menu) {
|
|
boolean z = false;
|
|
if (this.mCurState < 1) {
|
|
return false;
|
|
}
|
|
for (Fragment fragment : this.mFragmentStore.getFragments()) {
|
|
if (fragment != null && isParentMenuVisible(fragment) && fragment.performPrepareOptionsMenu(menu)) {
|
|
z = true;
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
boolean dispatchOptionsItemSelected(MenuItem menuItem) {
|
|
if (this.mCurState < 1) {
|
|
return false;
|
|
}
|
|
for (Fragment fragment : this.mFragmentStore.getFragments()) {
|
|
if (fragment != null && fragment.performOptionsItemSelected(menuItem)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
boolean dispatchContextItemSelected(MenuItem menuItem) {
|
|
if (this.mCurState < 1) {
|
|
return false;
|
|
}
|
|
for (Fragment fragment : this.mFragmentStore.getFragments()) {
|
|
if (fragment != null && fragment.performContextItemSelected(menuItem)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void dispatchOptionsMenuClosed(Menu menu) {
|
|
if (this.mCurState < 1) {
|
|
return;
|
|
}
|
|
for (Fragment fragment : this.mFragmentStore.getFragments()) {
|
|
if (fragment != null) {
|
|
fragment.performOptionsMenuClosed(menu);
|
|
}
|
|
}
|
|
}
|
|
|
|
void setPrimaryNavigationFragment(Fragment fragment) {
|
|
if (fragment != null && (!fragment.equals(findActiveFragment(fragment.mWho)) || (fragment.mHost != null && fragment.mFragmentManager != this))) {
|
|
throw new IllegalArgumentException("Fragment " + fragment + " is not an active fragment of FragmentManager " + this);
|
|
}
|
|
Fragment fragment2 = this.mPrimaryNav;
|
|
this.mPrimaryNav = fragment;
|
|
dispatchParentPrimaryNavigationFragmentChanged(fragment2);
|
|
dispatchParentPrimaryNavigationFragmentChanged(this.mPrimaryNav);
|
|
}
|
|
|
|
private void dispatchParentPrimaryNavigationFragmentChanged(Fragment fragment) {
|
|
if (fragment == null || !fragment.equals(findActiveFragment(fragment.mWho))) {
|
|
return;
|
|
}
|
|
fragment.performPrimaryNavigationFragmentChanged();
|
|
}
|
|
|
|
void dispatchPrimaryNavigationFragmentChanged() {
|
|
updateOnBackPressedCallbackEnabled();
|
|
dispatchParentPrimaryNavigationFragmentChanged(this.mPrimaryNav);
|
|
}
|
|
|
|
void setMaxLifecycle(Fragment fragment, Lifecycle.State state) {
|
|
if (!fragment.equals(findActiveFragment(fragment.mWho)) || (fragment.mHost != null && fragment.mFragmentManager != this)) {
|
|
throw new IllegalArgumentException("Fragment " + fragment + " is not an active fragment of FragmentManager " + this);
|
|
}
|
|
fragment.mMaxState = state;
|
|
}
|
|
|
|
public FragmentFactory getFragmentFactory() {
|
|
FragmentFactory fragmentFactory = this.mFragmentFactory;
|
|
if (fragmentFactory != null) {
|
|
return fragmentFactory;
|
|
}
|
|
Fragment fragment = this.mParent;
|
|
return fragment != null ? fragment.mFragmentManager.getFragmentFactory() : this.mHostFragmentFactory;
|
|
}
|
|
|
|
SpecialEffectsControllerFactory getSpecialEffectsControllerFactory() {
|
|
SpecialEffectsControllerFactory specialEffectsControllerFactory = this.mSpecialEffectsControllerFactory;
|
|
if (specialEffectsControllerFactory != null) {
|
|
return specialEffectsControllerFactory;
|
|
}
|
|
Fragment fragment = this.mParent;
|
|
return fragment != null ? fragment.mFragmentManager.getSpecialEffectsControllerFactory() : this.mDefaultSpecialEffectsControllerFactory;
|
|
}
|
|
|
|
public void registerFragmentLifecycleCallbacks(FragmentLifecycleCallbacks fragmentLifecycleCallbacks, boolean z) {
|
|
this.mLifecycleCallbacksDispatcher.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, z);
|
|
}
|
|
|
|
public void unregisterFragmentLifecycleCallbacks(FragmentLifecycleCallbacks fragmentLifecycleCallbacks) {
|
|
this.mLifecycleCallbacksDispatcher.unregisterFragmentLifecycleCallbacks(fragmentLifecycleCallbacks);
|
|
}
|
|
|
|
public void addFragmentOnAttachListener(FragmentOnAttachListener fragmentOnAttachListener) {
|
|
this.mOnAttachListeners.add(fragmentOnAttachListener);
|
|
}
|
|
|
|
void dispatchOnAttachFragment(Fragment fragment) {
|
|
Iterator<FragmentOnAttachListener> it = this.mOnAttachListeners.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onAttachFragment(this, fragment);
|
|
}
|
|
}
|
|
|
|
public void removeFragmentOnAttachListener(FragmentOnAttachListener fragmentOnAttachListener) {
|
|
this.mOnAttachListeners.remove(fragmentOnAttachListener);
|
|
}
|
|
|
|
boolean checkForMenus() {
|
|
boolean z = false;
|
|
for (Fragment fragment : this.mFragmentStore.getActiveFragments()) {
|
|
if (fragment != null) {
|
|
z = isMenuAvailable(fragment);
|
|
}
|
|
if (z) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private boolean isMenuAvailable(Fragment fragment) {
|
|
return (fragment.mHasMenu && fragment.mMenuVisible) || fragment.mChildFragmentManager.checkForMenus();
|
|
}
|
|
|
|
void invalidateMenuForFragment(Fragment fragment) {
|
|
if (fragment.mAdded && isMenuAvailable(fragment)) {
|
|
this.mNeedMenuInvalidate = true;
|
|
}
|
|
}
|
|
|
|
private class PopBackStackState implements OpGenerator {
|
|
final int mFlags;
|
|
final int mId;
|
|
final String mName;
|
|
|
|
PopBackStackState(String str, int i, int i2) {
|
|
this.mName = str;
|
|
this.mId = i;
|
|
this.mFlags = i2;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager.OpGenerator
|
|
public boolean generateOps(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2) {
|
|
if (FragmentManager.this.mPrimaryNav == null || this.mId >= 0 || this.mName != null || !FragmentManager.this.mPrimaryNav.getChildFragmentManager().popBackStackImmediate()) {
|
|
return FragmentManager.this.popBackStackState(arrayList, arrayList2, this.mName, this.mId, this.mFlags);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
static class StartEnterTransitionListener implements Fragment.OnStartEnterTransitionListener {
|
|
final boolean mIsBack;
|
|
private int mNumPostponed;
|
|
final BackStackRecord mRecord;
|
|
|
|
public boolean isReady() {
|
|
return this.mNumPostponed == 0;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment.OnStartEnterTransitionListener
|
|
public void startListening() {
|
|
this.mNumPostponed++;
|
|
}
|
|
|
|
StartEnterTransitionListener(BackStackRecord backStackRecord, boolean z) {
|
|
this.mIsBack = z;
|
|
this.mRecord = backStackRecord;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment.OnStartEnterTransitionListener
|
|
public void onStartEnterTransition() {
|
|
int i = this.mNumPostponed - 1;
|
|
this.mNumPostponed = i;
|
|
if (i != 0) {
|
|
return;
|
|
}
|
|
this.mRecord.mManager.scheduleCommit();
|
|
}
|
|
|
|
void completeTransaction() {
|
|
boolean z = this.mNumPostponed > 0;
|
|
for (Fragment fragment : this.mRecord.mManager.getFragments()) {
|
|
fragment.setOnStartEnterTransitionListener(null);
|
|
if (z && fragment.isPostponed()) {
|
|
fragment.startPostponedEnterTransition();
|
|
}
|
|
}
|
|
this.mRecord.mManager.completeExecute(this.mRecord, this.mIsBack, !z, true);
|
|
}
|
|
|
|
void cancelTransaction() {
|
|
this.mRecord.mManager.completeExecute(this.mRecord, this.mIsBack, false, false);
|
|
}
|
|
}
|
|
|
|
static class LaunchedFragmentInfo implements Parcelable {
|
|
public static final Parcelable.Creator<LaunchedFragmentInfo> CREATOR = new Parcelable.Creator<LaunchedFragmentInfo>() { // from class: androidx.fragment.app.FragmentManager.LaunchedFragmentInfo.1
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public LaunchedFragmentInfo createFromParcel(Parcel parcel) {
|
|
return new LaunchedFragmentInfo(parcel);
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public LaunchedFragmentInfo[] newArray(int i) {
|
|
return new LaunchedFragmentInfo[i];
|
|
}
|
|
};
|
|
int mRequestCode;
|
|
String mWho;
|
|
|
|
@Override // android.os.Parcelable
|
|
public int describeContents() {
|
|
return 0;
|
|
}
|
|
|
|
LaunchedFragmentInfo(String str, int i) {
|
|
this.mWho = str;
|
|
this.mRequestCode = i;
|
|
}
|
|
|
|
LaunchedFragmentInfo(Parcel parcel) {
|
|
this.mWho = parcel.readString();
|
|
this.mRequestCode = parcel.readInt();
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
parcel.writeString(this.mWho);
|
|
parcel.writeInt(this.mRequestCode);
|
|
}
|
|
}
|
|
|
|
static class FragmentIntentSenderContract extends ActivityResultContract<IntentSenderRequest, ActivityResult> {
|
|
FragmentIntentSenderContract() {
|
|
}
|
|
|
|
@Override // androidx.activity.result.contract.ActivityResultContract
|
|
public Intent createIntent(Context context, IntentSenderRequest intentSenderRequest) {
|
|
Bundle bundleExtra;
|
|
Intent intent = new Intent(ActivityResultContracts.StartIntentSenderForResult.ACTION_INTENT_SENDER_REQUEST);
|
|
Intent fillInIntent = intentSenderRequest.getFillInIntent();
|
|
if (fillInIntent != null && (bundleExtra = fillInIntent.getBundleExtra(ActivityResultContracts.StartActivityForResult.EXTRA_ACTIVITY_OPTIONS_BUNDLE)) != null) {
|
|
intent.putExtra(ActivityResultContracts.StartActivityForResult.EXTRA_ACTIVITY_OPTIONS_BUNDLE, bundleExtra);
|
|
fillInIntent.removeExtra(ActivityResultContracts.StartActivityForResult.EXTRA_ACTIVITY_OPTIONS_BUNDLE);
|
|
if (fillInIntent.getBooleanExtra(FragmentManager.EXTRA_CREATED_FILLIN_INTENT, false)) {
|
|
intentSenderRequest = new IntentSenderRequest.Builder(intentSenderRequest.getIntentSender()).setFillInIntent(null).setFlags(intentSenderRequest.getFlagsValues(), intentSenderRequest.getFlagsMask()).build();
|
|
}
|
|
}
|
|
intent.putExtra(ActivityResultContracts.StartIntentSenderForResult.EXTRA_INTENT_SENDER_REQUEST, intentSenderRequest);
|
|
if (FragmentManager.isLoggingEnabled(2)) {
|
|
Log.v(FragmentManager.TAG, "CreateIntent created the following intent: " + intent);
|
|
}
|
|
return intent;
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // androidx.activity.result.contract.ActivityResultContract
|
|
public ActivityResult parseResult(int i, Intent intent) {
|
|
return new ActivityResult(i, intent);
|
|
}
|
|
}
|
|
}
|