2736 lines
98 KiB
Java
2736 lines
98 KiB
Java
package androidx.fragment.app;
|
|
|
|
import android.R;
|
|
import android.animation.Animator;
|
|
import android.animation.AnimatorInflater;
|
|
import android.animation.AnimatorListenerAdapter;
|
|
import android.animation.AnimatorSet;
|
|
import android.animation.PropertyValuesHolder;
|
|
import android.animation.ValueAnimator;
|
|
import android.content.Context;
|
|
import android.content.res.Configuration;
|
|
import android.content.res.Resources;
|
|
import android.content.res.TypedArray;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.Looper;
|
|
import android.os.Parcelable;
|
|
import android.util.AttributeSet;
|
|
import android.util.Log;
|
|
import android.util.SparseArray;
|
|
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 android.view.animation.AccelerateInterpolator;
|
|
import android.view.animation.AlphaAnimation;
|
|
import android.view.animation.Animation;
|
|
import android.view.animation.AnimationSet;
|
|
import android.view.animation.AnimationUtils;
|
|
import android.view.animation.DecelerateInterpolator;
|
|
import android.view.animation.Interpolator;
|
|
import android.view.animation.ScaleAnimation;
|
|
import android.view.animation.Transformation;
|
|
import androidx.collection.ArraySet;
|
|
import androidx.core.util.DebugUtils;
|
|
import androidx.core.util.LogWriter;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.lifecycle.ViewModelStore;
|
|
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
|
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
|
import java.io.FileDescriptor;
|
|
import java.io.PrintWriter;
|
|
import java.lang.reflect.Field;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
|
/* compiled from: FragmentManager.java */
|
|
/* loaded from: classes.dex */
|
|
final class FragmentManagerImpl extends FragmentManager implements LayoutInflater.Factory2 {
|
|
static boolean F = false;
|
|
static Field G;
|
|
static final Interpolator H = new DecelerateInterpolator(2.5f);
|
|
static final Interpolator I = new DecelerateInterpolator(1.5f);
|
|
ArrayList<StartEnterTransitionListener> C;
|
|
FragmentManagerNonConfig D;
|
|
ArrayList<OpGenerator> a;
|
|
boolean b;
|
|
SparseArray<Fragment> e;
|
|
ArrayList<BackStackRecord> f;
|
|
ArrayList<Fragment> g;
|
|
ArrayList<BackStackRecord> h;
|
|
ArrayList<Integer> i;
|
|
ArrayList<FragmentManager.OnBackStackChangedListener> j;
|
|
FragmentHostCallback m;
|
|
FragmentContainer n;
|
|
Fragment o;
|
|
Fragment p;
|
|
boolean q;
|
|
boolean r;
|
|
boolean s;
|
|
boolean t;
|
|
String u;
|
|
boolean v;
|
|
ArrayList<BackStackRecord> x;
|
|
ArrayList<Boolean> y;
|
|
ArrayList<Fragment> z;
|
|
int c = 0;
|
|
final ArrayList<Fragment> d = new ArrayList<>();
|
|
private final CopyOnWriteArrayList<FragmentLifecycleCallbacksHolder> k = new CopyOnWriteArrayList<>();
|
|
int l = 0;
|
|
Bundle A = null;
|
|
SparseArray<Parcelable> B = null;
|
|
Runnable E = new Runnable() { // from class: androidx.fragment.app.FragmentManagerImpl.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
FragmentManagerImpl.this.p();
|
|
}
|
|
};
|
|
|
|
/* compiled from: FragmentManager.java */
|
|
private static class AnimateOnHWLayerIfNeededListener extends AnimationListenerWrapper {
|
|
View b;
|
|
|
|
AnimateOnHWLayerIfNeededListener(View view, Animation.AnimationListener animationListener) {
|
|
super(animationListener);
|
|
this.b = view;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManagerImpl.AnimationListenerWrapper, android.view.animation.Animation.AnimationListener
|
|
public void onAnimationEnd(Animation animation) {
|
|
if (ViewCompat.w(this.b) || Build.VERSION.SDK_INT >= 24) {
|
|
this.b.post(new Runnable() { // from class: androidx.fragment.app.FragmentManagerImpl.AnimateOnHWLayerIfNeededListener.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
AnimateOnHWLayerIfNeededListener.this.b.setLayerType(0, null);
|
|
}
|
|
});
|
|
} else {
|
|
this.b.setLayerType(0, null);
|
|
}
|
|
super.onAnimationEnd(animation);
|
|
}
|
|
}
|
|
|
|
/* compiled from: FragmentManager.java */
|
|
private static class AnimationListenerWrapper implements Animation.AnimationListener {
|
|
private final Animation.AnimationListener a;
|
|
|
|
AnimationListenerWrapper(Animation.AnimationListener animationListener) {
|
|
this.a = animationListener;
|
|
}
|
|
|
|
@Override // android.view.animation.Animation.AnimationListener
|
|
public void onAnimationEnd(Animation animation) {
|
|
Animation.AnimationListener animationListener = this.a;
|
|
if (animationListener != null) {
|
|
animationListener.onAnimationEnd(animation);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.animation.Animation.AnimationListener
|
|
public void onAnimationRepeat(Animation animation) {
|
|
Animation.AnimationListener animationListener = this.a;
|
|
if (animationListener != null) {
|
|
animationListener.onAnimationRepeat(animation);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.animation.Animation.AnimationListener
|
|
public void onAnimationStart(Animation animation) {
|
|
Animation.AnimationListener animationListener = this.a;
|
|
if (animationListener != null) {
|
|
animationListener.onAnimationStart(animation);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: FragmentManager.java */
|
|
private static class AnimatorOnHWLayerIfNeededListener extends AnimatorListenerAdapter {
|
|
View a;
|
|
|
|
AnimatorOnHWLayerIfNeededListener(View view) {
|
|
this.a = view;
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationEnd(Animator animator) {
|
|
this.a.setLayerType(0, null);
|
|
animator.removeListener(this);
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationStart(Animator animator) {
|
|
this.a.setLayerType(2, null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: FragmentManager.java */
|
|
private static final class FragmentLifecycleCallbacksHolder {
|
|
final FragmentManager.FragmentLifecycleCallbacks a;
|
|
final boolean b;
|
|
}
|
|
|
|
/* compiled from: FragmentManager.java */
|
|
static class FragmentTag {
|
|
public static final int[] a = {R.attr.name, R.attr.id, R.attr.tag};
|
|
}
|
|
|
|
/* compiled from: FragmentManager.java */
|
|
interface OpGenerator {
|
|
boolean a(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2);
|
|
}
|
|
|
|
/* compiled from: FragmentManager.java */
|
|
private class PopBackStackState implements OpGenerator {
|
|
final String a;
|
|
final int b;
|
|
final int c;
|
|
|
|
PopBackStackState(String str, int i, int i2) {
|
|
this.a = str;
|
|
this.b = i;
|
|
this.c = i2;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManagerImpl.OpGenerator
|
|
public boolean a(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2) {
|
|
FragmentManager peekChildFragmentManager;
|
|
Fragment fragment = FragmentManagerImpl.this.p;
|
|
if (fragment == null || this.b >= 0 || this.a != null || (peekChildFragmentManager = fragment.peekChildFragmentManager()) == null || !peekChildFragmentManager.e()) {
|
|
return FragmentManagerImpl.this.a(arrayList, arrayList2, this.a, this.b, this.c);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/* compiled from: FragmentManager.java */
|
|
static class StartEnterTransitionListener implements Fragment.OnStartEnterTransitionListener {
|
|
final boolean a;
|
|
final BackStackRecord b;
|
|
private int c;
|
|
|
|
StartEnterTransitionListener(BackStackRecord backStackRecord, boolean z) {
|
|
this.a = z;
|
|
this.b = backStackRecord;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment.OnStartEnterTransitionListener
|
|
public void a() {
|
|
this.c++;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment.OnStartEnterTransitionListener
|
|
public void b() {
|
|
this.c--;
|
|
if (this.c != 0) {
|
|
return;
|
|
}
|
|
this.b.a.x();
|
|
}
|
|
|
|
public void c() {
|
|
BackStackRecord backStackRecord = this.b;
|
|
backStackRecord.a.a(backStackRecord, this.a, false, false);
|
|
}
|
|
|
|
public void d() {
|
|
boolean z = this.c > 0;
|
|
FragmentManagerImpl fragmentManagerImpl = this.b.a;
|
|
int size = fragmentManagerImpl.d.size();
|
|
for (int i = 0; i < size; i++) {
|
|
Fragment fragment = fragmentManagerImpl.d.get(i);
|
|
fragment.setOnStartEnterTransitionListener(null);
|
|
if (z && fragment.isPostponed()) {
|
|
fragment.startPostponedEnterTransition();
|
|
}
|
|
}
|
|
BackStackRecord backStackRecord = this.b;
|
|
backStackRecord.a.a(backStackRecord, this.a, !z, true);
|
|
}
|
|
|
|
public boolean e() {
|
|
return this.c == 0;
|
|
}
|
|
}
|
|
|
|
static {
|
|
new AccelerateInterpolator(2.5f);
|
|
new AccelerateInterpolator(1.5f);
|
|
}
|
|
|
|
FragmentManagerImpl() {
|
|
}
|
|
|
|
private void A() {
|
|
if (c()) {
|
|
throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
|
|
}
|
|
if (this.u == null) {
|
|
return;
|
|
}
|
|
throw new IllegalStateException("Can not perform this action inside of " + this.u);
|
|
}
|
|
|
|
private void B() {
|
|
this.b = false;
|
|
this.y.clear();
|
|
this.x.clear();
|
|
}
|
|
|
|
private void C() {
|
|
SparseArray<Fragment> sparseArray = this.e;
|
|
int size = sparseArray == null ? 0 : sparseArray.size();
|
|
for (int i = 0; i < size; i++) {
|
|
Fragment valueAt = this.e.valueAt(i);
|
|
if (valueAt != null) {
|
|
if (valueAt.getAnimatingAway() != null) {
|
|
int stateAfterAnimating = valueAt.getStateAfterAnimating();
|
|
View animatingAway = valueAt.getAnimatingAway();
|
|
Animation animation = animatingAway.getAnimation();
|
|
if (animation != null) {
|
|
animation.cancel();
|
|
animatingAway.clearAnimation();
|
|
}
|
|
valueAt.setAnimatingAway(null);
|
|
a(valueAt, stateAfterAnimating, 0, 0, false);
|
|
} else if (valueAt.getAnimator() != null) {
|
|
valueAt.getAnimator().end();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void D() {
|
|
if (this.C != null) {
|
|
while (!this.C.isEmpty()) {
|
|
this.C.remove(0).d();
|
|
}
|
|
}
|
|
}
|
|
|
|
static boolean a(AnimationOrAnimator animationOrAnimator) {
|
|
Animation animation = animationOrAnimator.a;
|
|
if (animation instanceof AlphaAnimation) {
|
|
return true;
|
|
}
|
|
if (!(animation instanceof AnimationSet)) {
|
|
return a(animationOrAnimator.b);
|
|
}
|
|
List<Animation> animations = ((AnimationSet) animation).getAnimations();
|
|
for (int i = 0; i < animations.size(); i++) {
|
|
if (animations.get(i) instanceof AlphaAnimation) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static int b(int i, boolean z) {
|
|
if (i == 4097) {
|
|
return z ? 1 : 2;
|
|
}
|
|
if (i == 4099) {
|
|
return z ? 5 : 6;
|
|
}
|
|
if (i != 8194) {
|
|
return -1;
|
|
}
|
|
return z ? 3 : 4;
|
|
}
|
|
|
|
static boolean b(View view, AnimationOrAnimator animationOrAnimator) {
|
|
return view != null && animationOrAnimator != null && Build.VERSION.SDK_INT >= 19 && view.getLayerType() == 0 && ViewCompat.u(view) && a(animationOrAnimator);
|
|
}
|
|
|
|
public static int e(int i) {
|
|
if (i == 4097) {
|
|
return UnityActivity.BLOCKLY_TYPE_COURSE;
|
|
}
|
|
if (i != 4099) {
|
|
return i != 8194 ? 0 : 4097;
|
|
}
|
|
return 4099;
|
|
}
|
|
|
|
private Fragment q(Fragment fragment) {
|
|
ViewGroup viewGroup = fragment.mContainer;
|
|
View view = fragment.mView;
|
|
if (viewGroup != null && view != null) {
|
|
for (int indexOf = this.d.indexOf(fragment) - 1; indexOf >= 0; indexOf--) {
|
|
Fragment fragment2 = this.d.get(indexOf);
|
|
if (fragment2.mContainer == viewGroup && fragment2.mView != null) {
|
|
return fragment2;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void z() {
|
|
SparseArray<Fragment> sparseArray = this.e;
|
|
if (sparseArray != null) {
|
|
for (int size = sparseArray.size() - 1; size >= 0; size--) {
|
|
if (this.e.valueAt(size) == null) {
|
|
SparseArray<Fragment> sparseArray2 = this.e;
|
|
sparseArray2.delete(sparseArray2.keyAt(size));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
boolean c(int i) {
|
|
return this.l >= i;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager
|
|
public void d() {
|
|
a((OpGenerator) new PopBackStackState(null, -1, 0), false);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager
|
|
public boolean e() {
|
|
A();
|
|
return a((String) null, -1, 0);
|
|
}
|
|
|
|
public void f(Fragment fragment) {
|
|
if (F) {
|
|
Log.v("FragmentManager", "hide: " + fragment);
|
|
}
|
|
if (fragment.mHidden) {
|
|
return;
|
|
}
|
|
fragment.mHidden = true;
|
|
fragment.mHiddenChanged = true ^ fragment.mHiddenChanged;
|
|
}
|
|
|
|
void g(Fragment fragment) {
|
|
if (fragment.mIndex >= 0) {
|
|
return;
|
|
}
|
|
int i = this.c;
|
|
this.c = i + 1;
|
|
fragment.setIndex(i, this.o);
|
|
if (this.e == null) {
|
|
this.e = new SparseArray<>();
|
|
}
|
|
this.e.put(fragment.mIndex, fragment);
|
|
if (F) {
|
|
Log.v("FragmentManager", "Allocated fragment index " + fragment);
|
|
}
|
|
}
|
|
|
|
void h(Fragment fragment) {
|
|
if (fragment.mIndex < 0) {
|
|
return;
|
|
}
|
|
if (F) {
|
|
Log.v("FragmentManager", "Freeing fragment index " + fragment);
|
|
}
|
|
this.e.put(fragment.mIndex, null);
|
|
fragment.initState();
|
|
}
|
|
|
|
void i(Fragment fragment) {
|
|
if (fragment == null) {
|
|
return;
|
|
}
|
|
int i = this.l;
|
|
if (fragment.mRemoving) {
|
|
i = fragment.isInBackStack() ? Math.min(i, 1) : Math.min(i, 0);
|
|
}
|
|
a(fragment, i, fragment.getNextTransition(), fragment.getNextTransitionStyle(), false);
|
|
if (fragment.mView != null) {
|
|
Fragment q = q(fragment);
|
|
if (q != null) {
|
|
View view = q.mView;
|
|
ViewGroup viewGroup = fragment.mContainer;
|
|
int indexOfChild = viewGroup.indexOfChild(view);
|
|
int indexOfChild2 = viewGroup.indexOfChild(fragment.mView);
|
|
if (indexOfChild2 < indexOfChild) {
|
|
viewGroup.removeViewAt(indexOfChild2);
|
|
viewGroup.addView(fragment.mView, indexOfChild);
|
|
}
|
|
}
|
|
if (fragment.mIsNewlyAdded && fragment.mContainer != null) {
|
|
float f = fragment.mPostponedAlpha;
|
|
if (f > 0.0f) {
|
|
fragment.mView.setAlpha(f);
|
|
}
|
|
fragment.mPostponedAlpha = 0.0f;
|
|
fragment.mIsNewlyAdded = false;
|
|
AnimationOrAnimator a = a(fragment, fragment.getNextTransition(), true, fragment.getNextTransitionStyle());
|
|
if (a != null) {
|
|
a(fragment.mView, a);
|
|
Animation animation = a.a;
|
|
if (animation != null) {
|
|
fragment.mView.startAnimation(animation);
|
|
} else {
|
|
a.b.setTarget(fragment.mView);
|
|
a.b.start();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (fragment.mHiddenChanged) {
|
|
c(fragment);
|
|
}
|
|
}
|
|
|
|
void j(Fragment fragment) {
|
|
a(fragment, this.l, 0, 0, false);
|
|
}
|
|
|
|
public void k(Fragment fragment) {
|
|
if (fragment.mDeferStart) {
|
|
if (this.b) {
|
|
this.v = true;
|
|
} else {
|
|
fragment.mDeferStart = false;
|
|
a(fragment, this.l, 0, 0, false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void l(Fragment fragment) {
|
|
if (F) {
|
|
Log.v("FragmentManager", "remove: " + fragment + " nesting=" + fragment.mBackStackNesting);
|
|
}
|
|
boolean z = !fragment.isInBackStack();
|
|
if (!fragment.mDetached || z) {
|
|
synchronized (this.d) {
|
|
this.d.remove(fragment);
|
|
}
|
|
if (fragment.mHasMenu && fragment.mMenuVisible) {
|
|
this.q = true;
|
|
}
|
|
fragment.mAdded = false;
|
|
fragment.mRemoving = true;
|
|
}
|
|
}
|
|
|
|
Bundle m(Fragment fragment) {
|
|
Bundle bundle;
|
|
if (this.A == null) {
|
|
this.A = new Bundle();
|
|
}
|
|
fragment.performSaveInstanceState(this.A);
|
|
d(fragment, this.A, false);
|
|
if (this.A.isEmpty()) {
|
|
bundle = null;
|
|
} else {
|
|
bundle = this.A;
|
|
this.A = null;
|
|
}
|
|
if (fragment.mView != null) {
|
|
n(fragment);
|
|
}
|
|
if (fragment.mSavedViewState != null) {
|
|
if (bundle == null) {
|
|
bundle = new Bundle();
|
|
}
|
|
bundle.putSparseParcelableArray("android:view_state", fragment.mSavedViewState);
|
|
}
|
|
if (!fragment.mUserVisibleHint) {
|
|
if (bundle == null) {
|
|
bundle = new Bundle();
|
|
}
|
|
bundle.putBoolean("android:user_visible_hint", fragment.mUserVisibleHint);
|
|
}
|
|
return bundle;
|
|
}
|
|
|
|
void n(Fragment fragment) {
|
|
if (fragment.mInnerView == null) {
|
|
return;
|
|
}
|
|
SparseArray<Parcelable> sparseArray = this.B;
|
|
if (sparseArray == null) {
|
|
this.B = new SparseArray<>();
|
|
} else {
|
|
sparseArray.clear();
|
|
}
|
|
fragment.mInnerView.saveHierarchyState(this.B);
|
|
if (this.B.size() > 0) {
|
|
fragment.mSavedViewState = this.B;
|
|
this.B = null;
|
|
}
|
|
}
|
|
|
|
void o() {
|
|
if (this.v) {
|
|
this.v = false;
|
|
y();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.LayoutInflater.Factory2
|
|
public View onCreateView(View view, String str, Context context, AttributeSet attributeSet) {
|
|
Fragment fragment;
|
|
if (!"fragment".equals(str)) {
|
|
return null;
|
|
}
|
|
String attributeValue = attributeSet.getAttributeValue(null, "class");
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, FragmentTag.a);
|
|
if (attributeValue == null) {
|
|
attributeValue = obtainStyledAttributes.getString(0);
|
|
}
|
|
String str2 = attributeValue;
|
|
int resourceId = obtainStyledAttributes.getResourceId(1, -1);
|
|
String string = obtainStyledAttributes.getString(2);
|
|
obtainStyledAttributes.recycle();
|
|
if (!Fragment.isSupportFragmentClass(this.m.c(), str2)) {
|
|
return null;
|
|
}
|
|
int id = view != null ? view.getId() : 0;
|
|
if (id == -1 && resourceId == -1 && string == null) {
|
|
throw new IllegalArgumentException(attributeSet.getPositionDescription() + ": Must specify unique android:id, android:tag, or have a parent with an id for " + str2);
|
|
}
|
|
Fragment a = resourceId != -1 ? a(resourceId) : null;
|
|
if (a == null && string != null) {
|
|
a = a(string);
|
|
}
|
|
if (a == null && id != -1) {
|
|
a = a(id);
|
|
}
|
|
if (F) {
|
|
Log.v("FragmentManager", "onCreateView: id=0x" + Integer.toHexString(resourceId) + " fname=" + str2 + " existing=" + a);
|
|
}
|
|
if (a == null) {
|
|
Fragment a2 = this.n.a(context, str2, null);
|
|
a2.mFromLayout = true;
|
|
a2.mFragmentId = resourceId != 0 ? resourceId : id;
|
|
a2.mContainerId = id;
|
|
a2.mTag = string;
|
|
a2.mInLayout = true;
|
|
a2.mFragmentManager = this;
|
|
FragmentHostCallback fragmentHostCallback = this.m;
|
|
a2.mHost = fragmentHostCallback;
|
|
a2.onInflate(fragmentHostCallback.c(), attributeSet, a2.mSavedFragmentState);
|
|
a(a2, true);
|
|
fragment = a2;
|
|
} else {
|
|
if (a.mInLayout) {
|
|
throw new IllegalArgumentException(attributeSet.getPositionDescription() + ": Duplicate id 0x" + Integer.toHexString(resourceId) + ", tag " + string + ", or parent id 0x" + Integer.toHexString(id) + " with another fragment for " + str2);
|
|
}
|
|
a.mInLayout = true;
|
|
FragmentHostCallback fragmentHostCallback2 = this.m;
|
|
a.mHost = fragmentHostCallback2;
|
|
if (!a.mRetaining) {
|
|
a.onInflate(fragmentHostCallback2.c(), attributeSet, a.mSavedFragmentState);
|
|
}
|
|
fragment = a;
|
|
}
|
|
if (this.l >= 1 || !fragment.mFromLayout) {
|
|
j(fragment);
|
|
} else {
|
|
a(fragment, 1, 0, 0, false);
|
|
}
|
|
View view2 = fragment.mView;
|
|
if (view2 != null) {
|
|
if (resourceId != 0) {
|
|
view2.setId(resourceId);
|
|
}
|
|
if (fragment.mView.getTag() == null) {
|
|
fragment.mView.setTag(string);
|
|
}
|
|
return fragment.mView;
|
|
}
|
|
throw new IllegalStateException("Fragment " + str2 + " did not create a view.");
|
|
}
|
|
|
|
public void p(Fragment fragment) {
|
|
if (F) {
|
|
Log.v("FragmentManager", "show: " + fragment);
|
|
}
|
|
if (fragment.mHidden) {
|
|
fragment.mHidden = false;
|
|
fragment.mHiddenChanged = !fragment.mHiddenChanged;
|
|
}
|
|
}
|
|
|
|
LayoutInflater.Factory2 q() {
|
|
return this;
|
|
}
|
|
|
|
public Fragment r() {
|
|
return this.p;
|
|
}
|
|
|
|
public void s() {
|
|
this.D = null;
|
|
this.r = false;
|
|
this.s = false;
|
|
int size = this.d.size();
|
|
for (int i = 0; i < size; i++) {
|
|
Fragment fragment = this.d.get(i);
|
|
if (fragment != null) {
|
|
fragment.noteStateNotSaved();
|
|
}
|
|
}
|
|
}
|
|
|
|
void t() {
|
|
if (this.j != null) {
|
|
for (int i = 0; i < this.j.size(); i++) {
|
|
this.j.get(i).a();
|
|
}
|
|
}
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder(PeripheralType.SERVO);
|
|
sb.append("FragmentManager{");
|
|
sb.append(Integer.toHexString(System.identityHashCode(this)));
|
|
sb.append(" in ");
|
|
Fragment fragment = this.o;
|
|
if (fragment != null) {
|
|
DebugUtils.a(fragment, sb);
|
|
} else {
|
|
DebugUtils.a(this.m, sb);
|
|
}
|
|
sb.append("}}");
|
|
return sb.toString();
|
|
}
|
|
|
|
FragmentManagerNonConfig u() {
|
|
a(this.D);
|
|
return this.D;
|
|
}
|
|
|
|
Parcelable v() {
|
|
int[] iArr;
|
|
int size;
|
|
D();
|
|
C();
|
|
p();
|
|
this.r = true;
|
|
BackStackState[] backStackStateArr = null;
|
|
this.D = null;
|
|
SparseArray<Fragment> sparseArray = this.e;
|
|
if (sparseArray == null || sparseArray.size() <= 0) {
|
|
return null;
|
|
}
|
|
int size2 = this.e.size();
|
|
FragmentState[] fragmentStateArr = new FragmentState[size2];
|
|
boolean z = false;
|
|
for (int i = 0; i < size2; i++) {
|
|
Fragment valueAt = this.e.valueAt(i);
|
|
if (valueAt != null) {
|
|
if (valueAt.mIndex < 0) {
|
|
a(new IllegalStateException("Failure saving state: active " + valueAt + " has cleared index: " + valueAt.mIndex));
|
|
throw null;
|
|
}
|
|
FragmentState fragmentState = new FragmentState(valueAt);
|
|
fragmentStateArr[i] = fragmentState;
|
|
if (valueAt.mState <= 0 || fragmentState.mSavedFragmentState != null) {
|
|
fragmentState.mSavedFragmentState = valueAt.mSavedFragmentState;
|
|
} else {
|
|
fragmentState.mSavedFragmentState = m(valueAt);
|
|
Fragment fragment = valueAt.mTarget;
|
|
if (fragment != null) {
|
|
if (fragment.mIndex < 0) {
|
|
a(new IllegalStateException("Failure saving state: " + valueAt + " has target not in fragment manager: " + valueAt.mTarget));
|
|
throw null;
|
|
}
|
|
if (fragmentState.mSavedFragmentState == null) {
|
|
fragmentState.mSavedFragmentState = new Bundle();
|
|
}
|
|
a(fragmentState.mSavedFragmentState, "android:target_state", valueAt.mTarget);
|
|
int i2 = valueAt.mTargetRequestCode;
|
|
if (i2 != 0) {
|
|
fragmentState.mSavedFragmentState.putInt("android:target_req_state", i2);
|
|
}
|
|
}
|
|
}
|
|
if (F) {
|
|
Log.v("FragmentManager", "Saved state of " + valueAt + ": " + fragmentState.mSavedFragmentState);
|
|
}
|
|
z = true;
|
|
}
|
|
}
|
|
if (!z) {
|
|
if (F) {
|
|
Log.v("FragmentManager", "saveAllState: no fragments!");
|
|
}
|
|
return null;
|
|
}
|
|
int size3 = this.d.size();
|
|
if (size3 > 0) {
|
|
iArr = new int[size3];
|
|
for (int i3 = 0; i3 < size3; i3++) {
|
|
iArr[i3] = this.d.get(i3).mIndex;
|
|
if (iArr[i3] < 0) {
|
|
a(new IllegalStateException("Failure saving state: active " + this.d.get(i3) + " has cleared index: " + iArr[i3]));
|
|
throw null;
|
|
}
|
|
if (F) {
|
|
Log.v("FragmentManager", "saveAllState: adding fragment #" + i3 + ": " + this.d.get(i3));
|
|
}
|
|
}
|
|
} else {
|
|
iArr = null;
|
|
}
|
|
ArrayList<BackStackRecord> arrayList = this.f;
|
|
if (arrayList != null && (size = arrayList.size()) > 0) {
|
|
backStackStateArr = new BackStackState[size];
|
|
for (int i4 = 0; i4 < size; i4++) {
|
|
backStackStateArr[i4] = new BackStackState(this.f.get(i4));
|
|
if (F) {
|
|
Log.v("FragmentManager", "saveAllState: adding back stack #" + i4 + ": " + this.f.get(i4));
|
|
}
|
|
}
|
|
}
|
|
FragmentManagerState fragmentManagerState = new FragmentManagerState();
|
|
fragmentManagerState.mActive = fragmentStateArr;
|
|
fragmentManagerState.mAdded = iArr;
|
|
fragmentManagerState.mBackStack = backStackStateArr;
|
|
Fragment fragment2 = this.p;
|
|
if (fragment2 != null) {
|
|
fragmentManagerState.mPrimaryNavActiveIndex = fragment2.mIndex;
|
|
}
|
|
fragmentManagerState.mNextFragmentIndex = this.c;
|
|
w();
|
|
return fragmentManagerState;
|
|
}
|
|
|
|
void w() {
|
|
ArrayList arrayList;
|
|
ArrayList arrayList2;
|
|
ArrayList arrayList3;
|
|
FragmentManagerNonConfig fragmentManagerNonConfig;
|
|
if (this.e != null) {
|
|
arrayList = null;
|
|
arrayList2 = null;
|
|
arrayList3 = null;
|
|
for (int i = 0; i < this.e.size(); i++) {
|
|
Fragment valueAt = this.e.valueAt(i);
|
|
if (valueAt != null) {
|
|
if (valueAt.mRetainInstance) {
|
|
if (arrayList == null) {
|
|
arrayList = new ArrayList();
|
|
}
|
|
arrayList.add(valueAt);
|
|
Fragment fragment = valueAt.mTarget;
|
|
valueAt.mTargetIndex = fragment != null ? fragment.mIndex : -1;
|
|
if (F) {
|
|
Log.v("FragmentManager", "retainNonConfig: keeping retained " + valueAt);
|
|
}
|
|
}
|
|
FragmentManagerImpl fragmentManagerImpl = valueAt.mChildFragmentManager;
|
|
if (fragmentManagerImpl != null) {
|
|
fragmentManagerImpl.w();
|
|
fragmentManagerNonConfig = valueAt.mChildFragmentManager.D;
|
|
} else {
|
|
fragmentManagerNonConfig = valueAt.mChildNonConfig;
|
|
}
|
|
if (arrayList2 == null && fragmentManagerNonConfig != null) {
|
|
arrayList2 = new ArrayList(this.e.size());
|
|
for (int i2 = 0; i2 < i; i2++) {
|
|
arrayList2.add(null);
|
|
}
|
|
}
|
|
if (arrayList2 != null) {
|
|
arrayList2.add(fragmentManagerNonConfig);
|
|
}
|
|
if (arrayList3 == null && valueAt.mViewModelStore != null) {
|
|
arrayList3 = new ArrayList(this.e.size());
|
|
for (int i3 = 0; i3 < i; i3++) {
|
|
arrayList3.add(null);
|
|
}
|
|
}
|
|
if (arrayList3 != null) {
|
|
arrayList3.add(valueAt.mViewModelStore);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
arrayList = null;
|
|
arrayList2 = null;
|
|
arrayList3 = null;
|
|
}
|
|
if (arrayList == null && arrayList2 == null && arrayList3 == null) {
|
|
this.D = null;
|
|
} else {
|
|
this.D = new FragmentManagerNonConfig(arrayList, arrayList2, arrayList3);
|
|
}
|
|
}
|
|
|
|
void x() {
|
|
synchronized (this) {
|
|
boolean z = false;
|
|
boolean z2 = (this.C == null || this.C.isEmpty()) ? false : true;
|
|
if (this.a != null && this.a.size() == 1) {
|
|
z = true;
|
|
}
|
|
if (z2 || z) {
|
|
this.m.e().removeCallbacks(this.E);
|
|
this.m.e().post(this.E);
|
|
}
|
|
}
|
|
}
|
|
|
|
void y() {
|
|
if (this.e == null) {
|
|
return;
|
|
}
|
|
for (int i = 0; i < this.e.size(); i++) {
|
|
Fragment valueAt = this.e.valueAt(i);
|
|
if (valueAt != null) {
|
|
k(valueAt);
|
|
}
|
|
}
|
|
}
|
|
|
|
void c(final Fragment fragment) {
|
|
Animator animator;
|
|
if (fragment.mView != null) {
|
|
AnimationOrAnimator a = a(fragment, fragment.getNextTransition(), !fragment.mHidden, fragment.getNextTransitionStyle());
|
|
if (a == null || (animator = a.b) == null) {
|
|
if (a != null) {
|
|
a(fragment.mView, a);
|
|
fragment.mView.startAnimation(a.a);
|
|
a.a.start();
|
|
}
|
|
fragment.mView.setVisibility((!fragment.mHidden || fragment.isHideReplaced()) ? 0 : 8);
|
|
if (fragment.isHideReplaced()) {
|
|
fragment.setHideReplaced(false);
|
|
}
|
|
} else {
|
|
animator.setTarget(fragment.mView);
|
|
if (!fragment.mHidden) {
|
|
fragment.mView.setVisibility(0);
|
|
} else if (fragment.isHideReplaced()) {
|
|
fragment.setHideReplaced(false);
|
|
} else {
|
|
final ViewGroup viewGroup = fragment.mContainer;
|
|
final View view = fragment.mView;
|
|
viewGroup.startViewTransition(view);
|
|
a.b.addListener(new AnimatorListenerAdapter(this) { // from class: androidx.fragment.app.FragmentManagerImpl.4
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationEnd(Animator animator2) {
|
|
viewGroup.endViewTransition(view);
|
|
animator2.removeListener(this);
|
|
View view2 = fragment.mView;
|
|
if (view2 != null) {
|
|
view2.setVisibility(8);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
a(fragment.mView, a);
|
|
a.b.start();
|
|
}
|
|
}
|
|
if (fragment.mAdded && fragment.mHasMenu && fragment.mMenuVisible) {
|
|
this.q = true;
|
|
}
|
|
fragment.mHiddenChanged = false;
|
|
fragment.onHiddenChanged(fragment.mHidden);
|
|
}
|
|
|
|
public void d(Fragment fragment) {
|
|
if (F) {
|
|
Log.v("FragmentManager", "detach: " + fragment);
|
|
}
|
|
if (fragment.mDetached) {
|
|
return;
|
|
}
|
|
fragment.mDetached = true;
|
|
if (fragment.mAdded) {
|
|
if (F) {
|
|
Log.v("FragmentManager", "remove from detach: " + fragment);
|
|
}
|
|
synchronized (this.d) {
|
|
this.d.remove(fragment);
|
|
}
|
|
if (fragment.mHasMenu && fragment.mMenuVisible) {
|
|
this.q = true;
|
|
}
|
|
fragment.mAdded = false;
|
|
}
|
|
}
|
|
|
|
public void j() {
|
|
for (int i = 0; i < this.d.size(); i++) {
|
|
Fragment fragment = this.d.get(i);
|
|
if (fragment != null) {
|
|
fragment.performLowMemory();
|
|
}
|
|
}
|
|
}
|
|
|
|
void e(Fragment fragment) {
|
|
if (!fragment.mFromLayout || fragment.mPerformedCreateView) {
|
|
return;
|
|
}
|
|
fragment.performCreateView(fragment.performGetLayoutInflater(fragment.mSavedFragmentState), null, fragment.mSavedFragmentState);
|
|
View view = fragment.mView;
|
|
if (view != null) {
|
|
fragment.mInnerView = view;
|
|
view.setSaveFromParentEnabled(false);
|
|
if (fragment.mHidden) {
|
|
fragment.mView.setVisibility(8);
|
|
}
|
|
fragment.onViewCreated(fragment.mView, fragment.mSavedFragmentState);
|
|
a(fragment, fragment.mView, fragment.mSavedFragmentState, false);
|
|
return;
|
|
}
|
|
fragment.mInnerView = null;
|
|
}
|
|
|
|
/* compiled from: FragmentManager.java */
|
|
private static class AnimationOrAnimator {
|
|
public final Animation a;
|
|
public final Animator b;
|
|
|
|
AnimationOrAnimator(Animation animation) {
|
|
this.a = animation;
|
|
this.b = null;
|
|
if (animation == null) {
|
|
throw new IllegalStateException("Animation cannot be null");
|
|
}
|
|
}
|
|
|
|
AnimationOrAnimator(Animator animator) {
|
|
this.a = null;
|
|
this.b = animator;
|
|
if (animator == null) {
|
|
throw new IllegalStateException("Animator cannot be null");
|
|
}
|
|
}
|
|
}
|
|
|
|
public void o(Fragment fragment) {
|
|
if (fragment != null && (this.e.get(fragment.mIndex) != fragment || (fragment.mHost != null && fragment.getFragmentManager() != this))) {
|
|
throw new IllegalArgumentException("Fragment " + fragment + " is not an active fragment of FragmentManager " + this);
|
|
}
|
|
this.p = fragment;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager
|
|
public List<Fragment> b() {
|
|
List<Fragment> list;
|
|
if (this.d.isEmpty()) {
|
|
return Collections.emptyList();
|
|
}
|
|
synchronized (this.d) {
|
|
list = (List) this.d.clone();
|
|
}
|
|
return list;
|
|
}
|
|
|
|
public void f() {
|
|
this.r = false;
|
|
this.s = false;
|
|
d(2);
|
|
}
|
|
|
|
public void h() {
|
|
this.t = true;
|
|
p();
|
|
d(0);
|
|
this.m = null;
|
|
this.n = null;
|
|
this.o = null;
|
|
}
|
|
|
|
public boolean p() {
|
|
c(true);
|
|
boolean z = false;
|
|
while (b(this.x, this.y)) {
|
|
this.b = true;
|
|
try {
|
|
c(this.x, this.y);
|
|
B();
|
|
z = true;
|
|
} catch (Throwable th) {
|
|
B();
|
|
throw th;
|
|
}
|
|
}
|
|
o();
|
|
z();
|
|
return z;
|
|
}
|
|
|
|
/* compiled from: FragmentManager.java */
|
|
private static class EndViewTransitionAnimator extends AnimationSet implements Runnable {
|
|
private final ViewGroup a;
|
|
private final View b;
|
|
private boolean c;
|
|
private boolean d;
|
|
private boolean e;
|
|
|
|
EndViewTransitionAnimator(Animation animation, ViewGroup viewGroup, View view) {
|
|
super(false);
|
|
this.e = true;
|
|
this.a = viewGroup;
|
|
this.b = view;
|
|
addAnimation(animation);
|
|
this.a.post(this);
|
|
}
|
|
|
|
@Override // android.view.animation.AnimationSet, android.view.animation.Animation
|
|
public boolean getTransformation(long j, Transformation transformation) {
|
|
this.e = true;
|
|
if (this.c) {
|
|
return !this.d;
|
|
}
|
|
if (!super.getTransformation(j, transformation)) {
|
|
this.c = true;
|
|
OneShotPreDrawListener.a(this.a, this);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (this.c || !this.e) {
|
|
this.a.endViewTransition(this.b);
|
|
this.d = true;
|
|
} else {
|
|
this.e = false;
|
|
this.a.post(this);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.animation.Animation
|
|
public boolean getTransformation(long j, Transformation transformation, float f) {
|
|
this.e = true;
|
|
if (this.c) {
|
|
return !this.d;
|
|
}
|
|
if (!super.getTransformation(j, transformation, f)) {
|
|
this.c = true;
|
|
OneShotPreDrawListener.a(this.a, this);
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public void k() {
|
|
d(3);
|
|
}
|
|
|
|
static boolean a(Animator animator) {
|
|
if (animator == null) {
|
|
return false;
|
|
}
|
|
if (animator instanceof ValueAnimator) {
|
|
for (PropertyValuesHolder propertyValuesHolder : ((ValueAnimator) animator).getValues()) {
|
|
if ("alpha".equals(propertyValuesHolder.getPropertyName())) {
|
|
return true;
|
|
}
|
|
}
|
|
} else if (animator instanceof AnimatorSet) {
|
|
ArrayList<Animator> childAnimations = ((AnimatorSet) animator).getChildAnimations();
|
|
for (int i = 0; i < childAnimations.size(); i++) {
|
|
if (a(childAnimations.get(i))) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public void g() {
|
|
this.r = false;
|
|
this.s = false;
|
|
d(1);
|
|
}
|
|
|
|
void f(Fragment fragment, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).f(fragment, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.e(this, fragment);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void n() {
|
|
this.s = true;
|
|
d(2);
|
|
}
|
|
|
|
public void b(Fragment fragment) {
|
|
if (F) {
|
|
Log.v("FragmentManager", "attach: " + fragment);
|
|
}
|
|
if (fragment.mDetached) {
|
|
fragment.mDetached = false;
|
|
if (fragment.mAdded) {
|
|
return;
|
|
}
|
|
if (!this.d.contains(fragment)) {
|
|
if (F) {
|
|
Log.v("FragmentManager", "add from attach: " + fragment);
|
|
}
|
|
synchronized (this.d) {
|
|
this.d.add(fragment);
|
|
}
|
|
fragment.mAdded = true;
|
|
if (fragment.mHasMenu && fragment.mMenuVisible) {
|
|
this.q = true;
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
throw new IllegalStateException("Fragment already added: " + fragment);
|
|
}
|
|
}
|
|
|
|
void g(Fragment fragment, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).g(fragment, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.f(this, fragment);
|
|
}
|
|
}
|
|
}
|
|
|
|
void h(Fragment fragment, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).h(fragment, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.g(this, fragment);
|
|
}
|
|
}
|
|
}
|
|
|
|
void e(Fragment fragment, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).e(fragment, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.d(this, fragment);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void l() {
|
|
this.r = false;
|
|
this.s = false;
|
|
d(4);
|
|
}
|
|
|
|
private void d(int i) {
|
|
try {
|
|
this.b = true;
|
|
a(i, false);
|
|
this.b = false;
|
|
p();
|
|
} catch (Throwable th) {
|
|
this.b = false;
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
private void a(RuntimeException runtimeException) {
|
|
Log.e("FragmentManager", runtimeException.getMessage());
|
|
Log.e("FragmentManager", "Activity state:");
|
|
PrintWriter printWriter = new PrintWriter(new LogWriter("FragmentManager"));
|
|
FragmentHostCallback fragmentHostCallback = this.m;
|
|
if (fragmentHostCallback != null) {
|
|
try {
|
|
fragmentHostCallback.a(" ", (FileDescriptor) null, printWriter, new String[0]);
|
|
throw runtimeException;
|
|
} catch (Exception e) {
|
|
Log.e("FragmentManager", "Failed dumping state", e);
|
|
throw runtimeException;
|
|
}
|
|
}
|
|
try {
|
|
a(" ", (FileDescriptor) null, printWriter, new String[0]);
|
|
throw runtimeException;
|
|
} catch (Exception e2) {
|
|
Log.e("FragmentManager", "Failed dumping state", e2);
|
|
throw runtimeException;
|
|
}
|
|
}
|
|
|
|
public void m() {
|
|
this.r = false;
|
|
this.s = false;
|
|
d(3);
|
|
}
|
|
|
|
void d(Fragment fragment, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).d(fragment, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.c(this, fragment);
|
|
}
|
|
}
|
|
}
|
|
|
|
public Fragment b(String str) {
|
|
Fragment findFragmentByWho;
|
|
SparseArray<Fragment> sparseArray = this.e;
|
|
if (sparseArray == null || str == null) {
|
|
return null;
|
|
}
|
|
for (int size = sparseArray.size() - 1; size >= 0; size--) {
|
|
Fragment valueAt = this.e.valueAt(size);
|
|
if (valueAt != null && (findFragmentByWho = valueAt.findFragmentByWho(str)) != null) {
|
|
return findFragmentByWho;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager
|
|
public FragmentTransaction a() {
|
|
return new BackStackRecord(this);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager
|
|
public void a(int i, int i2) {
|
|
if (i >= 0) {
|
|
a((OpGenerator) new PopBackStackState(null, i, i2), false);
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("Bad id: " + i);
|
|
}
|
|
|
|
void d(Fragment fragment, Bundle bundle, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).d(fragment, bundle, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.d(this, fragment, bundle);
|
|
}
|
|
}
|
|
}
|
|
|
|
public int b(BackStackRecord backStackRecord) {
|
|
synchronized (this) {
|
|
if (this.i != null && this.i.size() > 0) {
|
|
int intValue = this.i.remove(this.i.size() - 1).intValue();
|
|
if (F) {
|
|
Log.v("FragmentManager", "Adding back stack index " + intValue + " with " + backStackRecord);
|
|
}
|
|
this.h.set(intValue, backStackRecord);
|
|
return intValue;
|
|
}
|
|
if (this.h == null) {
|
|
this.h = new ArrayList<>();
|
|
}
|
|
int size = this.h.size();
|
|
if (F) {
|
|
Log.v("FragmentManager", "Setting back stack index " + size + " to " + backStackRecord);
|
|
}
|
|
this.h.add(backStackRecord);
|
|
return size;
|
|
}
|
|
}
|
|
|
|
private boolean a(String str, int i, int i2) {
|
|
FragmentManager peekChildFragmentManager;
|
|
p();
|
|
c(true);
|
|
Fragment fragment = this.p;
|
|
if (fragment != null && i < 0 && str == null && (peekChildFragmentManager = fragment.peekChildFragmentManager()) != null && peekChildFragmentManager.e()) {
|
|
return true;
|
|
}
|
|
boolean a = a(this.x, this.y, str, i, i2);
|
|
if (a) {
|
|
this.b = true;
|
|
try {
|
|
c(this.x, this.y);
|
|
} finally {
|
|
B();
|
|
}
|
|
}
|
|
o();
|
|
z();
|
|
return a;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager
|
|
public boolean c() {
|
|
return this.r || this.s;
|
|
}
|
|
|
|
private void c(boolean z) {
|
|
if (!this.b) {
|
|
if (this.m != null) {
|
|
if (Looper.myLooper() == this.m.e().getLooper()) {
|
|
if (!z) {
|
|
A();
|
|
}
|
|
if (this.x == null) {
|
|
this.x = new ArrayList<>();
|
|
this.y = new ArrayList<>();
|
|
}
|
|
this.b = true;
|
|
try {
|
|
a((ArrayList<BackStackRecord>) null, (ArrayList<Boolean>) null);
|
|
return;
|
|
} finally {
|
|
this.b = false;
|
|
}
|
|
}
|
|
throw new IllegalStateException("Must be called from main thread of fragment host");
|
|
}
|
|
throw new IllegalStateException("Fragment host has been destroyed");
|
|
}
|
|
throw new IllegalStateException("FragmentManager is already executing transactions");
|
|
}
|
|
|
|
public void i() {
|
|
d(1);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager
|
|
public void a(Bundle bundle, String str, Fragment fragment) {
|
|
int i = fragment.mIndex;
|
|
if (i >= 0) {
|
|
bundle.putInt(str, i);
|
|
return;
|
|
}
|
|
a(new IllegalStateException("Fragment " + fragment + " is not currently in the FragmentManager"));
|
|
throw null;
|
|
}
|
|
|
|
public void b(int i) {
|
|
synchronized (this) {
|
|
this.h.set(i, null);
|
|
if (this.i == null) {
|
|
this.i = new ArrayList<>();
|
|
}
|
|
if (F) {
|
|
Log.v("FragmentManager", "Freeing back stack index " + i);
|
|
}
|
|
this.i.add(Integer.valueOf(i));
|
|
}
|
|
}
|
|
|
|
private void c(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2) {
|
|
if (arrayList == null || arrayList.isEmpty()) {
|
|
return;
|
|
}
|
|
if (arrayList2 != null && arrayList.size() == arrayList2.size()) {
|
|
a(arrayList, arrayList2);
|
|
int size = arrayList.size();
|
|
int i = 0;
|
|
int i2 = 0;
|
|
while (i < size) {
|
|
if (!arrayList.get(i).t) {
|
|
if (i2 != i) {
|
|
b(arrayList, arrayList2, i2, i);
|
|
}
|
|
i2 = i + 1;
|
|
if (arrayList2.get(i).booleanValue()) {
|
|
while (i2 < size && arrayList2.get(i2).booleanValue() && !arrayList.get(i2).t) {
|
|
i2++;
|
|
}
|
|
}
|
|
b(arrayList, arrayList2, i, i2);
|
|
i = i2 - 1;
|
|
}
|
|
i++;
|
|
}
|
|
if (i2 != size) {
|
|
b(arrayList, arrayList2, i2, size);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
throw new IllegalStateException("Internal error with the back stack records");
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager
|
|
public Fragment a(Bundle bundle, String str) {
|
|
int i = bundle.getInt(str, -1);
|
|
if (i == -1) {
|
|
return null;
|
|
}
|
|
Fragment fragment = this.e.get(i);
|
|
if (fragment != null) {
|
|
return fragment;
|
|
}
|
|
a(new IllegalStateException("Fragment no longer exists for key " + str + ": index " + i));
|
|
throw null;
|
|
}
|
|
|
|
@Override // android.view.LayoutInflater.Factory
|
|
public View onCreateView(String str, Context context, AttributeSet attributeSet) {
|
|
return onCreateView(null, str, context, attributeSet);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager
|
|
public Fragment.SavedState a(Fragment fragment) {
|
|
Bundle m;
|
|
if (fragment.mIndex >= 0) {
|
|
if (fragment.mState <= 0 || (m = m(fragment)) == null) {
|
|
return null;
|
|
}
|
|
return new Fragment.SavedState(m);
|
|
}
|
|
a(new IllegalStateException("Fragment " + fragment + " is not currently in the FragmentManager"));
|
|
throw null;
|
|
}
|
|
|
|
public void b(OpGenerator opGenerator, boolean z) {
|
|
if (z && (this.m == null || this.t)) {
|
|
return;
|
|
}
|
|
c(z);
|
|
if (opGenerator.a(this.x, this.y)) {
|
|
this.b = true;
|
|
try {
|
|
c(this.x, this.y);
|
|
} finally {
|
|
B();
|
|
}
|
|
}
|
|
o();
|
|
z();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager
|
|
public void a(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
|
|
int size;
|
|
int size2;
|
|
int size3;
|
|
int size4;
|
|
int size5;
|
|
String str2 = str + " ";
|
|
SparseArray<Fragment> sparseArray = this.e;
|
|
if (sparseArray != null && (size5 = sparseArray.size()) > 0) {
|
|
printWriter.print(str);
|
|
printWriter.print("Active Fragments in ");
|
|
printWriter.print(Integer.toHexString(System.identityHashCode(this)));
|
|
printWriter.println(":");
|
|
for (int i = 0; i < size5; i++) {
|
|
Fragment valueAt = this.e.valueAt(i);
|
|
printWriter.print(str);
|
|
printWriter.print(" #");
|
|
printWriter.print(i);
|
|
printWriter.print(": ");
|
|
printWriter.println(valueAt);
|
|
if (valueAt != null) {
|
|
valueAt.dump(str2, fileDescriptor, printWriter, strArr);
|
|
}
|
|
}
|
|
}
|
|
int size6 = this.d.size();
|
|
if (size6 > 0) {
|
|
printWriter.print(str);
|
|
printWriter.println("Added Fragments:");
|
|
for (int i2 = 0; i2 < size6; i2++) {
|
|
Fragment fragment = this.d.get(i2);
|
|
printWriter.print(str);
|
|
printWriter.print(" #");
|
|
printWriter.print(i2);
|
|
printWriter.print(": ");
|
|
printWriter.println(fragment.toString());
|
|
}
|
|
}
|
|
ArrayList<Fragment> arrayList = this.g;
|
|
if (arrayList != null && (size4 = arrayList.size()) > 0) {
|
|
printWriter.print(str);
|
|
printWriter.println("Fragments Created Menus:");
|
|
for (int i3 = 0; i3 < size4; i3++) {
|
|
Fragment fragment2 = this.g.get(i3);
|
|
printWriter.print(str);
|
|
printWriter.print(" #");
|
|
printWriter.print(i3);
|
|
printWriter.print(": ");
|
|
printWriter.println(fragment2.toString());
|
|
}
|
|
}
|
|
ArrayList<BackStackRecord> arrayList2 = this.f;
|
|
if (arrayList2 != null && (size3 = arrayList2.size()) > 0) {
|
|
printWriter.print(str);
|
|
printWriter.println("Back Stack:");
|
|
for (int i4 = 0; i4 < size3; i4++) {
|
|
BackStackRecord backStackRecord = this.f.get(i4);
|
|
printWriter.print(str);
|
|
printWriter.print(" #");
|
|
printWriter.print(i4);
|
|
printWriter.print(": ");
|
|
printWriter.println(backStackRecord.toString());
|
|
backStackRecord.a(str2, fileDescriptor, printWriter, strArr);
|
|
}
|
|
}
|
|
synchronized (this) {
|
|
if (this.h != null && (size2 = this.h.size()) > 0) {
|
|
printWriter.print(str);
|
|
printWriter.println("Back Stack Indices:");
|
|
for (int i5 = 0; i5 < size2; i5++) {
|
|
Object obj = (BackStackRecord) this.h.get(i5);
|
|
printWriter.print(str);
|
|
printWriter.print(" #");
|
|
printWriter.print(i5);
|
|
printWriter.print(": ");
|
|
printWriter.println(obj);
|
|
}
|
|
}
|
|
if (this.i != null && this.i.size() > 0) {
|
|
printWriter.print(str);
|
|
printWriter.print("mAvailBackStackIndices: ");
|
|
printWriter.println(Arrays.toString(this.i.toArray()));
|
|
}
|
|
}
|
|
ArrayList<OpGenerator> arrayList3 = this.a;
|
|
if (arrayList3 != null && (size = arrayList3.size()) > 0) {
|
|
printWriter.print(str);
|
|
printWriter.println("Pending Actions:");
|
|
for (int i6 = 0; i6 < size; i6++) {
|
|
Object obj2 = (OpGenerator) this.a.get(i6);
|
|
printWriter.print(str);
|
|
printWriter.print(" #");
|
|
printWriter.print(i6);
|
|
printWriter.print(": ");
|
|
printWriter.println(obj2);
|
|
}
|
|
}
|
|
printWriter.print(str);
|
|
printWriter.println("FragmentManager misc state:");
|
|
printWriter.print(str);
|
|
printWriter.print(" mHost=");
|
|
printWriter.println(this.m);
|
|
printWriter.print(str);
|
|
printWriter.print(" mContainer=");
|
|
printWriter.println(this.n);
|
|
if (this.o != null) {
|
|
printWriter.print(str);
|
|
printWriter.print(" mParent=");
|
|
printWriter.println(this.o);
|
|
}
|
|
printWriter.print(str);
|
|
printWriter.print(" mCurState=");
|
|
printWriter.print(this.l);
|
|
printWriter.print(" mStateSaved=");
|
|
printWriter.print(this.r);
|
|
printWriter.print(" mStopped=");
|
|
printWriter.print(this.s);
|
|
printWriter.print(" mDestroyed=");
|
|
printWriter.println(this.t);
|
|
if (this.q) {
|
|
printWriter.print(str);
|
|
printWriter.print(" mNeedMenuInvalidate=");
|
|
printWriter.println(this.q);
|
|
}
|
|
if (this.u != null) {
|
|
printWriter.print(str);
|
|
printWriter.print(" mNoTransactionsBecause=");
|
|
printWriter.println(this.u);
|
|
}
|
|
}
|
|
|
|
void c(Fragment fragment, Bundle bundle, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).c(fragment, bundle, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.c(this, fragment, bundle);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void b(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2, int i, int i2) {
|
|
int i3;
|
|
int i4;
|
|
int i5 = i;
|
|
boolean z = arrayList.get(i5).t;
|
|
ArrayList<Fragment> arrayList3 = this.z;
|
|
if (arrayList3 == null) {
|
|
this.z = new ArrayList<>();
|
|
} else {
|
|
arrayList3.clear();
|
|
}
|
|
this.z.addAll(this.d);
|
|
Fragment r = r();
|
|
boolean z2 = false;
|
|
for (int i6 = i5; i6 < i2; i6++) {
|
|
BackStackRecord backStackRecord = arrayList.get(i6);
|
|
if (!arrayList2.get(i6).booleanValue()) {
|
|
r = backStackRecord.a(this.z, r);
|
|
} else {
|
|
r = backStackRecord.b(this.z, r);
|
|
}
|
|
z2 = z2 || backStackRecord.i;
|
|
}
|
|
this.z.clear();
|
|
if (!z) {
|
|
FragmentTransition.a(this, arrayList, arrayList2, i, i2, false);
|
|
}
|
|
a(arrayList, arrayList2, i, i2);
|
|
if (z) {
|
|
ArraySet<Fragment> arraySet = new ArraySet<>();
|
|
a(arraySet);
|
|
int a = a(arrayList, arrayList2, i, i2, arraySet);
|
|
b(arraySet);
|
|
i3 = a;
|
|
} else {
|
|
i3 = i2;
|
|
}
|
|
if (i3 != i5 && z) {
|
|
FragmentTransition.a(this, arrayList, arrayList2, i, i3, true);
|
|
a(this.l, true);
|
|
}
|
|
while (i5 < i2) {
|
|
BackStackRecord backStackRecord2 = arrayList.get(i5);
|
|
if (arrayList2.get(i5).booleanValue() && (i4 = backStackRecord2.m) >= 0) {
|
|
b(i4);
|
|
backStackRecord2.m = -1;
|
|
}
|
|
backStackRecord2.h();
|
|
i5++;
|
|
}
|
|
if (z2) {
|
|
t();
|
|
}
|
|
}
|
|
|
|
void c(Fragment fragment, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).c(fragment, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.b(this, fragment);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void b(ArraySet<Fragment> arraySet) {
|
|
int size = arraySet.size();
|
|
for (int i = 0; i < size; i++) {
|
|
Fragment e = arraySet.e(i);
|
|
if (!e.mAdded) {
|
|
View view = e.getView();
|
|
e.mPostponedAlpha = view.getAlpha();
|
|
view.setAlpha(0.0f);
|
|
}
|
|
}
|
|
}
|
|
|
|
private boolean b(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2) {
|
|
synchronized (this) {
|
|
if (this.a != null && this.a.size() != 0) {
|
|
int size = this.a.size();
|
|
boolean z = false;
|
|
for (int i = 0; i < size; i++) {
|
|
z |= this.a.get(i).a(arrayList, arrayList2);
|
|
}
|
|
this.a.clear();
|
|
this.m.e().removeCallbacks(this.E);
|
|
return z;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public void b(boolean z) {
|
|
for (int size = this.d.size() - 1; size >= 0; size--) {
|
|
Fragment fragment = this.d.get(size);
|
|
if (fragment != null) {
|
|
fragment.performPictureInPictureModeChanged(z);
|
|
}
|
|
}
|
|
}
|
|
|
|
public boolean b(Menu menu) {
|
|
if (this.l < 1) {
|
|
return false;
|
|
}
|
|
boolean z = false;
|
|
for (int i = 0; i < this.d.size(); i++) {
|
|
Fragment fragment = this.d.get(i);
|
|
if (fragment != null && fragment.performPrepareOptionsMenu(menu)) {
|
|
z = true;
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
public boolean b(MenuItem menuItem) {
|
|
if (this.l < 1) {
|
|
return false;
|
|
}
|
|
for (int i = 0; i < this.d.size(); i++) {
|
|
Fragment fragment = this.d.get(i);
|
|
if (fragment != null && fragment.performOptionsItemSelected(menuItem)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void b(Fragment fragment, Context context, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).b(fragment, context, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.b(this, fragment, context);
|
|
}
|
|
}
|
|
}
|
|
|
|
static AnimationOrAnimator a(Context context, float f, float f2, float f3, float f4) {
|
|
AnimationSet animationSet = new AnimationSet(false);
|
|
ScaleAnimation scaleAnimation = new ScaleAnimation(f, f2, f, f2, 1, 0.5f, 1, 0.5f);
|
|
scaleAnimation.setInterpolator(H);
|
|
scaleAnimation.setDuration(220L);
|
|
animationSet.addAnimation(scaleAnimation);
|
|
AlphaAnimation alphaAnimation = new AlphaAnimation(f3, f4);
|
|
alphaAnimation.setInterpolator(I);
|
|
alphaAnimation.setDuration(220L);
|
|
animationSet.addAnimation(alphaAnimation);
|
|
return new AnimationOrAnimator(animationSet);
|
|
}
|
|
|
|
void b(Fragment fragment, Bundle bundle, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).b(fragment, bundle, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.b(this, fragment, bundle);
|
|
}
|
|
}
|
|
}
|
|
|
|
static AnimationOrAnimator a(Context context, float f, float f2) {
|
|
AlphaAnimation alphaAnimation = new AlphaAnimation(f, f2);
|
|
alphaAnimation.setInterpolator(I);
|
|
alphaAnimation.setDuration(220L);
|
|
return new AnimationOrAnimator(alphaAnimation);
|
|
}
|
|
|
|
void b(Fragment fragment, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).b(fragment, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.a(this, fragment);
|
|
}
|
|
}
|
|
}
|
|
|
|
AnimationOrAnimator a(Fragment fragment, int i, boolean z, int i2) {
|
|
int b;
|
|
int nextAnim = fragment.getNextAnim();
|
|
Animation onCreateAnimation = fragment.onCreateAnimation(i, z, nextAnim);
|
|
if (onCreateAnimation != null) {
|
|
return new AnimationOrAnimator(onCreateAnimation);
|
|
}
|
|
Animator onCreateAnimator = fragment.onCreateAnimator(i, z, nextAnim);
|
|
if (onCreateAnimator != null) {
|
|
return new AnimationOrAnimator(onCreateAnimator);
|
|
}
|
|
if (nextAnim != 0) {
|
|
boolean equals = "anim".equals(this.m.c().getResources().getResourceTypeName(nextAnim));
|
|
boolean z2 = false;
|
|
if (equals) {
|
|
try {
|
|
Animation loadAnimation = AnimationUtils.loadAnimation(this.m.c(), nextAnim);
|
|
if (loadAnimation != null) {
|
|
return new AnimationOrAnimator(loadAnimation);
|
|
}
|
|
z2 = true;
|
|
} catch (Resources.NotFoundException e) {
|
|
throw e;
|
|
} catch (RuntimeException unused) {
|
|
}
|
|
}
|
|
if (!z2) {
|
|
try {
|
|
Animator loadAnimator = AnimatorInflater.loadAnimator(this.m.c(), nextAnim);
|
|
if (loadAnimator != null) {
|
|
return new AnimationOrAnimator(loadAnimator);
|
|
}
|
|
} catch (RuntimeException e2) {
|
|
if (!equals) {
|
|
Animation loadAnimation2 = AnimationUtils.loadAnimation(this.m.c(), nextAnim);
|
|
if (loadAnimation2 != null) {
|
|
return new AnimationOrAnimator(loadAnimation2);
|
|
}
|
|
} else {
|
|
throw e2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (i == 0 || (b = b(i, z)) < 0) {
|
|
return null;
|
|
}
|
|
switch (b) {
|
|
case 1:
|
|
return a(this.m.c(), 1.125f, 1.0f, 0.0f, 1.0f);
|
|
case 2:
|
|
return a(this.m.c(), 1.0f, 0.975f, 1.0f, 0.0f);
|
|
case 3:
|
|
return a(this.m.c(), 0.975f, 1.0f, 0.0f, 1.0f);
|
|
case 4:
|
|
return a(this.m.c(), 1.0f, 1.075f, 1.0f, 0.0f);
|
|
case 5:
|
|
return a(this.m.c(), 0.0f, 1.0f);
|
|
case 6:
|
|
return a(this.m.c(), 1.0f, 0.0f);
|
|
default:
|
|
if (i2 == 0 && this.m.i()) {
|
|
i2 = this.m.h();
|
|
}
|
|
if (i2 == 0) {
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private static void a(View view, AnimationOrAnimator animationOrAnimator) {
|
|
if (view == null || animationOrAnimator == null || !b(view, animationOrAnimator)) {
|
|
return;
|
|
}
|
|
Animator animator = animationOrAnimator.b;
|
|
if (animator != null) {
|
|
animator.addListener(new AnimatorOnHWLayerIfNeededListener(view));
|
|
return;
|
|
}
|
|
Animation.AnimationListener a = a(animationOrAnimator.a);
|
|
view.setLayerType(2, null);
|
|
animationOrAnimator.a.setAnimationListener(new AnimateOnHWLayerIfNeededListener(view, a));
|
|
}
|
|
|
|
private static Animation.AnimationListener a(Animation animation) {
|
|
try {
|
|
if (G == null) {
|
|
G = Animation.class.getDeclaredField("mListener");
|
|
G.setAccessible(true);
|
|
}
|
|
return (Animation.AnimationListener) G.get(animation);
|
|
} catch (IllegalAccessException e) {
|
|
Log.e("FragmentManager", "Cannot access Animation's mListener field", e);
|
|
return null;
|
|
} catch (NoSuchFieldException e2) {
|
|
Log.e("FragmentManager", "No field with the name mListener is found in Animation class", e2);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:37:0x0072, code lost:
|
|
|
|
if (r0 != 3) goto L218;
|
|
*/
|
|
/* JADX WARN: Removed duplicated region for block: B:39:0x02b4 */
|
|
/* JADX WARN: Removed duplicated region for block: B:46:0x041f */
|
|
/* JADX WARN: Removed duplicated region for block: B:48:? A[RETURN, SYNTHETIC] */
|
|
/* JADX WARN: Removed duplicated region for block: B:50:0x0294 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
void a(androidx.fragment.app.Fragment r17, int r18, int r19, int r20, boolean r21) {
|
|
/*
|
|
Method dump skipped, instructions count: 1101
|
|
To view this dump change 'Code comments level' option to 'DEBUG'
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.fragment.app.FragmentManagerImpl.a(androidx.fragment.app.Fragment, int, int, int, boolean):void");
|
|
}
|
|
|
|
private void a(final Fragment fragment, AnimationOrAnimator animationOrAnimator, int i) {
|
|
final View view = fragment.mView;
|
|
final ViewGroup viewGroup = fragment.mContainer;
|
|
viewGroup.startViewTransition(view);
|
|
fragment.setStateAfterAnimating(i);
|
|
Animation animation = animationOrAnimator.a;
|
|
if (animation != null) {
|
|
EndViewTransitionAnimator endViewTransitionAnimator = new EndViewTransitionAnimator(animation, viewGroup, view);
|
|
fragment.setAnimatingAway(fragment.mView);
|
|
endViewTransitionAnimator.setAnimationListener(new AnimationListenerWrapper(a(endViewTransitionAnimator)) { // from class: androidx.fragment.app.FragmentManagerImpl.2
|
|
@Override // androidx.fragment.app.FragmentManagerImpl.AnimationListenerWrapper, android.view.animation.Animation.AnimationListener
|
|
public void onAnimationEnd(Animation animation2) {
|
|
super.onAnimationEnd(animation2);
|
|
viewGroup.post(new Runnable() { // from class: androidx.fragment.app.FragmentManagerImpl.2.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (fragment.getAnimatingAway() != null) {
|
|
fragment.setAnimatingAway(null);
|
|
AnonymousClass2 anonymousClass2 = AnonymousClass2.this;
|
|
FragmentManagerImpl fragmentManagerImpl = FragmentManagerImpl.this;
|
|
Fragment fragment2 = fragment;
|
|
fragmentManagerImpl.a(fragment2, fragment2.getStateAfterAnimating(), 0, 0, false);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
a(view, animationOrAnimator);
|
|
fragment.mView.startAnimation(endViewTransitionAnimator);
|
|
return;
|
|
}
|
|
Animator animator = animationOrAnimator.b;
|
|
fragment.setAnimator(animator);
|
|
animator.addListener(new AnimatorListenerAdapter() { // from class: androidx.fragment.app.FragmentManagerImpl.3
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationEnd(Animator animator2) {
|
|
viewGroup.endViewTransition(view);
|
|
Animator animator3 = fragment.getAnimator();
|
|
fragment.setAnimator(null);
|
|
if (animator3 == null || viewGroup.indexOfChild(view) >= 0) {
|
|
return;
|
|
}
|
|
FragmentManagerImpl fragmentManagerImpl = FragmentManagerImpl.this;
|
|
Fragment fragment2 = fragment;
|
|
fragmentManagerImpl.a(fragment2, fragment2.getStateAfterAnimating(), 0, 0, false);
|
|
}
|
|
});
|
|
animator.setTarget(fragment.mView);
|
|
a(fragment.mView, animationOrAnimator);
|
|
animator.start();
|
|
}
|
|
|
|
void a(int i, boolean z) {
|
|
FragmentHostCallback fragmentHostCallback;
|
|
if (this.m == null && i != 0) {
|
|
throw new IllegalStateException("No activity");
|
|
}
|
|
if (z || i != this.l) {
|
|
this.l = i;
|
|
if (this.e != null) {
|
|
int size = this.d.size();
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
i(this.d.get(i2));
|
|
}
|
|
int size2 = this.e.size();
|
|
for (int i3 = 0; i3 < size2; i3++) {
|
|
Fragment valueAt = this.e.valueAt(i3);
|
|
if (valueAt != null && ((valueAt.mRemoving || valueAt.mDetached) && !valueAt.mIsNewlyAdded)) {
|
|
i(valueAt);
|
|
}
|
|
}
|
|
y();
|
|
if (this.q && (fragmentHostCallback = this.m) != null && this.l == 4) {
|
|
fragmentHostCallback.j();
|
|
this.q = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void a(Fragment fragment, boolean z) {
|
|
if (F) {
|
|
Log.v("FragmentManager", "add: " + fragment);
|
|
}
|
|
g(fragment);
|
|
if (fragment.mDetached) {
|
|
return;
|
|
}
|
|
if (!this.d.contains(fragment)) {
|
|
synchronized (this.d) {
|
|
this.d.add(fragment);
|
|
}
|
|
fragment.mAdded = true;
|
|
fragment.mRemoving = false;
|
|
if (fragment.mView == null) {
|
|
fragment.mHiddenChanged = false;
|
|
}
|
|
if (fragment.mHasMenu && fragment.mMenuVisible) {
|
|
this.q = true;
|
|
}
|
|
if (z) {
|
|
j(fragment);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
throw new IllegalStateException("Fragment already added: " + fragment);
|
|
}
|
|
|
|
public Fragment a(int i) {
|
|
for (int size = this.d.size() - 1; size >= 0; size--) {
|
|
Fragment fragment = this.d.get(size);
|
|
if (fragment != null && fragment.mFragmentId == i) {
|
|
return fragment;
|
|
}
|
|
}
|
|
SparseArray<Fragment> sparseArray = this.e;
|
|
if (sparseArray == null) {
|
|
return null;
|
|
}
|
|
for (int size2 = sparseArray.size() - 1; size2 >= 0; size2--) {
|
|
Fragment valueAt = this.e.valueAt(size2);
|
|
if (valueAt != null && valueAt.mFragmentId == i) {
|
|
return valueAt;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentManager
|
|
public Fragment a(String str) {
|
|
if (str != null) {
|
|
for (int size = this.d.size() - 1; size >= 0; size--) {
|
|
Fragment fragment = this.d.get(size);
|
|
if (fragment != null && str.equals(fragment.mTag)) {
|
|
return fragment;
|
|
}
|
|
}
|
|
}
|
|
SparseArray<Fragment> sparseArray = this.e;
|
|
if (sparseArray == null || str == null) {
|
|
return null;
|
|
}
|
|
for (int size2 = sparseArray.size() - 1; size2 >= 0; size2--) {
|
|
Fragment valueAt = this.e.valueAt(size2);
|
|
if (valueAt != null && str.equals(valueAt.mTag)) {
|
|
return valueAt;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:19:0x0027, code lost:
|
|
|
|
return;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
public void a(androidx.fragment.app.FragmentManagerImpl.OpGenerator r2, boolean r3) {
|
|
/*
|
|
r1 = this;
|
|
if (r3 != 0) goto L5
|
|
r1.A()
|
|
L5:
|
|
monitor-enter(r1)
|
|
boolean r0 = r1.t // Catch: java.lang.Throwable -> L30
|
|
if (r0 != 0) goto L24
|
|
androidx.fragment.app.FragmentHostCallback r0 = r1.m // Catch: java.lang.Throwable -> L30
|
|
if (r0 != 0) goto Lf
|
|
goto L24
|
|
Lf:
|
|
java.util.ArrayList<androidx.fragment.app.FragmentManagerImpl$OpGenerator> r3 = r1.a // Catch: java.lang.Throwable -> L30
|
|
if (r3 != 0) goto L1a
|
|
java.util.ArrayList r3 = new java.util.ArrayList // Catch: java.lang.Throwable -> L30
|
|
r3.<init>() // Catch: java.lang.Throwable -> L30
|
|
r1.a = r3 // Catch: java.lang.Throwable -> L30
|
|
L1a:
|
|
java.util.ArrayList<androidx.fragment.app.FragmentManagerImpl$OpGenerator> r3 = r1.a // Catch: java.lang.Throwable -> L30
|
|
r3.add(r2) // Catch: java.lang.Throwable -> L30
|
|
r1.x() // Catch: java.lang.Throwable -> L30
|
|
monitor-exit(r1) // Catch: java.lang.Throwable -> L30
|
|
return
|
|
L24:
|
|
if (r3 == 0) goto L28
|
|
monitor-exit(r1) // Catch: java.lang.Throwable -> L30
|
|
return
|
|
L28:
|
|
java.lang.IllegalStateException r2 = new java.lang.IllegalStateException // Catch: java.lang.Throwable -> L30
|
|
java.lang.String r3 = "Activity has been destroyed"
|
|
r2.<init>(r3) // Catch: java.lang.Throwable -> L30
|
|
throw r2 // Catch: java.lang.Throwable -> L30
|
|
L30:
|
|
r2 = move-exception
|
|
monitor-exit(r1) // Catch: java.lang.Throwable -> L30
|
|
throw r2
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.fragment.app.FragmentManagerImpl.a(androidx.fragment.app.FragmentManagerImpl$OpGenerator, boolean):void");
|
|
}
|
|
|
|
public void a(int i, BackStackRecord backStackRecord) {
|
|
synchronized (this) {
|
|
if (this.h == null) {
|
|
this.h = new ArrayList<>();
|
|
}
|
|
int size = this.h.size();
|
|
if (i < size) {
|
|
if (F) {
|
|
Log.v("FragmentManager", "Setting back stack index " + i + " to " + backStackRecord);
|
|
}
|
|
this.h.set(i, backStackRecord);
|
|
} else {
|
|
while (size < i) {
|
|
this.h.add(null);
|
|
if (this.i == null) {
|
|
this.i = new ArrayList<>();
|
|
}
|
|
if (F) {
|
|
Log.v("FragmentManager", "Adding available back stack index " + size);
|
|
}
|
|
this.i.add(Integer.valueOf(size));
|
|
size++;
|
|
}
|
|
if (F) {
|
|
Log.v("FragmentManager", "Adding back stack index " + i + " with " + backStackRecord);
|
|
}
|
|
this.h.add(backStackRecord);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void a(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2) {
|
|
int indexOf;
|
|
int indexOf2;
|
|
ArrayList<StartEnterTransitionListener> arrayList3 = this.C;
|
|
int size = arrayList3 == null ? 0 : arrayList3.size();
|
|
int i = 0;
|
|
while (i < size) {
|
|
StartEnterTransitionListener startEnterTransitionListener = this.C.get(i);
|
|
if (arrayList != null && !startEnterTransitionListener.a && (indexOf2 = arrayList.indexOf(startEnterTransitionListener.b)) != -1 && arrayList2.get(indexOf2).booleanValue()) {
|
|
startEnterTransitionListener.c();
|
|
} else if (startEnterTransitionListener.e() || (arrayList != null && startEnterTransitionListener.b.a(arrayList, 0, arrayList.size()))) {
|
|
this.C.remove(i);
|
|
i--;
|
|
size--;
|
|
if (arrayList != null && !startEnterTransitionListener.a && (indexOf = arrayList.indexOf(startEnterTransitionListener.b)) != -1 && arrayList2.get(indexOf).booleanValue()) {
|
|
startEnterTransitionListener.c();
|
|
} else {
|
|
startEnterTransitionListener.d();
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
private int a(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.g() && !backStackRecord.a(arrayList, i4 + 1, i2)) {
|
|
if (this.C == null) {
|
|
this.C = new ArrayList<>();
|
|
}
|
|
StartEnterTransitionListener startEnterTransitionListener = new StartEnterTransitionListener(backStackRecord, booleanValue);
|
|
this.C.add(startEnterTransitionListener);
|
|
backStackRecord.a(startEnterTransitionListener);
|
|
if (booleanValue) {
|
|
backStackRecord.e();
|
|
} else {
|
|
backStackRecord.b(false);
|
|
}
|
|
i3--;
|
|
if (i4 != i3) {
|
|
arrayList.remove(i4);
|
|
arrayList.add(i3, backStackRecord);
|
|
}
|
|
a(arraySet);
|
|
}
|
|
}
|
|
return i3;
|
|
}
|
|
|
|
void a(BackStackRecord backStackRecord, boolean z, boolean z2, boolean z3) {
|
|
if (z) {
|
|
backStackRecord.b(z3);
|
|
} else {
|
|
backStackRecord.e();
|
|
}
|
|
ArrayList arrayList = new ArrayList(1);
|
|
ArrayList arrayList2 = new ArrayList(1);
|
|
arrayList.add(backStackRecord);
|
|
arrayList2.add(Boolean.valueOf(z));
|
|
if (z2) {
|
|
FragmentTransition.a(this, (ArrayList<BackStackRecord>) arrayList, (ArrayList<Boolean>) arrayList2, 0, 1, true);
|
|
}
|
|
if (z3) {
|
|
a(this.l, true);
|
|
}
|
|
SparseArray<Fragment> sparseArray = this.e;
|
|
if (sparseArray != null) {
|
|
int size = sparseArray.size();
|
|
for (int i = 0; i < size; i++) {
|
|
Fragment valueAt = this.e.valueAt(i);
|
|
if (valueAt != null && valueAt.mView != null && valueAt.mIsNewlyAdded && backStackRecord.b(valueAt.mContainerId)) {
|
|
float f = valueAt.mPostponedAlpha;
|
|
if (f > 0.0f) {
|
|
valueAt.mView.setAlpha(f);
|
|
}
|
|
if (z3) {
|
|
valueAt.mPostponedAlpha = 0.0f;
|
|
} else {
|
|
valueAt.mPostponedAlpha = -1.0f;
|
|
valueAt.mIsNewlyAdded = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void a(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2, int i, int i2) {
|
|
while (i < i2) {
|
|
BackStackRecord backStackRecord = arrayList.get(i);
|
|
if (arrayList2.get(i).booleanValue()) {
|
|
backStackRecord.a(-1);
|
|
backStackRecord.b(i == i2 + (-1));
|
|
} else {
|
|
backStackRecord.a(1);
|
|
backStackRecord.e();
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
private void a(ArraySet<Fragment> arraySet) {
|
|
int i = this.l;
|
|
if (i < 1) {
|
|
return;
|
|
}
|
|
int min = Math.min(i, 3);
|
|
int size = this.d.size();
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
Fragment fragment = this.d.get(i2);
|
|
if (fragment.mState < min) {
|
|
a(fragment, min, fragment.getNextAnim(), fragment.getNextTransition(), false);
|
|
if (fragment.mView != null && !fragment.mHidden && fragment.mIsNewlyAdded) {
|
|
arraySet.add(fragment);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void a(BackStackRecord backStackRecord) {
|
|
if (this.f == null) {
|
|
this.f = new ArrayList<>();
|
|
}
|
|
this.f.add(backStackRecord);
|
|
}
|
|
|
|
boolean a(ArrayList<BackStackRecord> arrayList, ArrayList<Boolean> arrayList2, String str, int i, int i2) {
|
|
int size;
|
|
ArrayList<BackStackRecord> arrayList3 = this.f;
|
|
if (arrayList3 == null) {
|
|
return false;
|
|
}
|
|
if (str == null && i < 0 && (i2 & 1) == 0) {
|
|
int size2 = arrayList3.size() - 1;
|
|
if (size2 < 0) {
|
|
return false;
|
|
}
|
|
arrayList.add(this.f.remove(size2));
|
|
arrayList2.add(true);
|
|
} else {
|
|
if (str != null || i >= 0) {
|
|
size = this.f.size() - 1;
|
|
while (size >= 0) {
|
|
BackStackRecord backStackRecord = this.f.get(size);
|
|
if ((str != null && str.equals(backStackRecord.f())) || (i >= 0 && i == backStackRecord.m)) {
|
|
break;
|
|
}
|
|
size--;
|
|
}
|
|
if (size < 0) {
|
|
return false;
|
|
}
|
|
if ((i2 & 1) != 0) {
|
|
while (true) {
|
|
size--;
|
|
if (size < 0) {
|
|
break;
|
|
}
|
|
BackStackRecord backStackRecord2 = this.f.get(size);
|
|
if (str == null || !str.equals(backStackRecord2.f())) {
|
|
if (i < 0 || i != backStackRecord2.m) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
size = -1;
|
|
}
|
|
if (size == this.f.size() - 1) {
|
|
return false;
|
|
}
|
|
for (int size3 = this.f.size() - 1; size3 > size; size3--) {
|
|
arrayList.add(this.f.remove(size3));
|
|
arrayList2.add(true);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private static void a(FragmentManagerNonConfig fragmentManagerNonConfig) {
|
|
if (fragmentManagerNonConfig == null) {
|
|
return;
|
|
}
|
|
List<Fragment> b = fragmentManagerNonConfig.b();
|
|
if (b != null) {
|
|
Iterator<Fragment> it = b.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().mRetaining = true;
|
|
}
|
|
}
|
|
List<FragmentManagerNonConfig> a = fragmentManagerNonConfig.a();
|
|
if (a != null) {
|
|
Iterator<FragmentManagerNonConfig> it2 = a.iterator();
|
|
while (it2.hasNext()) {
|
|
a(it2.next());
|
|
}
|
|
}
|
|
}
|
|
|
|
void a(Parcelable parcelable, FragmentManagerNonConfig fragmentManagerNonConfig) {
|
|
List<FragmentManagerNonConfig> list;
|
|
List<ViewModelStore> list2;
|
|
if (parcelable == null) {
|
|
return;
|
|
}
|
|
FragmentManagerState fragmentManagerState = (FragmentManagerState) parcelable;
|
|
if (fragmentManagerState.mActive == null) {
|
|
return;
|
|
}
|
|
if (fragmentManagerNonConfig != null) {
|
|
List<Fragment> b = fragmentManagerNonConfig.b();
|
|
list = fragmentManagerNonConfig.a();
|
|
list2 = fragmentManagerNonConfig.c();
|
|
int size = b != null ? b.size() : 0;
|
|
for (int i = 0; i < size; i++) {
|
|
Fragment fragment = b.get(i);
|
|
if (F) {
|
|
Log.v("FragmentManager", "restoreAllState: re-attaching retained " + fragment);
|
|
}
|
|
int i2 = 0;
|
|
while (true) {
|
|
FragmentState[] fragmentStateArr = fragmentManagerState.mActive;
|
|
if (i2 >= fragmentStateArr.length || fragmentStateArr[i2].mIndex == fragment.mIndex) {
|
|
break;
|
|
} else {
|
|
i2++;
|
|
}
|
|
}
|
|
FragmentState[] fragmentStateArr2 = fragmentManagerState.mActive;
|
|
if (i2 != fragmentStateArr2.length) {
|
|
FragmentState fragmentState = fragmentStateArr2[i2];
|
|
fragmentState.mInstance = fragment;
|
|
fragment.mSavedViewState = null;
|
|
fragment.mBackStackNesting = 0;
|
|
fragment.mInLayout = false;
|
|
fragment.mAdded = false;
|
|
fragment.mTarget = null;
|
|
Bundle bundle = fragmentState.mSavedFragmentState;
|
|
if (bundle != null) {
|
|
bundle.setClassLoader(this.m.c().getClassLoader());
|
|
fragment.mSavedViewState = fragmentState.mSavedFragmentState.getSparseParcelableArray("android:view_state");
|
|
fragment.mSavedFragmentState = fragmentState.mSavedFragmentState;
|
|
}
|
|
} else {
|
|
a(new IllegalStateException("Could not find active fragment with index " + fragment.mIndex));
|
|
throw null;
|
|
}
|
|
}
|
|
} else {
|
|
list = null;
|
|
list2 = null;
|
|
}
|
|
this.e = new SparseArray<>(fragmentManagerState.mActive.length);
|
|
int i3 = 0;
|
|
while (true) {
|
|
FragmentState[] fragmentStateArr3 = fragmentManagerState.mActive;
|
|
if (i3 >= fragmentStateArr3.length) {
|
|
break;
|
|
}
|
|
FragmentState fragmentState2 = fragmentStateArr3[i3];
|
|
if (fragmentState2 != null) {
|
|
Fragment instantiate = fragmentState2.instantiate(this.m, this.n, this.o, (list == null || i3 >= list.size()) ? null : list.get(i3), (list2 == null || i3 >= list2.size()) ? null : list2.get(i3));
|
|
if (F) {
|
|
Log.v("FragmentManager", "restoreAllState: active #" + i3 + ": " + instantiate);
|
|
}
|
|
this.e.put(instantiate.mIndex, instantiate);
|
|
fragmentState2.mInstance = null;
|
|
}
|
|
i3++;
|
|
}
|
|
if (fragmentManagerNonConfig != null) {
|
|
List<Fragment> b2 = fragmentManagerNonConfig.b();
|
|
int size2 = b2 != null ? b2.size() : 0;
|
|
for (int i4 = 0; i4 < size2; i4++) {
|
|
Fragment fragment2 = b2.get(i4);
|
|
int i5 = fragment2.mTargetIndex;
|
|
if (i5 >= 0) {
|
|
fragment2.mTarget = this.e.get(i5);
|
|
if (fragment2.mTarget == null) {
|
|
Log.w("FragmentManager", "Re-attaching retained fragment " + fragment2 + " target no longer exists: " + fragment2.mTargetIndex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.d.clear();
|
|
if (fragmentManagerState.mAdded != null) {
|
|
int i6 = 0;
|
|
while (true) {
|
|
int[] iArr = fragmentManagerState.mAdded;
|
|
if (i6 >= iArr.length) {
|
|
break;
|
|
}
|
|
Fragment fragment3 = this.e.get(iArr[i6]);
|
|
if (fragment3 != null) {
|
|
fragment3.mAdded = true;
|
|
if (F) {
|
|
Log.v("FragmentManager", "restoreAllState: added #" + i6 + ": " + fragment3);
|
|
}
|
|
if (!this.d.contains(fragment3)) {
|
|
synchronized (this.d) {
|
|
this.d.add(fragment3);
|
|
}
|
|
i6++;
|
|
} else {
|
|
throw new IllegalStateException("Already added!");
|
|
}
|
|
} else {
|
|
a(new IllegalStateException("No instantiated fragment for index #" + fragmentManagerState.mAdded[i6]));
|
|
throw null;
|
|
}
|
|
}
|
|
}
|
|
BackStackState[] backStackStateArr = fragmentManagerState.mBackStack;
|
|
if (backStackStateArr != null) {
|
|
this.f = new ArrayList<>(backStackStateArr.length);
|
|
int i7 = 0;
|
|
while (true) {
|
|
BackStackState[] backStackStateArr2 = fragmentManagerState.mBackStack;
|
|
if (i7 >= backStackStateArr2.length) {
|
|
break;
|
|
}
|
|
BackStackRecord instantiate2 = backStackStateArr2[i7].instantiate(this);
|
|
if (F) {
|
|
Log.v("FragmentManager", "restoreAllState: back stack #" + i7 + " (index " + instantiate2.m + "): " + instantiate2);
|
|
PrintWriter printWriter = new PrintWriter(new LogWriter("FragmentManager"));
|
|
instantiate2.a(" ", printWriter, false);
|
|
printWriter.close();
|
|
}
|
|
this.f.add(instantiate2);
|
|
int i8 = instantiate2.m;
|
|
if (i8 >= 0) {
|
|
a(i8, instantiate2);
|
|
}
|
|
i7++;
|
|
}
|
|
} else {
|
|
this.f = null;
|
|
}
|
|
int i9 = fragmentManagerState.mPrimaryNavActiveIndex;
|
|
if (i9 >= 0) {
|
|
this.p = this.e.get(i9);
|
|
}
|
|
this.c = fragmentManagerState.mNextFragmentIndex;
|
|
}
|
|
|
|
public void a(FragmentHostCallback fragmentHostCallback, FragmentContainer fragmentContainer, Fragment fragment) {
|
|
if (this.m == null) {
|
|
this.m = fragmentHostCallback;
|
|
this.n = fragmentContainer;
|
|
this.o = fragment;
|
|
return;
|
|
}
|
|
throw new IllegalStateException("Already attached");
|
|
}
|
|
|
|
public void a(boolean z) {
|
|
for (int size = this.d.size() - 1; size >= 0; size--) {
|
|
Fragment fragment = this.d.get(size);
|
|
if (fragment != null) {
|
|
fragment.performMultiWindowModeChanged(z);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void a(Configuration configuration) {
|
|
for (int i = 0; i < this.d.size(); i++) {
|
|
Fragment fragment = this.d.get(i);
|
|
if (fragment != null) {
|
|
fragment.performConfigurationChanged(configuration);
|
|
}
|
|
}
|
|
}
|
|
|
|
public boolean a(Menu menu, MenuInflater menuInflater) {
|
|
if (this.l < 1) {
|
|
return false;
|
|
}
|
|
ArrayList<Fragment> arrayList = null;
|
|
boolean z = false;
|
|
for (int i = 0; i < this.d.size(); i++) {
|
|
Fragment fragment = this.d.get(i);
|
|
if (fragment != null && fragment.performCreateOptionsMenu(menu, menuInflater)) {
|
|
if (arrayList == null) {
|
|
arrayList = new ArrayList<>();
|
|
}
|
|
arrayList.add(fragment);
|
|
z = true;
|
|
}
|
|
}
|
|
if (this.g != null) {
|
|
for (int i2 = 0; i2 < this.g.size(); i2++) {
|
|
Fragment fragment2 = this.g.get(i2);
|
|
if (arrayList == null || !arrayList.contains(fragment2)) {
|
|
fragment2.onDestroyOptionsMenu();
|
|
}
|
|
}
|
|
}
|
|
this.g = arrayList;
|
|
return z;
|
|
}
|
|
|
|
public boolean a(MenuItem menuItem) {
|
|
if (this.l < 1) {
|
|
return false;
|
|
}
|
|
for (int i = 0; i < this.d.size(); i++) {
|
|
Fragment fragment = this.d.get(i);
|
|
if (fragment != null && fragment.performContextItemSelected(menuItem)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public void a(Menu menu) {
|
|
if (this.l < 1) {
|
|
return;
|
|
}
|
|
for (int i = 0; i < this.d.size(); i++) {
|
|
Fragment fragment = this.d.get(i);
|
|
if (fragment != null) {
|
|
fragment.performOptionsMenuClosed(menu);
|
|
}
|
|
}
|
|
}
|
|
|
|
void a(Fragment fragment, Context context, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).a(fragment, context, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.a(this, fragment, context);
|
|
}
|
|
}
|
|
}
|
|
|
|
void a(Fragment fragment, Bundle bundle, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).a(fragment, bundle, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.a(this, fragment, bundle);
|
|
}
|
|
}
|
|
}
|
|
|
|
void a(Fragment fragment, View view, Bundle bundle, boolean z) {
|
|
Fragment fragment2 = this.o;
|
|
if (fragment2 != null) {
|
|
FragmentManager fragmentManager = fragment2.getFragmentManager();
|
|
if (fragmentManager instanceof FragmentManagerImpl) {
|
|
((FragmentManagerImpl) fragmentManager).a(fragment, view, bundle, true);
|
|
}
|
|
}
|
|
Iterator<FragmentLifecycleCallbacksHolder> it = this.k.iterator();
|
|
while (it.hasNext()) {
|
|
FragmentLifecycleCallbacksHolder next = it.next();
|
|
if (!z || next.b) {
|
|
next.a.a(this, fragment, view, bundle);
|
|
}
|
|
}
|
|
}
|
|
}
|