Merge "DO NOT MERGE: Add custom fragment anims for popping backstack" into honeycomb-mr2
This commit is contained in:
@ -31483,6 +31483,25 @@
|
|||||||
<parameter name="exit" type="int">
|
<parameter name="exit" type="int">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="setCustomAnimations"
|
||||||
|
return="android.app.FragmentTransaction"
|
||||||
|
abstract="true"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="enter" type="int">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="exit" type="int">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="popEnter" type="int">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="popExit" type="int">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
<method name="setTransition"
|
<method name="setTransition"
|
||||||
return="android.app.FragmentTransaction"
|
return="android.app.FragmentTransaction"
|
||||||
abstract="true"
|
abstract="true"
|
||||||
|
@ -43,7 +43,7 @@ final class BackStackState implements Parcelable {
|
|||||||
if (op.removed != null) numRemoved += op.removed.size();
|
if (op.removed != null) numRemoved += op.removed.size();
|
||||||
op = op.next;
|
op = op.next;
|
||||||
}
|
}
|
||||||
mOps = new int[bse.mNumOp*5 + numRemoved];
|
mOps = new int[bse.mNumOp*7 + numRemoved];
|
||||||
|
|
||||||
if (!bse.mAddToBackStack) {
|
if (!bse.mAddToBackStack) {
|
||||||
throw new IllegalStateException("Not on back stack");
|
throw new IllegalStateException("Not on back stack");
|
||||||
@ -56,6 +56,8 @@ final class BackStackState implements Parcelable {
|
|||||||
mOps[pos++] = op.fragment.mIndex;
|
mOps[pos++] = op.fragment.mIndex;
|
||||||
mOps[pos++] = op.enterAnim;
|
mOps[pos++] = op.enterAnim;
|
||||||
mOps[pos++] = op.exitAnim;
|
mOps[pos++] = op.exitAnim;
|
||||||
|
mOps[pos++] = op.popEnterAnim;
|
||||||
|
mOps[pos++] = op.popExitAnim;
|
||||||
if (op.removed != null) {
|
if (op.removed != null) {
|
||||||
final int N = op.removed.size();
|
final int N = op.removed.size();
|
||||||
mOps[pos++] = N;
|
mOps[pos++] = N;
|
||||||
@ -101,6 +103,8 @@ final class BackStackState implements Parcelable {
|
|||||||
op.fragment = f;
|
op.fragment = f;
|
||||||
op.enterAnim = mOps[pos++];
|
op.enterAnim = mOps[pos++];
|
||||||
op.exitAnim = mOps[pos++];
|
op.exitAnim = mOps[pos++];
|
||||||
|
op.popEnterAnim = mOps[pos++];
|
||||||
|
op.popExitAnim = mOps[pos++];
|
||||||
final int N = mOps[pos++];
|
final int N = mOps[pos++];
|
||||||
if (N > 0) {
|
if (N > 0) {
|
||||||
op.removed = new ArrayList<Fragment>(N);
|
op.removed = new ArrayList<Fragment>(N);
|
||||||
@ -179,6 +183,8 @@ final class BackStackRecord extends FragmentTransaction implements
|
|||||||
Fragment fragment;
|
Fragment fragment;
|
||||||
int enterAnim;
|
int enterAnim;
|
||||||
int exitAnim;
|
int exitAnim;
|
||||||
|
int popEnterAnim;
|
||||||
|
int popExitAnim;
|
||||||
ArrayList<Fragment> removed;
|
ArrayList<Fragment> removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +193,8 @@ final class BackStackRecord extends FragmentTransaction implements
|
|||||||
int mNumOp;
|
int mNumOp;
|
||||||
int mEnterAnim;
|
int mEnterAnim;
|
||||||
int mExitAnim;
|
int mExitAnim;
|
||||||
|
int mPopEnterAnim;
|
||||||
|
int mPopExitAnim;
|
||||||
int mTransition;
|
int mTransition;
|
||||||
int mTransitionStyle;
|
int mTransitionStyle;
|
||||||
boolean mAddToBackStack;
|
boolean mAddToBackStack;
|
||||||
@ -243,6 +251,11 @@ final class BackStackRecord extends FragmentTransaction implements
|
|||||||
writer.print(prefix); writer.print("enterAnim="); writer.print(op.enterAnim);
|
writer.print(prefix); writer.print("enterAnim="); writer.print(op.enterAnim);
|
||||||
writer.print(" exitAnim="); writer.println(op.exitAnim);
|
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) {
|
if (op.removed != null && op.removed.size() > 0) {
|
||||||
for (int i=0; i<op.removed.size(); i++) {
|
for (int i=0; i<op.removed.size(); i++) {
|
||||||
writer.print(innerPrefix);
|
writer.print(innerPrefix);
|
||||||
@ -301,6 +314,8 @@ final class BackStackRecord extends FragmentTransaction implements
|
|||||||
}
|
}
|
||||||
op.enterAnim = mEnterAnim;
|
op.enterAnim = mEnterAnim;
|
||||||
op.exitAnim = mExitAnim;
|
op.exitAnim = mExitAnim;
|
||||||
|
op.popEnterAnim = mPopEnterAnim;
|
||||||
|
op.popExitAnim = mPopExitAnim;
|
||||||
mNumOp++;
|
mNumOp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,8 +445,15 @@ final class BackStackRecord extends FragmentTransaction implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FragmentTransaction setCustomAnimations(int enter, int exit) {
|
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;
|
mEnterAnim = enter;
|
||||||
mExitAnim = exit;
|
mExitAnim = exit;
|
||||||
|
mPopEnterAnim = popEnter;
|
||||||
|
mPopExitAnim = popExit;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,6 +653,7 @@ final class BackStackRecord extends FragmentTransaction implements
|
|||||||
switch (op.cmd) {
|
switch (op.cmd) {
|
||||||
case OP_ADD: {
|
case OP_ADD: {
|
||||||
Fragment f = op.fragment;
|
Fragment f = op.fragment;
|
||||||
|
f.mNextAnim = op.popExitAnim;
|
||||||
f.mImmediateActivity = null;
|
f.mImmediateActivity = null;
|
||||||
mManager.removeFragment(f,
|
mManager.removeFragment(f,
|
||||||
FragmentManagerImpl.reverseTransit(mTransition),
|
FragmentManagerImpl.reverseTransit(mTransition),
|
||||||
@ -638,6 +661,7 @@ final class BackStackRecord extends FragmentTransaction implements
|
|||||||
} break;
|
} break;
|
||||||
case OP_REPLACE: {
|
case OP_REPLACE: {
|
||||||
Fragment f = op.fragment;
|
Fragment f = op.fragment;
|
||||||
|
f.mNextAnim = op.popExitAnim;
|
||||||
f.mImmediateActivity = null;
|
f.mImmediateActivity = null;
|
||||||
mManager.removeFragment(f,
|
mManager.removeFragment(f,
|
||||||
FragmentManagerImpl.reverseTransit(mTransition),
|
FragmentManagerImpl.reverseTransit(mTransition),
|
||||||
@ -645,6 +669,7 @@ final class BackStackRecord extends FragmentTransaction implements
|
|||||||
if (op.removed != null) {
|
if (op.removed != null) {
|
||||||
for (int i=0; i<op.removed.size(); i++) {
|
for (int i=0; i<op.removed.size(); i++) {
|
||||||
Fragment old = op.removed.get(i);
|
Fragment old = op.removed.get(i);
|
||||||
|
old.mNextAnim = op.popEnterAnim;
|
||||||
f.mImmediateActivity = mManager.mActivity;
|
f.mImmediateActivity = mManager.mActivity;
|
||||||
mManager.addFragment(old, false);
|
mManager.addFragment(old, false);
|
||||||
}
|
}
|
||||||
@ -652,16 +677,19 @@ final class BackStackRecord extends FragmentTransaction implements
|
|||||||
} break;
|
} break;
|
||||||
case OP_REMOVE: {
|
case OP_REMOVE: {
|
||||||
Fragment f = op.fragment;
|
Fragment f = op.fragment;
|
||||||
|
f.mNextAnim = op.popEnterAnim;
|
||||||
f.mImmediateActivity = mManager.mActivity;
|
f.mImmediateActivity = mManager.mActivity;
|
||||||
mManager.addFragment(f, false);
|
mManager.addFragment(f, false);
|
||||||
} break;
|
} break;
|
||||||
case OP_HIDE: {
|
case OP_HIDE: {
|
||||||
Fragment f = op.fragment;
|
Fragment f = op.fragment;
|
||||||
|
f.mNextAnim = op.popEnterAnim;
|
||||||
mManager.showFragment(f,
|
mManager.showFragment(f,
|
||||||
FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
|
FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
|
||||||
} break;
|
} break;
|
||||||
case OP_SHOW: {
|
case OP_SHOW: {
|
||||||
Fragment f = op.fragment;
|
Fragment f = op.fragment;
|
||||||
|
f.mNextAnim = op.popExitAnim;
|
||||||
mManager.hideFragment(f,
|
mManager.hideFragment(f,
|
||||||
FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
|
FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
|
||||||
} break;
|
} break;
|
||||||
|
@ -141,10 +141,20 @@ public abstract class FragmentTransaction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set specific animation resources to run for the fragments that are
|
* 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);
|
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
|
* Select a standard transition animation for this transaction. May be
|
||||||
* one of {@link #TRANSIT_NONE}, {@link #TRANSIT_FRAGMENT_OPEN},
|
* one of {@link #TRANSIT_NONE}, {@link #TRANSIT_FRAGMENT_OPEN},
|
||||||
|
Reference in New Issue
Block a user