From 19e748a3d1702f911476e103b590a36adefb83ca Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Tue, 22 Mar 2011 11:35:22 -0700 Subject: [PATCH] DO NOT MERGE: Add custom fragment anims for popping backstack The previous fragment implementation allowed for animations during fragment transitions, but did not account for the different behavior of fragments when popping the back stack. In general, you probably don't want to run the same animation for putting a fragment on the stack as for popping it off, which is what happens now. For example, you might fade a fragment out when putting it on the stack. But when popping ot off, fading it out is probably not the behavior you want. The new API (setCustomAnimations() overload with two additional parameters) allows developers to specify animations to be run in the popping operation. Otherwise, the animations are null and the operation will not be animated. Change-Id: I53bbc6e6ec4e953b7ecdd99e2452d81857917de2 --- api/current.xml | 19 ++++++++++++ core/java/android/app/BackStackRecord.java | 30 ++++++++++++++++++- .../java/android/app/FragmentTransaction.java | 14 +++++++-- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/api/current.xml b/api/current.xml index e669a990973ca..3a642f6425a86 100644 --- a/api/current.xml +++ b/api/current.xml @@ -31483,6 +31483,25 @@ + + + + + + + + + + 0) { op.removed = new ArrayList(N); @@ -179,6 +183,8 @@ final class BackStackRecord extends FragmentTransaction implements Fragment fragment; int enterAnim; int exitAnim; + int popEnterAnim; + int popExitAnim; ArrayList removed; } @@ -187,6 +193,8 @@ final class BackStackRecord extends FragmentTransaction implements int mNumOp; int mEnterAnim; int mExitAnim; + int mPopEnterAnim; + int mPopExitAnim; int mTransition; int mTransitionStyle; boolean mAddToBackStack; @@ -243,6 +251,11 @@ final class BackStackRecord extends FragmentTransaction implements 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; ipopEnter + * and popExit 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},