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());
}
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());
}
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());
}
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);
}
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();
}
Aggregations