public void run() {
    label0:
    {
      if (FragmentManagerImpl.DEBUG)
        Log.v("FragmentManager", (new StringBuilder()).append("Run: ").append(this).toString());
      if (mAddToBackStack && mIndex < 0)
        throw new IllegalStateException("addToBackStack() called after commit()");
      bumpBackStackNesting(1);
      Op op = mHead;
      label1:
      do {
        if (op == null) break label0;
        switch (op.cmd) {
          default:
            break label1;

          case 7: // '\007'
            Fragment fragment7 = op.fragment;
            fragment7.mNextAnim = op.enterAnim;
            mManager.attachFragment(fragment7, mTransition, mTransitionStyle);
            break;

          case 6: // '\006'
            Fragment fragment6 = op.fragment;
            fragment6.mNextAnim = op.exitAnim;
            mManager.detachFragment(fragment6, mTransition, mTransitionStyle);
            break;

          case 5: // '\005'
            Fragment fragment5 = op.fragment;
            fragment5.mNextAnim = op.enterAnim;
            mManager.showFragment(fragment5, mTransition, mTransitionStyle);
            break;

          case 4: // '\004'
            Fragment fragment4 = op.fragment;
            fragment4.mNextAnim = op.exitAnim;
            mManager.hideFragment(fragment4, mTransition, mTransitionStyle);
            break;

          case 3: // '\003'
            Fragment fragment3 = op.fragment;
            fragment3.mNextAnim = op.exitAnim;
            mManager.removeFragment(fragment3, mTransition, mTransitionStyle);
            break;

          case 2: // '\002'
            Fragment fragment1 = op.fragment;
            if (mManager.mAdded != null) {
              for (int i = 0; i < mManager.mAdded.size(); i++) {
                Fragment fragment2 = (Fragment) mManager.mAdded.get(i);
                if (FragmentManagerImpl.DEBUG)
                  Log.v(
                      "FragmentManager",
                      (new StringBuilder())
                          .append("OP_REPLACE: adding=")
                          .append(fragment1)
                          .append(" old=")
                          .append(fragment2)
                          .toString());
                if (fragment1 != null && fragment2.mContainerId != fragment1.mContainerId) continue;
                if (fragment2 == fragment1) {
                  fragment1 = null;
                  op.fragment = null;
                  continue;
                }
                if (op.removed == null) op.removed = new ArrayList();
                op.removed.add(fragment2);
                fragment2.mNextAnim = op.exitAnim;
                if (mAddToBackStack) {
                  fragment2.mBackStackNesting = 1 + fragment2.mBackStackNesting;
                  if (FragmentManagerImpl.DEBUG)
                    Log.v(
                        "FragmentManager",
                        (new StringBuilder())
                            .append("Bump nesting of ")
                            .append(fragment2)
                            .append(" to ")
                            .append(fragment2.mBackStackNesting)
                            .toString());
                }
                mManager.removeFragment(fragment2, mTransition, mTransitionStyle);
              }
            }
            if (fragment1 != null) {
              fragment1.mNextAnim = op.enterAnim;
              mManager.addFragment(fragment1, false);
            }
            break;

          case 1: // '\001'
            Fragment fragment = op.fragment;
            fragment.mNextAnim = op.enterAnim;
            mManager.addFragment(fragment, false);
            break;
        }
        op = op.next;
      } while (true);
      throw new IllegalArgumentException(
          (new StringBuilder()).append("Unknown cmd: ").append(op.cmd).toString());
    }
    mManager.moveToState(mManager.mCurState, mTransition, mTransitionStyle, true);
    if (mAddToBackStack) mManager.addBackStackState(this);
  }
示例#2
0
 public BackStackRecord instantiate(FragmentManagerImpl paramFragmentManagerImpl)
 {
   BackStackRecord localBackStackRecord = new BackStackRecord(paramFragmentManagerImpl);
   int i = 0;
   for (int j = 0; i < this.mOps.length; j++)
   {
     BackStackRecord.Op localOp = new BackStackRecord.Op();
     int[] arrayOfInt1 = this.mOps;
     int k = i + 1;
     localOp.cmd = arrayOfInt1[i];
     if (FragmentManagerImpl.DEBUG)
       Log.v("FragmentManager", "Instantiate " + localBackStackRecord + " op #" + j + " base fragment #" + this.mOps[k]);
     int[] arrayOfInt2 = this.mOps;
     int m = k + 1;
     int n = arrayOfInt2[k];
     if (n >= 0);
     int i5;
     for (localOp.fragment = ((Fragment)paramFragmentManagerImpl.mActive.get(n)); ; localOp.fragment = null)
     {
       int[] arrayOfInt3 = this.mOps;
       int i1 = m + 1;
       localOp.enterAnim = arrayOfInt3[m];
       int[] arrayOfInt4 = this.mOps;
       int i2 = i1 + 1;
       localOp.exitAnim = arrayOfInt4[i1];
       int[] arrayOfInt5 = this.mOps;
       int i3 = i2 + 1;
       localOp.popEnterAnim = arrayOfInt5[i2];
       int[] arrayOfInt6 = this.mOps;
       int i4 = i3 + 1;
       localOp.popExitAnim = arrayOfInt6[i3];
       int[] arrayOfInt7 = this.mOps;
       i5 = i4 + 1;
       int i6 = arrayOfInt7[i4];
       if (i6 <= 0)
         break;
       localOp.removed = new ArrayList(i6);
       int i7 = 0;
       while (i7 < i6)
       {
         if (FragmentManagerImpl.DEBUG)
           Log.v("FragmentManager", "Instantiate " + localBackStackRecord + " set remove fragment #" + this.mOps[i5]);
         ArrayList localArrayList = paramFragmentManagerImpl.mActive;
         int[] arrayOfInt8 = this.mOps;
         int i8 = i5 + 1;
         Fragment localFragment = (Fragment)localArrayList.get(arrayOfInt8[i5]);
         localOp.removed.add(localFragment);
         i7++;
         i5 = i8;
       }
     }
     i = i5;
     localBackStackRecord.addOp(localOp);
   }
   localBackStackRecord.mTransition = this.mTransition;
   localBackStackRecord.mTransitionStyle = this.mTransitionStyle;
   localBackStackRecord.mName = this.mName;
   localBackStackRecord.mIndex = this.mIndex;
   localBackStackRecord.mAddToBackStack = true;
   localBackStackRecord.mBreadCrumbTitleRes = this.mBreadCrumbTitleRes;
   localBackStackRecord.mBreadCrumbTitleText = this.mBreadCrumbTitleText;
   localBackStackRecord.mBreadCrumbShortTitleRes = this.mBreadCrumbShortTitleRes;
   localBackStackRecord.mBreadCrumbShortTitleText = this.mBreadCrumbShortTitleText;
   localBackStackRecord.bumpBackStackNesting(1);
   return localBackStackRecord;
 }
  public void popFromBackStack(boolean flag) {
    label0:
    {
      if (FragmentManagerImpl.DEBUG) {
        Log.v(
            "FragmentManager",
            (new StringBuilder()).append("popFromBackStack: ").append(this).toString());
        dump("  ", null, new PrintWriter(new LogWriter("FragmentManager")), null);
      }
      bumpBackStackNesting(-1);
      Op op = mTail;
      label1:
      do {
        if (op == null) break label0;
        switch (op.cmd) {
          default:
            break label1;

          case 7: // '\007'
            Fragment fragment7 = op.fragment;
            fragment7.mNextAnim = op.popEnterAnim;
            mManager.detachFragment(
                fragment7, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
            break;

          case 6: // '\006'
            Fragment fragment6 = op.fragment;
            fragment6.mNextAnim = op.popEnterAnim;
            mManager.attachFragment(
                fragment6, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
            break;

          case 5: // '\005'
            Fragment fragment5 = op.fragment;
            fragment5.mNextAnim = op.popExitAnim;
            mManager.hideFragment(
                fragment5, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
            break;

          case 4: // '\004'
            Fragment fragment4 = op.fragment;
            fragment4.mNextAnim = op.popEnterAnim;
            mManager.showFragment(
                fragment4, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
            break;

          case 3: // '\003'
            Fragment fragment3 = op.fragment;
            fragment3.mNextAnim = op.popEnterAnim;
            mManager.addFragment(fragment3, false);
            break;

          case 2: // '\002'
            Fragment fragment1 = op.fragment;
            if (fragment1 != null) {
              fragment1.mNextAnim = op.popExitAnim;
              mManager.removeFragment(
                  fragment1, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
            }
            if (op.removed == null) break;
            for (int i = 0; i < op.removed.size(); i++) {
              Fragment fragment2 = (Fragment) op.removed.get(i);
              fragment2.mNextAnim = op.popEnterAnim;
              mManager.addFragment(fragment2, false);
            }

            break;

          case 1: // '\001'
            Fragment fragment = op.fragment;
            fragment.mNextAnim = op.popExitAnim;
            mManager.removeFragment(
                fragment, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
            break;
        }
        op = op.prev;
      } while (true);
      throw new IllegalArgumentException(
          (new StringBuilder()).append("Unknown cmd: ").append(op.cmd).toString());
    }
    if (flag)
      mManager.moveToState(
          mManager.mCurState,
          FragmentManagerImpl.reverseTransit(mTransition),
          mTransitionStyle,
          true);
    if (mIndex >= 0) {
      mManager.freeBackStackIndex(mIndex);
      mIndex = -1;
    }
  }