diff options
| author | Ming-Shin Lu <lumark@google.com> | 2020-04-17 03:33:51 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-17 03:33:51 +0000 |
| commit | 49ccdb557f7d803b26d35d0396d3e681d2413bee (patch) | |
| tree | 2cfd35224c5cf0167e962ce6c29a52aef8ed8f3e /core/java/android/app/ActivityOptions.java | |
| parent | f89426d2a0ce711cecc3ed7a685dd6952ff6f2a6 (diff) | |
| parent | b6d7002f365d92010c1d55910d7a231c82820314 (diff) | |
Merge "Add test APIs for makeCustomAnimation" into rvc-dev
Diffstat (limited to 'core/java/android/app/ActivityOptions.java')
| -rw-r--r-- | core/java/android/app/ActivityOptions.java | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index 925b15deff29..0129aabd49f8 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -22,6 +22,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.view.Display.INVALID_DISPLAY; +import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.TestApi; @@ -379,7 +380,7 @@ public class ActivityOptions { */ public static ActivityOptions makeCustomAnimation(Context context, int enterResId, int exitResId) { - return makeCustomAnimation(context, enterResId, exitResId, null, null); + return makeCustomAnimation(context, enterResId, exitResId, null, null, null); } /** @@ -414,6 +415,38 @@ public class ActivityOptions { } /** + * Create an ActivityOptions specifying a custom animation to run when + * the activity is displayed. + * + * @param context Who is defining this. This is the application that the + * animation resources will be loaded from. + * @param enterResId A resource ID of the animation resource to use for + * the incoming activity. Use 0 for no animation. + * @param exitResId A resource ID of the animation resource to use for + * the outgoing activity. Use 0 for no animation. + * @param handler If <var>listener</var> is non-null this must be a valid + * Handler on which to dispatch the callback; otherwise it should be null. + * @param startedListener Optional OnAnimationStartedListener to find out when the + * requested animation has started running. If for some reason the animation + * is not executed, the callback will happen immediately. + * @param finishedListener Optional OnAnimationFinishedListener when the animation + * has finished running. + * @return Returns a new ActivityOptions object that you can use to + * supply these options as the options Bundle when starting an activity. + * @hide + */ + @TestApi + public static @NonNull ActivityOptions makeCustomAnimation(@NonNull Context context, + int enterResId, int exitResId, @Nullable Handler handler, + @Nullable OnAnimationStartedListener startedListener, + @Nullable OnAnimationFinishedListener finishedListener) { + ActivityOptions opts = makeCustomAnimation(context, enterResId, exitResId, handler, + startedListener); + opts.setOnAnimationFinishedListener(handler, finishedListener); + return opts; + } + + /** * Creates an ActivityOptions specifying a custom animation to run in place on an existing * activity. * @@ -458,6 +491,7 @@ public class ActivityOptions { * to find out when the given animation has started running. * @hide */ + @TestApi public interface OnAnimationStartedListener { void onAnimationStarted(); } @@ -484,6 +518,7 @@ public class ActivityOptions { * to find out when the given animation has drawn its last frame. * @hide */ + @TestApi public interface OnAnimationFinishedListener { void onAnimationFinished(); } @@ -1100,7 +1135,7 @@ public class ActivityOptions { } /** @hide */ - public IRemoteCallback getOnAnimationStartListener() { + public IRemoteCallback getAnimationStartedListener() { return mAnimationStartedListener; } |
