/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Parcelable; import android.transition.TransitionUtils; import android.view.View; import android.widget.ImageView; import android.widget.ImageView.ScaleType; import java.util.List; import java.util.Map; /** * Listener provided in * {@link Activity#setEnterSharedElementCallback(SharedElementCallback)} and * {@link Activity#setExitSharedElementCallback(SharedElementCallback)} as well as * {@link Fragment#setEnterSharedElementCallback(SharedElementCallback)} and * {@link Fragment#setExitSharedElementCallback(SharedElementCallback)} * to monitor the Shared element transitions. The events can be used to customize Activity * and Fragment Transition behavior. */ public abstract class SharedElementCallback { private Matrix mTempMatrix; private static final String BUNDLE_SNAPSHOT_BITMAP = "sharedElement:snapshot:bitmap"; private static final String BUNDLE_SNAPSHOT_IMAGE_SCALETYPE = "sharedElement:snapshot:imageScaleType"; private static final String BUNDLE_SNAPSHOT_IMAGE_MATRIX = "sharedElement:snapshot:imageMatrix"; static final SharedElementCallback NULL_CALLBACK = new SharedElementCallback() { }; /** * In Activity Transitions, onSharedElementStart is called immediately before * capturing the start of the shared element state on enter and reenter transitions and * immediately before capturing the end of the shared element state for exit and return * transitions. *
* In Fragment Transitions, onSharedElementStart is called immediately before capturing the * start state of all shared element transitions. *
* This call can be used to adjust the transition start state by modifying the shared * element Views. Note that no layout step will be executed between onSharedElementStart * and the transition state capture. *
* For Activity Transitions, any changes made in {@link #onSharedElementEnd(List, List, List)}
* that are not updated during by layout should be corrected in onSharedElementStart for exit and
* return transitions. For example, rotation or scale will not be affected by layout and
* if changed in {@link #onSharedElementEnd(List, List, List)}, it will also have to be reset
* in onSharedElementStart again to correct the end state.
*
* @param sharedElementNames The names of the shared elements that were accepted into
* the View hierarchy.
* @param sharedElements The shared elements that are part of the View hierarchy.
* @param sharedElementSnapshots The Views containing snap shots of the shared element
* from the launching Window. These elements will not
* be part of the scene, but will be positioned relative
* to the Window decor View. This list is null for Fragment
* Transitions.
*/
public void onSharedElementStart(List
* In Fragment Transitions, onSharedElementEnd is called immediately before capturing the
* end state of all shared element transitions.
*
* This call can be used to adjust the transition end state by modifying the shared
* element Views. Note that no layout step will be executed between onSharedElementEnd
* and the transition state capture.
*
* Any changes made in {@link #onSharedElementStart(List, List, List)} that are not updated
* during layout should be corrected in onSharedElementEnd. For example, rotation or scale
* will not be affected by layout and if changed in
* {@link #onSharedElementStart(List, List, List)}, it will also have to be reset in
* onSharedElementEnd again to correct the end state.
*
* @param sharedElementNames The names of the shared elements that were accepted into
* the View hierarchy.
* @param sharedElements The shared elements that are part of the View hierarchy.
* @param sharedElementSnapshots The Views containing snap shots of the shared element
* from the launching Window. These elements will not
* be part of the scene, but will be positioned relative
* to the Window decor View. This list will be null for
* Fragment Transitions.
*/
public void onSharedElementEnd(List
* Views in rejectedSharedElements will have their position and size set to the
* position of the calling shared element, relative to the Window decor View and contain
* snapshots of the View from the calling Activity or Fragment. This
* view may be safely added to the decor View's overlay to remain in position.
* This method is not called for Fragment Transitions. All rejected shared elements
* will be handled by the exit transition. This is not called for Fragment Transitions. This is not called for Fragment Transitions.
* 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(ListSharedElementCallback
.
*