public FragmentTransaction show(Fragment fragment) { Op op = new Op(); op.cmd = 5; op.fragment = fragment; addOp(op); return this; }
private void doAddOp(int i, Fragment fragment, String s, int j) { fragment.mFragmentManager = mManager; if (s != null) { if (fragment.mTag != null && !s.equals(fragment.mTag)) throw new IllegalStateException( (new StringBuilder()) .append("Can't change tag of fragment ") .append(fragment) .append(": was ") .append(fragment.mTag) .append(" now ") .append(s) .toString()); fragment.mTag = s; } if (i != 0) { if (fragment.mFragmentId != 0 && fragment.mFragmentId != i) throw new IllegalStateException( (new StringBuilder()) .append("Can't change container ID of fragment ") .append(fragment) .append(": was ") .append(fragment.mFragmentId) .append(" now ") .append(i) .toString()); fragment.mFragmentId = i; fragment.mContainerId = i; } Op op = new Op(); op.cmd = j; op.fragment = fragment; addOp(op); }
public FragmentTransaction remove(Fragment fragment) { Op op = new Op(); op.cmd = 3; op.fragment = fragment; addOp(op); return this; }
public FragmentTransaction detach(Fragment fragment) { Op op = new Op(); op.cmd = 6; op.fragment = fragment; addOp(op); return this; }
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); }