1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.support.v4.app; 18 19import android.app.ActivityOptions; 20import android.app.Activity; 21import android.os.Bundle; 22import android.util.Pair; 23import android.view.View; 24 25class ActivityOptionsCompat21 { 26 27 private final ActivityOptions mActivityOptions; 28 29 public static ActivityOptionsCompat21 makeSceneTransitionAnimation(Activity activity, 30 View sharedElement, String sharedElementName) { 31 return new ActivityOptionsCompat21( 32 ActivityOptions.makeSceneTransitionAnimation(activity, sharedElement, 33 sharedElementName)); 34 } 35 36 public static ActivityOptionsCompat21 makeSceneTransitionAnimation(Activity activity, 37 View[] sharedElements, String[] sharedElementNames) { 38 Pair[] pairs = null; 39 if (sharedElements != null) { 40 pairs = new Pair[sharedElements.length]; 41 for (int i = 0; i < pairs.length; i++) { 42 pairs[i] = Pair.create(sharedElements[i], sharedElementNames[i]); 43 } 44 } 45 return new ActivityOptionsCompat21( 46 ActivityOptions.makeSceneTransitionAnimation(activity, pairs)); 47 } 48 49 private ActivityOptionsCompat21(ActivityOptions activityOptions) { 50 mActivityOptions = activityOptions; 51 } 52 53 public Bundle toBundle() { 54 return mActivityOptions.toBundle(); 55 } 56 57 public void update(ActivityOptionsCompat21 otherOptions) { 58 mActivityOptions.update(otherOptions.mActivityOptions); 59 } 60} 61