if (op.removed != null) numRemoved += op.removed.size();
op = op.next;
}
- mOps = new int[bse.mNumOp*5 + numRemoved];
+ mOps = new int[bse.mNumOp*7 + numRemoved];
if (!bse.mAddToBackStack) {
throw new IllegalStateException("Not on back stack");
mOps[pos++] = op.fragment.mIndex;
mOps[pos++] = op.enterAnim;
mOps[pos++] = op.exitAnim;
+ mOps[pos++] = op.popEnterAnim;
+ mOps[pos++] = op.popExitAnim;
if (op.removed != null) {
final int N = op.removed.size();
mOps[pos++] = N;
op.fragment = f;
op.enterAnim = mOps[pos++];
op.exitAnim = mOps[pos++];
+ op.popEnterAnim = mOps[pos++];
+ op.popExitAnim = mOps[pos++];
final int N = mOps[pos++];
if (N > 0) {
op.removed = new ArrayList<Fragment>(N);
Fragment fragment;
int enterAnim;
int exitAnim;
+ int popEnterAnim;
+ int popExitAnim;
ArrayList<Fragment> removed;
}
int mNumOp;
int mEnterAnim;
int mExitAnim;
+ int mPopEnterAnim;
+ int mPopExitAnim;
int mTransition;
int mTransitionStyle;
boolean mAddToBackStack;
writer.print(prefix); writer.print("enterAnim="); writer.print(op.enterAnim);
writer.print(" exitAnim="); writer.println(op.exitAnim);
}
+ if (op.popEnterAnim != 0 || op.popExitAnim != 0) {
+ writer.print(prefix);
+ writer.print("popEnterAnim="); writer.print(op.popEnterAnim);
+ writer.print(" popExitAnim="); writer.println(op.popExitAnim);
+ }
if (op.removed != null && op.removed.size() > 0) {
for (int i=0; i<op.removed.size(); i++) {
writer.print(innerPrefix);
}
op.enterAnim = mEnterAnim;
op.exitAnim = mExitAnim;
+ op.popEnterAnim = mPopEnterAnim;
+ op.popExitAnim = mPopExitAnim;
mNumOp++;
}
}
public FragmentTransaction setCustomAnimations(int enter, int exit) {
+ return setCustomAnimations(enter, exit, 0, 0);
+ }
+
+ public FragmentTransaction setCustomAnimations(int enter, int exit,
+ int popEnter, int popExit) {
mEnterAnim = enter;
mExitAnim = exit;
+ mPopEnterAnim = popEnter;
+ mPopExitAnim = popExit;
return this;
}
switch (op.cmd) {
case OP_ADD: {
Fragment f = op.fragment;
+ f.mNextAnim = op.popExitAnim;
f.mImmediateActivity = null;
mManager.removeFragment(f,
FragmentManagerImpl.reverseTransit(mTransition),
} break;
case OP_REPLACE: {
Fragment f = op.fragment;
+ f.mNextAnim = op.popExitAnim;
f.mImmediateActivity = null;
mManager.removeFragment(f,
FragmentManagerImpl.reverseTransit(mTransition),
if (op.removed != null) {
for (int i=0; i<op.removed.size(); i++) {
Fragment old = op.removed.get(i);
+ old.mNextAnim = op.popEnterAnim;
f.mImmediateActivity = mManager.mActivity;
mManager.addFragment(old, false);
}
} break;
case OP_REMOVE: {
Fragment f = op.fragment;
+ f.mNextAnim = op.popEnterAnim;
f.mImmediateActivity = mManager.mActivity;
mManager.addFragment(f, false);
} break;
case OP_HIDE: {
Fragment f = op.fragment;
+ f.mNextAnim = op.popEnterAnim;
mManager.showFragment(f,
FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
} break;
case OP_SHOW: {
Fragment f = op.fragment;
+ f.mNextAnim = op.popExitAnim;
mManager.hideFragment(f,
FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
} break;
/**
* Set specific animation resources to run for the fragments that are
- * entering and exiting in this transaction.
+ * entering and exiting in this transaction. These animations will not be
+ * played when popping the back stack.
*/
public abstract FragmentTransaction setCustomAnimations(int enter, int exit);
-
+
+ /**
+ * Set specific animation resources to run for the fragments that are
+ * entering and exiting in this transaction. The <code>popEnter</code>
+ * and <code>popExit</code> animations will be played for enter/exit
+ * operations specifically when popping the back stack.
+ */
+ public abstract FragmentTransaction setCustomAnimations(int enter, int exit,
+ int popEnter, int popExit);
+
/**
* Select a standard transition animation for this transaction. May be
* one of {@link #TRANSIT_NONE}, {@link #TRANSIT_FRAGMENT_OPEN},