ActivityOptionsCompat24.java revision dcb9c07ac922c022750a803a74e4bb98a4bd8693
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.Activity; 20import android.app.ActivityOptions; 21import android.app.PendingIntent; 22import android.content.Context; 23import android.graphics.Bitmap; 24import android.graphics.Rect; 25import android.os.Bundle; 26import android.support.annotation.Nullable; 27import android.util.Pair; 28import android.view.View; 29 30class ActivityOptionsCompat24 { 31 32 public static ActivityOptionsCompat24 makeCustomAnimation(Context context, 33 int enterResId, int exitResId) { 34 return new ActivityOptionsCompat24( 35 ActivityOptions.makeCustomAnimation(context, enterResId, exitResId)); 36 } 37 38 public static ActivityOptionsCompat24 makeScaleUpAnimation(View source, 39 int startX, int startY, int startWidth, int startHeight) { 40 return new ActivityOptionsCompat24( 41 ActivityOptions.makeScaleUpAnimation(source, startX, startY, startWidth, startHeight)); 42 } 43 44 public static ActivityOptionsCompat24 makeThumbnailScaleUpAnimation(View source, 45 Bitmap thumbnail, int startX, int startY) { 46 return new ActivityOptionsCompat24( 47 ActivityOptions.makeThumbnailScaleUpAnimation(source, thumbnail, startX, startY)); 48 } 49 50 public static ActivityOptionsCompat24 makeSceneTransitionAnimation(Activity activity, 51 View sharedElement, String sharedElementName) { 52 return new ActivityOptionsCompat24( 53 ActivityOptions.makeSceneTransitionAnimation(activity, sharedElement, 54 sharedElementName)); 55 } 56 57 public static ActivityOptionsCompat24 makeSceneTransitionAnimation(Activity activity, 58 View[] sharedElements, String[] sharedElementNames) { 59 Pair[] pairs = null; 60 if (sharedElements != null) { 61 pairs = new Pair[sharedElements.length]; 62 for (int i = 0; i < pairs.length; i++) { 63 pairs[i] = Pair.create(sharedElements[i], sharedElementNames[i]); 64 } 65 } 66 return new ActivityOptionsCompat24( 67 ActivityOptions.makeSceneTransitionAnimation(activity, pairs)); 68 } 69 70 public static ActivityOptionsCompat24 makeClipRevealAnimation(View source, 71 int startX, int startY, int width, int height) { 72 return new ActivityOptionsCompat24( 73 ActivityOptions.makeClipRevealAnimation(source, startX, startY, width, height)); 74 } 75 76 public static ActivityOptionsCompat24 makeTaskLaunchBehind() { 77 return new ActivityOptionsCompat24( 78 ActivityOptions.makeTaskLaunchBehind()); 79 } 80 81 public static ActivityOptionsCompat24 makeBasic() { 82 return new ActivityOptionsCompat24(ActivityOptions.makeBasic()); 83 } 84 85 private final ActivityOptions mActivityOptions; 86 87 private ActivityOptionsCompat24(ActivityOptions activityOptions) { 88 mActivityOptions = activityOptions; 89 } 90 91 public ActivityOptionsCompat24 setLaunchBounds(@Nullable Rect screenSpacePixelRect) { 92 return new ActivityOptionsCompat24(mActivityOptions.setLaunchBounds(screenSpacePixelRect)); 93 } 94 95 public Rect getLaunchBounds() { 96 return mActivityOptions.getLaunchBounds(); 97 } 98 99 public Bundle toBundle() { 100 return mActivityOptions.toBundle(); 101 } 102 103 public void update(ActivityOptionsCompat24 otherOptions) { 104 mActivityOptions.update(otherOptions.mActivityOptions); 105 } 106 107 public void requestUsageTimeReport(PendingIntent receiver) { 108 mActivityOptions.requestUsageTimeReport(receiver); 109 } 110} 111