Search in sources :

Example 16 with ActivityOptions

use of android.app.ActivityOptions in project google-io-2014 by romainguy.

the class MainActivity method showPhoto.

@SuppressWarnings("UnusedDeclaration")
public void showPhoto(View view) {
    Intent intent = new Intent();
    intent.setClass(this, DetailActivity.class);
    switch(view.getId()) {
        case R.id.show_photo_1:
            intent.putExtra("lat", 37.6329946);
            intent.putExtra("lng", -122.4938344);
            intent.putExtra("zoom", 14.0f);
            intent.putExtra("title", "Pacifica Pier");
            intent.putExtra("description", getResources().getText(R.string.lorem));
            intent.putExtra("photo", R.drawable.photo1);
            break;
        case R.id.show_photo_2:
            intent.putExtra("lat", 37.73284);
            intent.putExtra("lng", -122.503065);
            intent.putExtra("zoom", 15.0f);
            intent.putExtra("title", "Pink Flamingo");
            intent.putExtra("description", getResources().getText(R.string.lorem));
            intent.putExtra("photo", R.drawable.photo2);
            break;
        case R.id.show_photo_3:
            intent.putExtra("lat", 36.861897);
            intent.putExtra("lng", -111.374438);
            intent.putExtra("zoom", 11.0f);
            intent.putExtra("title", "Antelope Canyon");
            intent.putExtra("description", getResources().getText(R.string.lorem));
            intent.putExtra("photo", R.drawable.photo3);
            break;
        case R.id.show_photo_4:
            intent.putExtra("lat", 36.596125);
            intent.putExtra("lng", -118.1604282);
            intent.putExtra("zoom", 9.0f);
            intent.putExtra("title", "Lone Pine");
            intent.putExtra("description", getResources().getText(R.string.lorem));
            intent.putExtra("photo", R.drawable.photo4);
            break;
    }
    ImageView hero = (ImageView) ((View) view.getParent()).findViewById(R.id.photo);
    sPhotoCache.put(intent.getIntExtra("photo", -1), ((BitmapDrawable) hero.getDrawable()).getBitmap());
    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, hero, "photo_hero");
    startActivity(intent, options.toBundle());
}
Also used : Intent(android.content.Intent) ImageView(android.widget.ImageView) ActivityOptions(android.app.ActivityOptions)

Example 17 with ActivityOptions

use of android.app.ActivityOptions in project Material-Movies by saulmm.

the class MoviesActivity method startDetailActivityBySharedElements.

@SuppressWarnings("unchecked")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void startDetailActivityBySharedElements(View touchedView, int moviePosition, Intent movieDetailActivityIntent) {
    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, new Pair<>(touchedView, SHARED_ELEMENT_COVER + moviePosition));
    startActivity(movieDetailActivityIntent, options.toBundle());
}
Also used : ActivityOptions(android.app.ActivityOptions) TargetApi(android.annotation.TargetApi)

Example 18 with ActivityOptions

use of android.app.ActivityOptions in project Android-Material-Examples by saulmm.

the class TransitionFirstActivity method onFabPressed.

public void onFabPressed(View view) {
    Intent i = new Intent(TransitionFirstActivity.this, TransitionSecondActivity.class);
    ActivityOptions transitionActivityOptions = ActivityOptions.makeSceneTransitionAnimation(TransitionFirstActivity.this, Pair.create(mFabButton, "fab"), Pair.create(mHeader, "holder1"));
    startActivity(i, transitionActivityOptions.toBundle());
}
Also used : Intent(android.content.Intent) ActivityOptions(android.app.ActivityOptions)

Example 19 with ActivityOptions

use of android.app.ActivityOptions in project platform_frameworks_base by android.

the class RecentsTransitionHelper method launchTaskFromRecents.

/**
     * Launches the specified {@link Task}.
     */
public void launchTaskFromRecents(final TaskStack stack, @Nullable final Task task, final TaskStackView stackView, final TaskView taskView, final boolean screenPinningRequested, final Rect bounds, final int destinationStack) {
    final ActivityOptions opts = ActivityOptions.makeBasic();
    if (bounds != null) {
        opts.setLaunchBounds(bounds.isEmpty() ? null : bounds);
    }
    final ActivityOptions.OnAnimationStartedListener animStartedListener;
    final IAppTransitionAnimationSpecsFuture transitionFuture;
    if (taskView != null) {
        transitionFuture = getAppTransitionFuture(new AnimationSpecComposer() {

            @Override
            public List<AppTransitionAnimationSpec> composeSpecs() {
                return composeAnimationSpecs(task, stackView, destinationStack);
            }
        });
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
                stackView.cancelAllTaskViewAnimations();
                if (screenPinningRequested) {
                    // Request screen pinning after the animation runs
                    mStartScreenPinningRunnable.taskId = task.key.id;
                    mHandler.postDelayed(mStartScreenPinningRunnable, 350);
                }
            }
        };
    } else {
        // This is only the case if the task is not on screen (scrolled offscreen for example)
        transitionFuture = null;
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
                stackView.cancelAllTaskViewAnimations();
            }
        };
    }
    if (taskView == null) {
        // If there is no task view, then we do not need to worry about animating out occluding
        // task views, and we can launch immediately
        startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
    } else {
        LaunchTaskStartedEvent launchStartedEvent = new LaunchTaskStartedEvent(taskView, screenPinningRequested);
        if (task.group != null && !task.group.isFrontMostTask(task)) {
            launchStartedEvent.addPostAnimationCallback(new Runnable() {

                @Override
                public void run() {
                    startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
                }
            });
            EventBus.getDefault().send(launchStartedEvent);
        } else {
            EventBus.getDefault().send(launchStartedEvent);
            startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
        }
    }
    Recents.getSystemServices().sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
}
Also used : OnAnimationStartedListener(android.app.ActivityOptions.OnAnimationStartedListener) IAppTransitionAnimationSpecsFuture(android.view.IAppTransitionAnimationSpecsFuture) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec) LaunchTaskStartedEvent(com.android.systemui.recents.events.activity.LaunchTaskStartedEvent) ExitRecentsWindowFirstAnimationFrameEvent(com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent) CancelEnterRecentsWindowAnimationEvent(com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent) ActivityOptions(android.app.ActivityOptions)

Example 20 with ActivityOptions

use of android.app.ActivityOptions in project platform_frameworks_base by android.

the class RecentsTvImpl method startRecentsActivity.

@Override
protected void startRecentsActivity(ActivityManager.RunningTaskInfo runningTask, boolean isHomeStackVisible, boolean animate, int growTarget) {
    RecentsTaskLoader loader = Recents.getTaskLoader();
    // the stacks might have changed.
    if (mTriggeredFromAltTab || sInstanceLoadPlan == null) {
        // Create a new load plan if preloadRecents() was never triggered
        sInstanceLoadPlan = loader.createLoadPlan(mContext);
    }
    if (mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
        loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible);
    }
    TaskStack stack = sInstanceLoadPlan.getTaskStack();
    if (!animate) {
        ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, -1, -1);
        startRecentsActivity(runningTask, opts, false, /* fromHome */
        false);
        return;
    }
    boolean hasRecentTasks = stack.getTaskCount() > 0;
    boolean useThumbnailTransition = (runningTask != null) && !isHomeStackVisible && hasRecentTasks;
    if (useThumbnailTransition) {
        // Try starting with a thumbnail transition
        ActivityOptions opts = getThumbnailTransitionActivityOptionsForTV(runningTask, stack.getTaskCount());
        if (opts != null) {
            startRecentsActivity(runningTask, opts, false, /* fromHome */
            true);
        } else {
            // Fall through below to the non-thumbnail transition
            useThumbnailTransition = false;
        }
    }
    if (!useThumbnailTransition) {
        startRecentsActivity(runningTask, null, true, /* fromHome */
        false);
    }
    mLastToggleTime = SystemClock.elapsedRealtime();
}
Also used : TaskStack(com.android.systemui.recents.model.TaskStack) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) ActivityOptions(android.app.ActivityOptions)

Aggregations

ActivityOptions (android.app.ActivityOptions)178 Intent (android.content.Intent)88 RemoteException (android.os.RemoteException)33 Point (android.graphics.Point)30 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)20 TaskStack (com.android.systemui.recents.model.TaskStack)20 PendingIntent (android.app.PendingIntent)18 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)15 ActivityManager (android.app.ActivityManager)14 ComponentName (android.content.ComponentName)13 ActivityInfo (android.content.pm.ActivityInfo)13 ResolveInfo (android.content.pm.ResolveInfo)12 UserHandle (android.os.UserHandle)12 Configuration (android.content.res.Configuration)10 ReferrerIntent (com.android.internal.content.ReferrerIntent)10 RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)10 Task (com.android.systemui.recents.model.Task)10 Bundle (android.os.Bundle)9 ActivityNotFoundException (android.content.ActivityNotFoundException)8 RecyclerView (android.support.v7.widget.RecyclerView)8