Java Code Examples for android.app.ActivityOptions#toBundle()

The following examples show how to use android.app.ActivityOptions#toBundle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Navigator.java    From yahnac with Apache License 2.0 6 votes vote down vote up
public void toLogin(View v) {

        final android.util.Pair[] pairs =
                TransitionHelper.createSafeTransitionParticipants
                        (
                                activity,
                                false,
                                new android.util.Pair<>(v, LoginActivity.VIEW_TOOLBAR_TITLE)
                        );

        if ((v != null) && (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP)) {
            ActivityOptions sceneTransitionAnimation = ActivityOptions
                    .makeSceneTransitionAnimation(activity, pairs);

            final Bundle transitionBundle = sceneTransitionAnimation.toBundle();
            Intent loginLollipopIntent = new Intent(activity, LoginActivity.class);
            ActivityCompat.startActivity(activity, loginLollipopIntent, transitionBundle);
        } else {
            Intent loginIntent = new Intent(activity, LoginActivity.class);
            ActivityCompat.startActivity(activity, loginIntent, null);
            activity.overridePendingTransition(0, 0);
        }

    }
 
Example 2
Source File: SafeActivityOptions.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Merges two activity options into one, with {@code options2} taking precedence in case of a
 * conflict.
 */
@VisibleForTesting
@Nullable ActivityOptions mergeActivityOptions(@Nullable ActivityOptions options1,
        @Nullable ActivityOptions options2) {
    if (options1 == null) {
        return options2;
    }
    if (options2 == null) {
        return options1;
    }
    final Bundle b1 = options1.toBundle();
    final Bundle b2 = options2.toBundle();
    b1.putAll(b2);
    return ActivityOptions.fromBundle(b1);
}
 
Example 3
Source File: ApiCompatibilityUtils.java    From cronet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates an ActivityOptions Bundle with basic options and the LaunchDisplayId set.
 * @param displayId The id of the display to launch into.
 * @return The created bundle, or null if unsupported.
 */
public static Bundle createLaunchDisplayIdActivityOptions(int displayId) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return null;

    ActivityOptions options = ActivityOptions.makeBasic();
    options.setLaunchDisplayId(displayId);
    return options.toBundle();
}
 
Example 4
Source File: U.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
private static Bundle getActivityOptionsBundle(Context context,
                                               ApplicationType applicationType,
                                               View view,
                                               int left,
                                               int top,
                                               int right,
                                               int bottom) {
    ActivityOptions options = getActivityOptions(context, applicationType, view);
    if(options == null) return null;

    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
        return options.toBundle();

    return options.setLaunchBounds(new Rect(left, top, right, bottom)).toBundle();
}
 
Example 5
Source File: HomeActivity.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
private Bundle getActivityAnimationOpts(View view) {
    Bundle bundle = null;
    if (view == null) {
        return null;
    }

    ActivityOptions options = null;
    if (VERSION.SDK_INT >= 23) {
        int left = 0;
        int top = 0;
        int width = view.getMeasuredWidth();
        int height = view.getMeasuredHeight();
        if (view instanceof AppItemView) {
            width = (int) ((AppItemView) view).getIconSize();
            left = (int) ((AppItemView) view).getDrawIconLeft();
            top = (int) ((AppItemView) view).getDrawIconTop();
        }
        options = ActivityOptions.makeClipRevealAnimation(view, left, top, width, height);
    } else if (VERSION.SDK_INT < 21) {
        options = ActivityOptions.makeScaleUpAnimation(view, 0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
    }

    if (options != null) {
        bundle = options.toBundle();
    }

    return bundle;
}