content: package androidx.fragment.app;
  
  import android.os.Bundle;
  import android.os.Parcelable;
  import android.util.Log;
  import android.view.View;
  import android.view.ViewGroup;
  import androidx.fragment.app.Fragment;
  import androidx.lifecycle.Lifecycle;
  import androidx.viewpager.widget.PagerAdapter;
  import java.util.ArrayList;
  
  @Deprecated
  public abstract class FragmentStatePagerAdapter extends PagerAdapter {
      public static final int BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT = 1;
      @Deprecated
      public static final int BEHAVIOR_SET_USER_VISIBLE_HINT = 0;
      private static final boolean DEBUG = false;
      private static final String TAG = "FragmentStatePagerAdapt";
      private final int mBehavior;
      private FragmentTransaction mCurTransaction;
      private Fragment mCurrentPrimaryItem;
      private boolean mExecutingFinishUpdate;
      private final FragmentManager mFragmentManager;
      private ArrayList<Fragment> mFragments;
      private ArrayList<Fragment.SavedState> mSavedState;
  
      @Deprecated
      public FragmentStatePagerAdapter(FragmentManager fm) {
          this(fm, 0);
      }
  
      public FragmentStatePagerAdapter(FragmentManager fm, int behavior) {
          this.mCurTransaction = null;
          this.mSavedState = new ArrayList<>();
          this.mFragments = new ArrayList<>();
          this.mCurrentPrimaryItem = null;
          this.mFragmentManager = fm;
          this.mBehavior = behavior;
      }
  
      public void destroyItem(ViewGroup container, int position, Object object) {
          Fragment fragment = (Fragment) object;
          if (this.mCurTransaction == null) {
              this.mCurTransaction = this.mFragmentManager.beginTransaction();
          }
          while (this.mSavedState.size() <= position) {
              this.mSavedState.add((Object) null);
          }
          this.mSavedState.set(position, fragment.isAdded() ? this.mFragmentManager.saveFragmentInstanceState(fragment) : null);
          this.mFragments.set(position, (Object) null);
          this.mCurTransaction.remove(fragment);
          if (fragment.equals(this.mCurrentPrimaryItem)) {
              this.mCurrentPrimaryItem = null;
          }
      }
  
      /* JADX INFO: finally extract failed */
      public void finishUpdate(ViewGroup container) {
          FragmentTransaction fragmentTransaction = this.mCurTransaction;
          if (fragmentTransaction != null) {
              if (!this.mExecutingFinishUpdate) {
                  try {
                      this.mExecutingFinishUpdate = true;
                      fragmentTransaction.commitNowAllowingStateLoss();
                      this.mExecutingFinishUpdate = false;
                  } catch (Throwable th) {
                      this.mExecutingFinishUpdate = false;
                      throw th;
                  }
              }
              this.mCurTransaction = null;
          }
      }
  
      public abstract Fragment getItem(int i);
  
      public Object instantiateItem(ViewGroup container, int position) {
          Fragment.SavedState savedState;
          Fragment fragment;
          if (this.mFragments.size() > position && (fragment = this.mFragments.get(position)) != null) {
              return fragment;
          }
          if (this.mCurTransaction == null) {
              this.mCurTransaction = this.mFragmentManager.beginTransaction();
          }
          Fragment item = getItem(position);
          if (this.mSavedState.size() > position && (savedState = this.mSavedState.get(position)) != null) {
              item.setInitialSavedState(savedState);
          }
          while (this.mFragments.size() <= position) {
              this.mFragments.add((Object) null);
          }
          item.setMenuVisibility(false);
          if (this.mBehavior == 0) {
              item.setUserVisibleHint(false);
          }
          this.mFragments.set(position, item);
          this.mCurTransaction.add(container.getId(), item);
          if (this.mBehavior == 1) {
              this.mCurTransaction.setMaxLifecycle(item, Lifecycle.State.STARTED);
          }
          return item;
      }
  
      public boolean isViewFromObject(View view, Object object) {
          return ((Fragment) object).getView() == view;
      }
  
      public void restoreState(Parcelable state, ClassLoader loader) {
          if (state != null) {
              Bundle bundle = (Bundle) state;
              bundle.setClassLoader(loader);
              Parcelable[] parcelableArray = bundle.getParcelableArray("states");
              this.mSavedState.clear();
              this.mFragments.clear();
              if (parcelableArray != null) {
                  for (Parcelable parcelable : parcelableArray) {
                      this.mSavedState.add((Fragment.SavedState) parcelable);
                  }
              }
              for (String str : bundle.keySet()) {
                  if (str.startsWith("f")) {
                      int parseInt = Integer.parseInt(str.substring(1));
                      Fragment fragment = this.mFragmentManager.getFragment(bundle, str);
                      if (fragment != null) {
                          while (this.mFragments.size() <= parseInt) {
                              this.mFragments.add((Object) null);
                          }
                          fragment.setMenuVisibility(false);
                          this.mFragments.set(parseInt, fragment);
                      } else {
                          Log.w(TAG, "Bad fragment at key " + str);
                      }
                  }
              }
          }
      }
  
      public Parcelable saveState() {
          Bundle bundle = null;
          if (this.mSavedState.size() > 0) {
              bundle = new Bundle();
              Fragment.SavedState[] savedStateArr = new Fragment.SavedState[this.mSavedState.size()];
              this.mSavedState.toArray(savedStateArr);
              bundle.putParcelableArray("states", savedStateArr);
          }
          for (int i = 0; i < this.mFragments.size(); i++) {
              Fragment fragment = this.mFragments.get(i);
              if (fragment != null && fragment.isAdded()) {
                  if (bundle == null) {
                      bundle = new Bundle();
                  }
                  this.mFragmentManager.putFragment(bundle, "f" + i, fragment);
              }
          }
          return bundle;
      }
  
      public void setPrimaryItem(ViewGroup container, int position, Object object) {
          Fragment fragment = (Fragment) object;
          Fragment fragment2 = this.mCurrentPrimaryItem;
          if (fragment != fragment2) {
              if (fragment2 != null) {
                  fragment2.setMenuVisibility(false);
                  if (this.mBehavior == 1) {
                      if (this.mCurTransaction == null) {
                          this.mCurTransaction = this.mFragmentManager.beginTransaction();
                      }
                      this.mCurTransaction.setMaxLifecycle(this.mCurrentPrimaryItem, Lifecycle.State.STARTED);
                  } else {
                      this.mCurrentPrimaryItem.setUserVisibleHint(false);
                  }
              }
              fragment.setMenuVisibility(true);
              if (this.mBehavior == 1) {
                  if (this.mCurTransaction == null) {
                      this.mCurTransaction = this.mFragmentManager.beginTransaction();
                  }
                  this.mCurTransaction.setMaxLifecycle(fragment, Lifecycle.State.RESUMED);
              } else {
                  fragment.setUserVisibleHint(true);
              }
              this.mCurrentPrimaryItem = fragment;
          }
      }
  
      public void startUpdate(ViewGroup container) {
          if (container.getId() == -1) {
              throw new IllegalStateException("ViewPager with adapter " + this + " requires a view id");
          }
      }
  }
  