From 92692c0284c2249e9a5381f7f19ec97f6b76d12f Mon Sep 17 00:00:00 2001 From: George Mount Date: Mon, 1 Dec 2014 16:44:05 -0800 Subject: [PATCH] Keep snapshot order matching the shared elements. Bug 18578796 When no snapshot was created, we weren't adding anything to the snapshot list. When a snapshot is not created, we should add an null snapshot to the snapshot list to keep them in order. Change-Id: I522e485163229230037dcdd635b83cff800df28f --- core/java/android/app/ActivityTransitionCoordinator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/ActivityTransitionCoordinator.java b/core/java/android/app/ActivityTransitionCoordinator.java index 9062892efde9d..d0d9d7153eaf4 100644 --- a/core/java/android/app/ActivityTransitionCoordinator.java +++ b/core/java/android/app/ActivityTransitionCoordinator.java @@ -641,17 +641,18 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { Matrix tempMatrix = new Matrix(); for (String name: names) { Bundle sharedElementBundle = state.getBundle(name); + View snapshot = null; if (sharedElementBundle != null) { Parcelable parcelable = sharedElementBundle.getParcelable(KEY_SNAPSHOT); - View snapshot = null; if (parcelable != null && mListener != null) { snapshot = mListener.onCreateSnapshotView(context, parcelable); } if (snapshot != null) { setSharedElementState(snapshot, name, state, tempMatrix, null, decorLoc); } - snapshots.add(snapshot); } + // Even null snapshots are added so they remain in the same order as shared elements. + snapshots.add(snapshot); } return snapshots; }