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.ActivityOptions; 20559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mountimport android.app.Activity; 21559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mountimport android.os.Bundle; 22559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mountimport android.util.Pair; 23559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mountimport android.view.View; 24559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 25559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mountclass ActivityOptionsCompat21 { 26559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 27559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount private final ActivityOptions mActivityOptions; 28559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 29559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount public static ActivityOptionsCompat21 makeSceneTransitionAnimation(Activity activity, 30559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount View sharedElement, String sharedElementName) { 31559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount return new ActivityOptionsCompat21( 32559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount ActivityOptions.makeSceneTransitionAnimation(activity, sharedElement, 33559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount sharedElementName)); 34559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 35559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 36559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount public static ActivityOptionsCompat21 makeSceneTransitionAnimation(Activity activity, 37559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount View[] sharedElements, String[] sharedElementNames) { 38559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount Pair[] pairs = null; 39559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount if (sharedElements != null) { 40559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount pairs = new Pair[sharedElements.length]; 41559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount for (int i = 0; i < pairs.length; i++) { 42559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount pairs[i] = Pair.create(sharedElements[i], sharedElementNames[i]); 43559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 44559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 45559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount return new ActivityOptionsCompat21( 46559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount ActivityOptions.makeSceneTransitionAnimation(activity, pairs)); 47559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 48559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 49559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount private ActivityOptionsCompat21(ActivityOptions activityOptions) { 50559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount mActivityOptions = activityOptions; 51559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 52559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 53559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount public Bundle toBundle() { 54559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount return mActivityOptions.toBundle(); 55559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 56559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount 57559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount public void update(ActivityOptionsCompat21 otherOptions) { 58559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount mActivityOptions.update(otherOptions.mActivityOptions); 59559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount } 60559b5e8554651ffc9f9cc639f8e363b9494fc98aGeorge Mount} 61