1559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount/* 2559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * Copyright (C) 2014 The Android Open Source Project 3559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * 4559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * Licensed under the Apache License, Version 2.0 (the "License"); 5559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * you may not use this file except in compliance with the License. 6559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * You may obtain a copy of the License at 7559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * 8559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * http://www.apache.org/licenses/LICENSE-2.0 9559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * 10559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * Unless required by applicable law or agreed to in writing, software 11559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * distributed under the License is distributed on an "AS IS" BASIS, 12559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * See the License for the specific language governing permissions and 14559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount * limitations under the License. 15559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount */ 16559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 17559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mountpackage android.support.v4.app; 18559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 19559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mountimport android.app.Activity; 20dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baidimport android.app.ActivityOptions; 21dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baidimport android.content.Context; 22dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baidimport android.graphics.Bitmap; 23559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mountimport android.os.Bundle; 24559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mountimport android.util.Pair; 25559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mountimport android.view.View; 26559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 27559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mountclass ActivityOptionsCompat21 { 28559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 29559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount private final ActivityOptions mActivityOptions; 30559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 31dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid public static ActivityOptionsCompat21 makeCustomAnimation(Context context, 32dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid int enterResId, int exitResId) { 33dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid return new ActivityOptionsCompat21( 34dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid ActivityOptions.makeCustomAnimation(context, enterResId, exitResId)); 35dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid } 36dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid 37dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid public static ActivityOptionsCompat21 makeScaleUpAnimation(View source, 38dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid int startX, int startY, int startWidth, int startHeight) { 39dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid return new ActivityOptionsCompat21( 40dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid ActivityOptions.makeScaleUpAnimation(source, startX, startY, startWidth, startHeight)); 41dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid } 42dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid 43dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid public static ActivityOptionsCompat21 makeThumbnailScaleUpAnimation(View source, 44dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid Bitmap thumbnail, int startX, int startY) { 45dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid return new ActivityOptionsCompat21( 46dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid ActivityOptions.makeThumbnailScaleUpAnimation(source, thumbnail, startX, startY)); 47dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid } 48dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid 49559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount public static ActivityOptionsCompat21 makeSceneTransitionAnimation(Activity activity, 50559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount View sharedElement, String sharedElementName) { 51559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount return new ActivityOptionsCompat21( 52559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount ActivityOptions.makeSceneTransitionAnimation(activity, sharedElement, 53559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount sharedElementName)); 54559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 55559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 56559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount public static ActivityOptionsCompat21 makeSceneTransitionAnimation(Activity activity, 57559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount View[] sharedElements, String[] sharedElementNames) { 58559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount Pair[] pairs = null; 59559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount if (sharedElements != null) { 60559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount pairs = new Pair[sharedElements.length]; 61559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount for (int i = 0; i < pairs.length; i++) { 62559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount pairs[i] = Pair.create(sharedElements[i], sharedElementNames[i]); 63559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 64559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 65559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount return new ActivityOptionsCompat21( 66559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount ActivityOptions.makeSceneTransitionAnimation(activity, pairs)); 67559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 68559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 69dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid public static ActivityOptionsCompat21 makeTaskLaunchBehind() { 70dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid return new ActivityOptionsCompat21( 71dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid ActivityOptions.makeTaskLaunchBehind()); 72dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid } 73dcb9c07ac922c022750a803a74e4bb98a4bd8693Abhinav Baid 74559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount private ActivityOptionsCompat21(ActivityOptions activityOptions) { 75559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount mActivityOptions = activityOptions; 76559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 77559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 78559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount public Bundle toBundle() { 79559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount return mActivityOptions.toBundle(); 80559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 81559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 82559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount public void update(ActivityOptionsCompat21 otherOptions) { 83559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount mActivityOptions.update(otherOptions.mActivityOptions); 84559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 85559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount} 86