Skip to content

Commit

Permalink
Fragment animations are not being saved across configuration changes
Browse files Browse the repository at this point in the history
As per comment SlimRoms#5 in issue #25994:

The problem here is not that the state isn't saved and restored, the problem is how the BackStackRecord is rebuilt.  The ops themselves do save and restore the state, the problem is in BackStackRecord#addOp.

    void addOp(Op op) {
        if (mHead == null) {
            mHead = mTail = op;
        } else {
            op.prev = mTail;
            mTail.next = op;
            mTail = op;
        }
        op.enterAnim = mEnterAnim;
        op.exitAnim = mExitAnim;
        op.popEnterAnim = mPopEnterAnim;
        op.popExitAnim = mPopExitAnim;
        mNumOp++;
    }

The enter, exit, popEnter and popExit animations are overwritten with whatever is currently in the record, which during the restoration process these are 0 so the values which were saved in the ops is lost.

Change-Id: I095cc7ff4ae65581d728f34217fb873ad2f0c574
  • Loading branch information
alexander-mironov authored and SeniorLimpio committed Aug 3, 2014
1 parent 5f19d2e commit 3fedc28
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/java/android/app/BackStackRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ public BackStackRecord instantiate(FragmentManagerImpl fm) {
} else {
op.fragment = null;
}
op.enterAnim = mOps[pos++];
op.exitAnim = mOps[pos++];
op.popEnterAnim = mOps[pos++];
op.popExitAnim = mOps[pos++];
bse.mEnterAnim = mOps[pos++];
bse.mExitAnim = mOps[pos++];
bse.mPopEnterAnim = mOps[pos++];
bse.mPopExitAnim = mOps[pos++];
final int N = mOps[pos++];
if (N > 0) {
op.removed = new ArrayList<Fragment>(N);
Expand Down

0 comments on commit 3fedc28

Please sign in to comment.