16de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn/* 26de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Copyright (C) 2012 The Android Open Source Project 36de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * 46de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License"); 56de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * you may not use this file except in compliance with the License. 66de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * You may obtain a copy of the License at 76de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * 86de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * http://www.apache.org/licenses/LICENSE-2.0 96de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * 106de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Unless required by applicable law or agreed to in writing, software 116de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS, 126de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * See the License for the specific language governing permissions and 146de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * limitations under the License. 156de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 166de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 176de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackbornpackage android.app; 186de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 196de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackbornimport android.content.Context; 208078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackbornimport android.graphics.Bitmap; 216de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackbornimport android.os.Bundle; 228078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackbornimport android.os.Handler; 238078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackbornimport android.os.IRemoteCallback; 248078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackbornimport android.os.RemoteException; 258078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackbornimport android.view.View; 266de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 276de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn/** 286de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Helper class for building an options Bundle that can be used with 296de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * {@link android.content.Context#startActivity(android.content.Intent, android.os.Bundle) 306de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Context.startActivity(Intent, Bundle)} and related methods. 316de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 326de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackbornpublic class ActivityOptions { 336de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 346de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * The package name that created the options. 356de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @hide 366de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 376de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public static final String KEY_PACKAGE_NAME = "android:packageName"; 386de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 396de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 408078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Type of animation that arguments specify. 418078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @hide 428078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 438078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static final String KEY_ANIM_TYPE = "android:animType"; 448078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 458078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 466de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Custom enter animation resource ID. 476de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @hide 486de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 496de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public static final String KEY_ANIM_ENTER_RES_ID = "android:animEnterRes"; 506de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 516de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 526de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Custom exit animation resource ID. 536de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @hide 546de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 556de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public static final String KEY_ANIM_EXIT_RES_ID = "android:animExitRes"; 566de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 578078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 588078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Bitmap for thumbnail animation. 598078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @hide 608078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 618078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static final String KEY_ANIM_THUMBNAIL = "android:animThumbnail"; 628078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 638078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 648078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Start X position of thumbnail animation. 658078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @hide 668078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 678078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static final String KEY_ANIM_START_X = "android:animStartX"; 688078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 698078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 708078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Start Y position of thumbnail animation. 718078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @hide 728078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 738078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static final String KEY_ANIM_START_Y = "android:animStartY"; 748078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 758078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 76eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * Initial width of the animation. 77eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @hide 78eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn */ 79eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn public static final String KEY_ANIM_START_WIDTH = "android:animStartWidth"; 80eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn 81eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** 82eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * Initial height of the animation. 83eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @hide 84eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn */ 85eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn public static final String KEY_ANIM_START_HEIGHT = "android:animStartHeight"; 86eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn 87eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** 888078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Callback for when animation is started. 898078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @hide 908078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 918078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static final String KEY_ANIM_START_LISTENER = "android:animStartListener"; 928078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 938078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 948078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static final int ANIM_NONE = 0; 958078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 968078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static final int ANIM_CUSTOM = 1; 978078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 98eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn public static final int ANIM_SCALE_UP = 2; 99eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** @hide */ 100832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka public static final int ANIM_THUMBNAIL_SCALE_UP = 3; 10121385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka /** @hide */ 102832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka public static final int ANIM_THUMBNAIL_SCALE_DOWN = 4; 1038078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 1046de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn private String mPackageName; 1058078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn private int mAnimationType = ANIM_NONE; 1066de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn private int mCustomEnterResId; 1076de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn private int mCustomExitResId; 1088078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn private Bitmap mThumbnail; 1098078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn private int mStartX; 1108078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn private int mStartY; 111eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn private int mStartWidth; 112eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn private int mStartHeight; 1138078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn private IRemoteCallback mAnimationStartedListener; 1146de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 1156de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 1166de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Create an ActivityOptions specifying a custom animation to run when 1176de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * the activity is displayed. 1186de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * 1196de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @param context Who is defining this. This is the application that the 1206de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * animation resources will be loaded from. 1216de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @param enterResId A resource ID of the animation resource to use for 1226de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * the incoming activity. Use 0 for no animation. 1236de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @param exitResId A resource ID of the animation resource to use for 1246de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * the outgoing activity. Use 0 for no animation. 1256de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @return Returns a new ActivityOptions object that you can use to 1266de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * supply these options as the options Bundle when starting an activity. 1276de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 1286de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public static ActivityOptions makeCustomAnimation(Context context, 1296de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn int enterResId, int exitResId) { 13084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn return makeCustomAnimation(context, enterResId, exitResId, null, null); 13184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 13284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn 13384375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn /** 13484375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * Create an ActivityOptions specifying a custom animation to run when 13584375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * the activity is displayed. 13684375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * 13784375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @param context Who is defining this. This is the application that the 13884375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * animation resources will be loaded from. 13984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @param enterResId A resource ID of the animation resource to use for 14084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * the incoming activity. Use 0 for no animation. 14184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @param exitResId A resource ID of the animation resource to use for 14284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * the outgoing activity. Use 0 for no animation. 14384375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @param handler If <var>listener</var> is non-null this must be a valid 14484375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * Handler on which to dispatch the callback; otherwise it should be null. 14584375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @param listener Optional OnAnimationStartedListener to find out when the 14684375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * requested animation has started running. If for some reason the animation 14784375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * is not executed, the callback will happen immediately. 14884375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @return Returns a new ActivityOptions object that you can use to 14984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * supply these options as the options Bundle when starting an activity. 15084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @hide 15184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn */ 15284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn public static ActivityOptions makeCustomAnimation(Context context, 15384375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn int enterResId, int exitResId, Handler handler, OnAnimationStartedListener listener) { 1546de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn ActivityOptions opts = new ActivityOptions(); 1556de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn opts.mPackageName = context.getPackageName(); 1568078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn opts.mAnimationType = ANIM_CUSTOM; 1576de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn opts.mCustomEnterResId = enterResId; 1586de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn opts.mCustomExitResId = exitResId; 15984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn opts.setListener(handler, listener); 1606de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn return opts; 1616de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 1626de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 16384375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn private void setListener(Handler handler, OnAnimationStartedListener listener) { 16484375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn if (listener != null) { 16584375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn final Handler h = handler; 16684375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn final OnAnimationStartedListener finalListener = listener; 16784375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn mAnimationStartedListener = new IRemoteCallback.Stub() { 16884375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn @Override public void sendResult(Bundle data) throws RemoteException { 16984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn h.post(new Runnable() { 17084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn @Override public void run() { 17184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn finalListener.onAnimationStarted(); 17284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 17384375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn }); 17484375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 17584375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn }; 17684375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 17784375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 17884375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn 1798078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 1808078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Callback for use with {@link ActivityOptions#makeThumbnailScaleUpAnimation} 1818078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * to find out when the given animation has started running. 1829944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * @hide 1838078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 1848078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public interface OnAnimationStartedListener { 1858078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn void onAnimationStarted(); 1868078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 1878078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 1888078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 189eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * Create an ActivityOptions specifying an animation where the new 190eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * activity is scaled from a small originating area of the screen to 191eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * its final full representation. 192eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * 193d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * <p>If the Intent this is being used with has not set its 194d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * {@link android.content.Intent#setSourceBounds Intent.setSourceBounds}, 195d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * those bounds will be filled in for you based on the initial 196d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * bounds passed in here. 197d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * 198eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param source The View that the new activity is animating from. This 199eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * defines the coordinate space for <var>startX</var> and <var>startY</var>. 200eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startX The x starting location of the new activity, relative to <var>source</var>. 201eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startY The y starting location of the activity, relative to <var>source</var>. 202eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startWidth The initial width of the new activity. 203d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * @param startHeight The initial height of the new activity. 204eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @return Returns a new ActivityOptions object that you can use to 205eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * supply these options as the options Bundle when starting an activity. 206eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn */ 207eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn public static ActivityOptions makeScaleUpAnimation(View source, 208eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn int startX, int startY, int startWidth, int startHeight) { 209eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn ActivityOptions opts = new ActivityOptions(); 210eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn opts.mPackageName = source.getContext().getPackageName(); 211eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn opts.mAnimationType = ANIM_SCALE_UP; 212eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn int[] pts = new int[2]; 213eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn source.getLocationOnScreen(pts); 214eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn opts.mStartX = pts[0] + startX; 215eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn opts.mStartY = pts[1] + startY; 216eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn opts.mStartWidth = startWidth; 217eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn opts.mStartHeight = startHeight; 218eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn return opts; 219eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn } 220eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn 221eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** 2228078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Create an ActivityOptions specifying an animation where a thumbnail 2238078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * is scaled from a given position to the new activity window that is 2248078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * being started. 2258078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * 226d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * <p>If the Intent this is being used with has not set its 227d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * {@link android.content.Intent#setSourceBounds Intent.setSourceBounds}, 228d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * those bounds will be filled in for you based on the initial 229d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * thumbnail location and size provided here. 230d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * 2318078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @param source The View that this thumbnail is animating from. This 2328078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * defines the coordinate space for <var>startX</var> and <var>startY</var>. 2338078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @param thumbnail The bitmap that will be shown as the initial thumbnail 2348078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * of the animation. 235eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startX The x starting location of the bitmap, relative to <var>source</var>. 236eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startY The y starting location of the bitmap, relative to <var>source</var>. 2379944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * @return Returns a new ActivityOptions object that you can use to 2389944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * supply these options as the options Bundle when starting an activity. 2399944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn */ 2409944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn public static ActivityOptions makeThumbnailScaleUpAnimation(View source, 2419944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn Bitmap thumbnail, int startX, int startY) { 2429944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn return makeThumbnailScaleUpAnimation(source, thumbnail, startX, startY, null); 2439944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn } 2449944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn 2459944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn /** 2469944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * Create an ActivityOptions specifying an animation where a thumbnail 2479944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * is scaled from a given position to the new activity window that is 2489944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * being started. 2499944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * 2509944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * @param source The View that this thumbnail is animating from. This 2519944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * defines the coordinate space for <var>startX</var> and <var>startY</var>. 2529944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * @param thumbnail The bitmap that will be shown as the initial thumbnail 2539944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * of the animation. 254eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startX The x starting location of the bitmap, relative to <var>source</var>. 255eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startY The y starting location of the bitmap, relative to <var>source</var>. 2568078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @param listener Optional OnAnimationStartedListener to find out when the 2578078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * requested animation has started running. If for some reason the animation 2588078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * is not executed, the callback will happen immediately. 2598078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @return Returns a new ActivityOptions object that you can use to 2608078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * supply these options as the options Bundle when starting an activity. 2619944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * @hide 2628078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 2638078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static ActivityOptions makeThumbnailScaleUpAnimation(View source, 2648078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) { 265832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka return makeThumbnailAnimation(source, thumbnail, startX, startY, listener, true); 26621385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka } 26721385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka 26821385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka /** 269832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * Create an ActivityOptions specifying an animation where an activity window 270832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * is scaled from a given position to a thumbnail at a specified location. 27121385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * 272832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * @param source The View that this thumbnail is animating to. This 27321385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * defines the coordinate space for <var>startX</var> and <var>startY</var>. 274832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * @param thumbnail The bitmap that will be shown as the final thumbnail 27521385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * of the animation. 276832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * @param startX The x end location of the bitmap, relative to <var>source</var>. 277832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * @param startY The y end location of the bitmap, relative to <var>source</var>. 27821385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * @param listener Optional OnAnimationStartedListener to find out when the 27921385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * requested animation has started running. If for some reason the animation 28021385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * is not executed, the callback will happen immediately. 28121385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * @return Returns a new ActivityOptions object that you can use to 28221385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * supply these options as the options Bundle when starting an activity. 28321385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * @hide 28421385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka */ 285832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka public static ActivityOptions makeThumbnailScaleDownAnimation(View source, 28621385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) { 287832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka return makeThumbnailAnimation(source, thumbnail, startX, startY, listener, false); 28821385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka } 28921385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka 290832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka private static ActivityOptions makeThumbnailAnimation(View source, 29121385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener, 292832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka boolean scaleUp) { 2938078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn ActivityOptions opts = new ActivityOptions(); 2948078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn opts.mPackageName = source.getContext().getPackageName(); 295832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka opts.mAnimationType = scaleUp ? ANIM_THUMBNAIL_SCALE_UP : ANIM_THUMBNAIL_SCALE_DOWN; 2968078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn opts.mThumbnail = thumbnail; 2978078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn int[] pts = new int[2]; 2988078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn source.getLocationOnScreen(pts); 2998078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn opts.mStartX = pts[0] + startX; 3008078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn opts.mStartY = pts[1] + startY; 30184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn opts.setListener(source.getHandler(), listener); 3028078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn return opts; 3038078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 3048078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 3056de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn private ActivityOptions() { 3066de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 3076de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 3086de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** @hide */ 3096de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public ActivityOptions(Bundle opts) { 3106de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn mPackageName = opts.getString(KEY_PACKAGE_NAME); 3118078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mAnimationType = opts.getInt(KEY_ANIM_TYPE); 3128078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn if (mAnimationType == ANIM_CUSTOM) { 3136de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn mCustomEnterResId = opts.getInt(KEY_ANIM_ENTER_RES_ID, 0); 3146de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn mCustomExitResId = opts.getInt(KEY_ANIM_EXIT_RES_ID, 0); 31584375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn mAnimationStartedListener = IRemoteCallback.Stub.asInterface( 31684375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn opts.getIBinder(KEY_ANIM_START_LISTENER)); 317eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn } else if (mAnimationType == ANIM_SCALE_UP) { 318eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn mStartX = opts.getInt(KEY_ANIM_START_X, 0); 319eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn mStartY = opts.getInt(KEY_ANIM_START_Y, 0); 320eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn mStartWidth = opts.getInt(KEY_ANIM_START_WIDTH, 0); 321eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn mStartHeight = opts.getInt(KEY_ANIM_START_HEIGHT, 0); 322832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka } else if (mAnimationType == ANIM_THUMBNAIL_SCALE_UP || 323832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka mAnimationType == ANIM_THUMBNAIL_SCALE_DOWN) { 3248078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mThumbnail = (Bitmap)opts.getParcelable(KEY_ANIM_THUMBNAIL); 3258078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mStartX = opts.getInt(KEY_ANIM_START_X, 0); 3268078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mStartY = opts.getInt(KEY_ANIM_START_Y, 0); 3278078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mAnimationStartedListener = IRemoteCallback.Stub.asInterface( 3288078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn opts.getIBinder(KEY_ANIM_START_LISTENER)); 3296de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 3306de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 3316de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 3326de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** @hide */ 3336de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public String getPackageName() { 3346de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn return mPackageName; 3356de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 3366de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 3376de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** @hide */ 3388078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public int getAnimationType() { 3398078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn return mAnimationType; 3406de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 3416de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 3426de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** @hide */ 3436de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public int getCustomEnterResId() { 3446de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn return mCustomEnterResId; 3456de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 3466de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 3476de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** @hide */ 3486de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public int getCustomExitResId() { 3496de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn return mCustomExitResId; 3506de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 3516de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 3528078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 3538078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public Bitmap getThumbnail() { 3548078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn return mThumbnail; 3558078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 3568078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 3578078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 3588078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public int getStartX() { 3598078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn return mStartX; 3608078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 3618078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 3628078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 3638078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public int getStartY() { 3648078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn return mStartY; 3658078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 3668078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 3678078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 368eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn public int getStartWidth() { 369eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn return mStartWidth; 370eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn } 371eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn 372eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** @hide */ 373eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn public int getStartHeight() { 374eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn return mStartHeight; 375eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn } 376eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn 377eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** @hide */ 3788078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public IRemoteCallback getOnAnimationStartListener() { 3798078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn return mAnimationStartedListener; 3808078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 3818078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 3828078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 3838078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public void abort() { 3848078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn if (mAnimationStartedListener != null) { 3858078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn try { 3868078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mAnimationStartedListener.sendResult(null); 3878078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } catch (RemoteException e) { 3888078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 3898078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 3908078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 3918078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 3928078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 3938078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static void abort(Bundle options) { 3948078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn if (options != null) { 3958078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn (new ActivityOptions(options)).abort(); 3968078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 3978078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 3988078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 3996de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 400ddc52a80b5280d4a67180a6caae8c7dead00157fDianne Hackborn * Update the current values in this ActivityOptions from those supplied 401ddc52a80b5280d4a67180a6caae8c7dead00157fDianne Hackborn * in <var>otherOptions</var>. Any values 4026de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * defined in <var>otherOptions</var> replace those in the base options. 4036de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 404ddc52a80b5280d4a67180a6caae8c7dead00157fDianne Hackborn public void update(ActivityOptions otherOptions) { 4056de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn if (otherOptions.mPackageName != null) { 4066de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn mPackageName = otherOptions.mPackageName; 4076de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 4088078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn switch (otherOptions.mAnimationType) { 4098078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn case ANIM_CUSTOM: 4108078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mAnimationType = otherOptions.mAnimationType; 4118078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mCustomEnterResId = otherOptions.mCustomEnterResId; 4128078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mCustomExitResId = otherOptions.mCustomExitResId; 4138078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mThumbnail = null; 41484375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn if (otherOptions.mAnimationStartedListener != null) { 41584375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn try { 41684375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn otherOptions.mAnimationStartedListener.sendResult(null); 41784375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } catch (RemoteException e) { 41884375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 41984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 42084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn mAnimationStartedListener = otherOptions.mAnimationStartedListener; 4218078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn break; 422eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn case ANIM_SCALE_UP: 423eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn mAnimationType = otherOptions.mAnimationType; 424eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn mStartX = otherOptions.mStartX; 425eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn mStartY = otherOptions.mStartY; 426eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn mStartWidth = otherOptions.mStartWidth; 427eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn mStartHeight = otherOptions.mStartHeight; 42884375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn if (otherOptions.mAnimationStartedListener != null) { 42984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn try { 43084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn otherOptions.mAnimationStartedListener.sendResult(null); 43184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } catch (RemoteException e) { 43284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 43384375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 43484375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn mAnimationStartedListener = null; 435eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn break; 436832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka case ANIM_THUMBNAIL_SCALE_UP: 437832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka case ANIM_THUMBNAIL_SCALE_DOWN: 4388078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mAnimationType = otherOptions.mAnimationType; 4398078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mThumbnail = otherOptions.mThumbnail; 4408078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mStartX = otherOptions.mStartX; 4418078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mStartY = otherOptions.mStartY; 4428078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn if (otherOptions.mAnimationStartedListener != null) { 4438078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn try { 4448078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn otherOptions.mAnimationStartedListener.sendResult(null); 4458078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } catch (RemoteException e) { 4468078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 4478078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 4488078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mAnimationStartedListener = otherOptions.mAnimationStartedListener; 4498078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn break; 4506de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 4516de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 4526de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 4536de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 4546de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Returns the created options as a Bundle, which can be passed to 4556de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * {@link android.content.Context#startActivity(android.content.Intent, android.os.Bundle) 4566de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Context.startActivity(Intent, Bundle)} and related methods. 4576de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Note that the returned Bundle is still owned by the ActivityOptions 4586de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * object; you must not modify it, but can supply it to the startActivity 4596de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * methods that take an options Bundle. 4606de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 4616de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public Bundle toBundle() { 4626de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn Bundle b = new Bundle(); 4636de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn if (mPackageName != null) { 4646de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn b.putString(KEY_PACKAGE_NAME, mPackageName); 4656de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 4668078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn switch (mAnimationType) { 4678078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn case ANIM_CUSTOM: 4688078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putInt(KEY_ANIM_TYPE, mAnimationType); 4698078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putInt(KEY_ANIM_ENTER_RES_ID, mCustomEnterResId); 4708078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putInt(KEY_ANIM_EXIT_RES_ID, mCustomExitResId); 47184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn b.putIBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener 47284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn != null ? mAnimationStartedListener.asBinder() : null); 4738078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn break; 474eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn case ANIM_SCALE_UP: 475eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn b.putInt(KEY_ANIM_TYPE, mAnimationType); 476eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn b.putInt(KEY_ANIM_START_X, mStartX); 477eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn b.putInt(KEY_ANIM_START_Y, mStartY); 478eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn b.putInt(KEY_ANIM_START_WIDTH, mStartWidth); 479eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn b.putInt(KEY_ANIM_START_HEIGHT, mStartHeight); 480eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn break; 481832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka case ANIM_THUMBNAIL_SCALE_UP: 482832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka case ANIM_THUMBNAIL_SCALE_DOWN: 4838078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putInt(KEY_ANIM_TYPE, mAnimationType); 4848078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putParcelable(KEY_ANIM_THUMBNAIL, mThumbnail); 4858078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putInt(KEY_ANIM_START_X, mStartX); 4868078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putInt(KEY_ANIM_START_Y, mStartY); 4878078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putIBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener 4888078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn != null ? mAnimationStartedListener.asBinder() : null); 489eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn break; 4906de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 4916de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn return b; 4926de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 4936de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn} 494