From bd93e69c8e0b06fc0b0bbba4bdd9e426b37f98e1 Mon Sep 17 00:00:00 2001 From: George Mount Date: Wed, 8 Apr 2015 14:48:02 -0700 Subject: Allow delay of showing/hiding shared element when transferring. Bug 18932344 Change-Id: Ic967551a4dd27967d2312a6c6c8a83b34c220031 --- core/java/android/app/SharedElementCallback.java | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'core/java/android/app/SharedElementCallback.java') diff --git a/core/java/android/app/SharedElementCallback.java b/core/java/android/app/SharedElementCallback.java index 6ac2401..9c70f1d 100644 --- a/core/java/android/app/SharedElementCallback.java +++ b/core/java/android/app/SharedElementCallback.java @@ -221,4 +221,42 @@ public abstract class SharedElementCallback { } return view; } + + /** + * Called during an Activity Transition when the shared elements have arrived at the + * final location and are ready to be transferred. This method is called for both the + * source and destination Activities. + *

+ * When the shared elements are ready to be transferred, + * {@link OnSharedElementsReadyListener#onSharedElementsReady()} + * must be called to trigger the transfer. + *

+ * The default behavior is to trigger the transfer immediately. + * + * @param sharedElementNames The names of the shared elements that are being transferred.. + * @param sharedElements The shared elements that are part of the View hierarchy. + * @param listener The listener to call when the shared elements are ready to be hidden + * in the source Activity or shown in the destination Activity. + */ + public void onSharedElementsArrived(List sharedElementNames, + List sharedElements, OnSharedElementsReadyListener listener) { + listener.onSharedElementsReady(); + } + + /** + * Listener to be called after {@link + * SharedElementCallback#onSharedElementsArrived(OnSharedElementsReadyListener)} + * when the shared elements are ready to be hidden in the source Activity and shown in the + * destination Activity. + */ + public interface OnSharedElementsReadyListener { + + /** + * Call this method during or after the OnSharedElementsReadyListener has been received + * in {@link SharedElementCallback#onSharedElementsArrived(OnSharedElementsReadyListener)} + * to indicate that the shared elements are ready to be hidden in the source and shown + * in the destination Activity. + */ + void onSharedElementsReady(); + } } -- cgit v1.1