use of android.view.IAppTransitionAnimationSpecsFuture in project android_frameworks_base by DirtyUnicorns.
the class AppTransition method fetchAppTransitionSpecsFromFuture.
/**
* If a future is set for the app transition specs, fetch it in another thread.
*/
private void fetchAppTransitionSpecsFromFuture() {
if (mNextAppTransitionAnimationsSpecsFuture != null) {
mNextAppTransitionAnimationsSpecsPending = true;
final IAppTransitionAnimationSpecsFuture future = mNextAppTransitionAnimationsSpecsFuture;
mNextAppTransitionAnimationsSpecsFuture = null;
mDefaultExecutor.execute(new Runnable() {
@Override
public void run() {
AppTransitionAnimationSpec[] specs = null;
try {
specs = future.get();
} catch (RemoteException e) {
Slog.w(TAG, "Failed to fetch app transition specs: " + e);
}
synchronized (mService.mWindowMap) {
mNextAppTransitionAnimationsSpecsPending = false;
overridePendingAppTransitionMultiThumb(specs, mNextAppTransitionFutureCallback, null, /* finishedCallback */
mNextAppTransitionScaleUp);
mNextAppTransitionFutureCallback = null;
if (specs != null) {
mService.prolongAnimationsFromSpecs(specs, mNextAppTransitionScaleUp);
}
}
mService.requestTraversal();
}
});
}
}
use of android.view.IAppTransitionAnimationSpecsFuture in project android_frameworks_base by DirtyUnicorns.
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.view.IAppTransitionAnimationSpecsFuture in project android_frameworks_base by crdroidandroid.
the class RecentsView method onBusEvent.
public final void onBusEvent(final DragEndEvent event) {
// Handle the case where we drop onto a dock region
if (event.dropTarget instanceof TaskStack.DockState) {
final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget;
// Hide the dock region
updateVisibleDockRegions(null, false, /* isDefaultDockState */
-1, -1, false, /* animateAlpha */
false);
// We translated the view but we need to animate it back from the current layout-space
// rect to its final layout-space rect
Utilities.setViewFrameFromTranslation(event.taskView);
// Dock the task and launch it
SystemServicesProxy ssp = Recents.getSystemServices();
if (ssp.startTaskInDockedMode(event.task.key.id, dockState.createMode)) {
final OnAnimationStartedListener startedListener = new OnAnimationStartedListener() {
@Override
public void onAnimationStarted() {
EventBus.getDefault().send(new DockedFirstAnimationFrameEvent());
// Remove the task and don't bother relaying out, as all the tasks will be
// relaid out when the stack changes on the multiwindow change event
getStack().removeTask(event.task, null, true);
}
};
final Rect taskRect = getTaskRect(event.taskView);
IAppTransitionAnimationSpecsFuture future = mTransitionHelper.getAppTransitionFuture(new AnimationSpecComposer() {
@Override
public List<AppTransitionAnimationSpec> composeSpecs() {
return mTransitionHelper.composeDockAnimationSpec(event.taskView, taskRect);
}
});
ssp.overridePendingAppTransitionMultiThumbFuture(future, mTransitionHelper.wrapStartedListener(startedListener), true);
MetricsLogger.action(mContext, MetricsEvent.ACTION_WINDOW_DOCK_DRAG_DROP, event.task.getTopComponent().flattenToShortString());
} else {
EventBus.getDefault().send(new DragEndCancelledEvent(getStack(), event.task, event.taskView));
}
} else {
// Animate the overlay alpha back to 0
updateVisibleDockRegions(null, true, /* isDefaultDockState */
-1, -1, true, /* animateAlpha */
false);
}
// Show the stack action button again without changing visibility
if (mStackActionButton != null) {
mStackActionButton.animate().alpha(1f).setDuration(SHOW_STACK_ACTION_BUTTON_DURATION).setInterpolator(Interpolators.ALPHA_IN).start();
}
}
use of android.view.IAppTransitionAnimationSpecsFuture in project android_frameworks_base by crdroidandroid.
the class AppTransition method fetchAppTransitionSpecsFromFuture.
/**
* If a future is set for the app transition specs, fetch it in another thread.
*/
private void fetchAppTransitionSpecsFromFuture() {
if (mNextAppTransitionAnimationsSpecsFuture != null) {
mNextAppTransitionAnimationsSpecsPending = true;
final IAppTransitionAnimationSpecsFuture future = mNextAppTransitionAnimationsSpecsFuture;
mNextAppTransitionAnimationsSpecsFuture = null;
mDefaultExecutor.execute(new Runnable() {
@Override
public void run() {
AppTransitionAnimationSpec[] specs = null;
try {
specs = future.get();
} catch (RemoteException e) {
Slog.w(TAG, "Failed to fetch app transition specs: " + e);
}
synchronized (mService.mWindowMap) {
mNextAppTransitionAnimationsSpecsPending = false;
overridePendingAppTransitionMultiThumb(specs, mNextAppTransitionFutureCallback, null, /* finishedCallback */
mNextAppTransitionScaleUp);
mNextAppTransitionFutureCallback = null;
if (specs != null) {
mService.prolongAnimationsFromSpecs(specs, mNextAppTransitionScaleUp);
}
}
mService.requestTraversal();
}
});
}
}
use of android.view.IAppTransitionAnimationSpecsFuture in project android_frameworks_base by AOSPA.
the class RecentsView method onBusEvent.
public final void onBusEvent(final DragEndEvent event) {
// Handle the case where we drop onto a dock region
if (event.dropTarget instanceof TaskStack.DockState) {
final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget;
// Hide the dock region
updateVisibleDockRegions(null, false, /* isDefaultDockState */
-1, -1, false, /* animateAlpha */
false);
// We translated the view but we need to animate it back from the current layout-space
// rect to its final layout-space rect
Utilities.setViewFrameFromTranslation(event.taskView);
// Dock the task and launch it
SystemServicesProxy ssp = Recents.getSystemServices();
if (ssp.startTaskInDockedMode(event.task.key.id, dockState.createMode)) {
final OnAnimationStartedListener startedListener = new OnAnimationStartedListener() {
@Override
public void onAnimationStarted() {
EventBus.getDefault().send(new DockedFirstAnimationFrameEvent());
// Remove the task and don't bother relaying out, as all the tasks will be
// relaid out when the stack changes on the multiwindow change event
getStack().removeTask(event.task, null, true);
}
};
final Rect taskRect = getTaskRect(event.taskView);
IAppTransitionAnimationSpecsFuture future = mTransitionHelper.getAppTransitionFuture(new AnimationSpecComposer() {
@Override
public List<AppTransitionAnimationSpec> composeSpecs() {
return mTransitionHelper.composeDockAnimationSpec(event.taskView, taskRect);
}
});
ssp.overridePendingAppTransitionMultiThumbFuture(future, mTransitionHelper.wrapStartedListener(startedListener), true);
MetricsLogger.action(mContext, MetricsEvent.ACTION_WINDOW_DOCK_DRAG_DROP, event.task.getTopComponent().flattenToShortString());
} else {
EventBus.getDefault().send(new DragEndCancelledEvent(getStack(), event.task, event.taskView));
}
} else {
// Animate the overlay alpha back to 0
updateVisibleDockRegions(null, true, /* isDefaultDockState */
-1, -1, true, /* animateAlpha */
false);
}
// Show the stack action button again without changing visibility
if (mStackActionButton != null) {
mStackActionButton.animate().alpha(1f).setDuration(SHOW_STACK_ACTION_BUTTON_DURATION).setInterpolator(Interpolators.ALPHA_IN).start();
}
}
Aggregations