Search in sources :

Example 6 with ReferenceCountedTrigger

use of com.android.systemui.recents.misc.ReferenceCountedTrigger in project android_frameworks_base by AOSPA.

the class RecentsView method hideStackActionButton.

/**
     * Hides the stack action button.
     */
private void hideStackActionButton(int duration, boolean translate) {
    if (!RecentsDebugFlags.Static.EnableStackActionButton) {
        return;
    }
    final ReferenceCountedTrigger postAnimationTrigger = new ReferenceCountedTrigger();
    hideStackActionButton(duration, translate, postAnimationTrigger);
    postAnimationTrigger.flushLastDecrementRunnables();
}
Also used : ReferenceCountedTrigger(com.android.systemui.recents.misc.ReferenceCountedTrigger)

Example 7 with ReferenceCountedTrigger

use of com.android.systemui.recents.misc.ReferenceCountedTrigger in project android_frameworks_base by crdroidandroid.

the class TaskStackAnimationHelper method startScrollToFocusedTaskAnimation.

/**
     * Starts the animation to focus the next {@link TaskView} when paging through recents.
     *
     * @return whether or not this will trigger a scroll in the stack
     */
public boolean startScrollToFocusedTaskAnimation(Task newFocusedTask, boolean requestViewFocus) {
    TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
    TaskStackViewScroller stackScroller = mStackView.getScroller();
    TaskStack stack = mStackView.getStack();
    final float curScroll = stackScroller.getStackScroll();
    final float newScroll = stackScroller.getBoundedStackScroll(stackLayout.getStackScrollForTask(newFocusedTask));
    boolean willScrollToFront = newScroll > curScroll;
    boolean willScroll = Float.compare(newScroll, curScroll) != 0;
    // Get the current set of task transforms
    int taskViewCount = mStackView.getTaskViews().size();
    ArrayList<Task> stackTasks = stack.getStackTasks();
    mStackView.getCurrentTaskTransforms(stackTasks, mTmpCurrentTaskTransforms);
    // Pick up the newly visible views after the scroll
    mStackView.bindVisibleTaskViews(newScroll);
    // Update the internal state
    stackLayout.setFocusState(TaskStackLayoutAlgorithm.STATE_FOCUSED);
    stackScroller.setStackScroll(newScroll, null);
    mStackView.cancelDeferredTaskViewLayoutAnimation();
    // Get the final set of task transforms
    mStackView.getLayoutTaskTransforms(newScroll, stackLayout.getFocusState(), stackTasks, true, /* ignoreTaskOverrides */
    mTmpFinalTaskTransforms);
    // Focus the task view
    TaskView newFocusedTaskView = mStackView.getChildViewForTask(newFocusedTask);
    if (newFocusedTaskView == null) {
        // Log the error if we have no task view, and skip the animation
        Log.e("TaskStackAnimationHelper", "b/27389156 null-task-view prebind:" + taskViewCount + " postbind:" + mStackView.getTaskViews().size() + " prescroll:" + curScroll + " postscroll: " + newScroll);
        return false;
    }
    newFocusedTaskView.setFocusedState(true, requestViewFocus);
    // Setup the end listener to return all the hidden views to the view pool after the
    // focus animation
    ReferenceCountedTrigger postAnimTrigger = new ReferenceCountedTrigger();
    postAnimTrigger.addLastDecrementRunnable(new Runnable() {

        @Override
        public void run() {
            mStackView.bindVisibleTaskViews(newScroll);
        }
    });
    List<TaskView> taskViews = mStackView.getTaskViews();
    taskViewCount = taskViews.size();
    int newFocusTaskViewIndex = taskViews.indexOf(newFocusedTaskView);
    for (int i = 0; i < taskViewCount; i++) {
        TaskView tv = taskViews.get(i);
        Task task = tv.getTask();
        if (mStackView.isIgnoredTask(task)) {
            continue;
        }
        int taskIndex = stackTasks.indexOf(task);
        TaskViewTransform fromTransform = mTmpCurrentTaskTransforms.get(taskIndex);
        TaskViewTransform toTransform = mTmpFinalTaskTransforms.get(taskIndex);
        // Update the task to the initial state (for the newly picked up tasks)
        mStackView.updateTaskViewToTransform(tv, fromTransform, AnimationProps.IMMEDIATE);
        int duration;
        Interpolator interpolator;
        if (willScrollToFront) {
            duration = calculateStaggeredAnimDuration(i);
            interpolator = FOCUS_BEHIND_NEXT_TASK_INTERPOLATOR;
        } else {
            if (i < newFocusTaskViewIndex) {
                duration = 150 + ((newFocusTaskViewIndex - i - 1) * 50);
                interpolator = FOCUS_BEHIND_NEXT_TASK_INTERPOLATOR;
            } else if (i > newFocusTaskViewIndex) {
                duration = Math.max(100, 150 - ((i - newFocusTaskViewIndex - 1) * 50));
                interpolator = FOCUS_IN_FRONT_NEXT_TASK_INTERPOLATOR;
            } else {
                duration = 200;
                interpolator = FOCUS_NEXT_TASK_INTERPOLATOR;
            }
        }
        AnimationProps anim = new AnimationProps().setDuration(AnimationProps.BOUNDS, duration).setInterpolator(AnimationProps.BOUNDS, interpolator).setListener(postAnimTrigger.decrementOnAnimationEnd());
        postAnimTrigger.increment();
        mStackView.updateTaskViewToTransform(tv, toTransform, anim);
    }
    return willScroll;
}
Also used : Task(com.android.systemui.recents.model.Task) TaskStack(com.android.systemui.recents.model.TaskStack) ReferenceCountedTrigger(com.android.systemui.recents.misc.ReferenceCountedTrigger) TimeInterpolator(android.animation.TimeInterpolator) PathInterpolator(android.view.animation.PathInterpolator) Interpolator(android.view.animation.Interpolator)

Example 8 with ReferenceCountedTrigger

use of com.android.systemui.recents.misc.ReferenceCountedTrigger in project android_frameworks_base by crdroidandroid.

the class RecentsView method showStackActionButton.

/**
     * Shows the stack action button.
     */
private void showStackActionButton(final int duration, final boolean translate) {
    if (!RecentsDebugFlags.Static.EnableStackActionButton) {
        return;
    }
    if (mFloatingButton != null && mShowClearAllRecents) {
        return;
    }
    final ReferenceCountedTrigger postAnimationTrigger = new ReferenceCountedTrigger();
    if (mStackActionButton.getVisibility() == View.INVISIBLE) {
        mStackActionButton.setVisibility(View.VISIBLE);
        mStackActionButton.setAlpha(0f);
        if (translate) {
            mStackActionButton.setTranslationY(-mStackActionButton.getMeasuredHeight() * 0.25f);
        } else {
            mStackActionButton.setTranslationY(0f);
        }
        postAnimationTrigger.addLastDecrementRunnable(new Runnable() {

            @Override
            public void run() {
                if (translate) {
                    mStackActionButton.animate().translationY(0f);
                }
                mStackActionButton.animate().alpha(1f).setDuration(duration).setInterpolator(Interpolators.FAST_OUT_SLOW_IN).start();
            }
        });
    }
    postAnimationTrigger.flushLastDecrementRunnables();
}
Also used : ReferenceCountedTrigger(com.android.systemui.recents.misc.ReferenceCountedTrigger)

Example 9 with ReferenceCountedTrigger

use of com.android.systemui.recents.misc.ReferenceCountedTrigger in project android_frameworks_base by AOSPA.

the class RecentsView method showStackActionButton.

/**
     * Shows the stack action button.
     */
private void showStackActionButton(final int duration, final boolean translate) {
    if (!RecentsDebugFlags.Static.EnableStackActionButton) {
        return;
    }
    final ReferenceCountedTrigger postAnimationTrigger = new ReferenceCountedTrigger();
    if (mStackActionButton.getVisibility() == View.INVISIBLE) {
        mStackActionButton.setVisibility(View.VISIBLE);
        mStackActionButton.setAlpha(0f);
        if (translate) {
            mStackActionButton.setTranslationY(-mStackActionButton.getMeasuredHeight() * 0.25f);
        } else {
            mStackActionButton.setTranslationY(0f);
        }
        postAnimationTrigger.addLastDecrementRunnable(new Runnable() {

            @Override
            public void run() {
                if (translate) {
                    mStackActionButton.animate().translationY(0f);
                }
                mStackActionButton.animate().alpha(1f).setDuration(duration).setInterpolator(Interpolators.FAST_OUT_SLOW_IN).start();
            }
        });
    }
    postAnimationTrigger.flushLastDecrementRunnables();
}
Also used : ReferenceCountedTrigger(com.android.systemui.recents.misc.ReferenceCountedTrigger)

Example 10 with ReferenceCountedTrigger

use of com.android.systemui.recents.misc.ReferenceCountedTrigger in project android_frameworks_base by AOSPA.

the class TaskStackAnimationHelper method startScrollToFocusedTaskAnimation.

/**
     * Starts the animation to focus the next {@link TaskView} when paging through recents.
     *
     * @return whether or not this will trigger a scroll in the stack
     */
public boolean startScrollToFocusedTaskAnimation(Task newFocusedTask, boolean requestViewFocus) {
    TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
    TaskStackViewScroller stackScroller = mStackView.getScroller();
    TaskStack stack = mStackView.getStack();
    final float curScroll = stackScroller.getStackScroll();
    final float newScroll = stackScroller.getBoundedStackScroll(stackLayout.getStackScrollForTask(newFocusedTask));
    boolean willScrollToFront = newScroll > curScroll;
    boolean willScroll = Float.compare(newScroll, curScroll) != 0;
    // Get the current set of task transforms
    int taskViewCount = mStackView.getTaskViews().size();
    ArrayList<Task> stackTasks = stack.getStackTasks();
    mStackView.getCurrentTaskTransforms(stackTasks, mTmpCurrentTaskTransforms);
    // Pick up the newly visible views after the scroll
    mStackView.bindVisibleTaskViews(newScroll);
    // Update the internal state
    stackLayout.setFocusState(TaskStackLayoutAlgorithm.STATE_FOCUSED);
    stackScroller.setStackScroll(newScroll, null);
    mStackView.cancelDeferredTaskViewLayoutAnimation();
    // Get the final set of task transforms
    mStackView.getLayoutTaskTransforms(newScroll, stackLayout.getFocusState(), stackTasks, true, /* ignoreTaskOverrides */
    mTmpFinalTaskTransforms);
    // Focus the task view
    TaskView newFocusedTaskView = mStackView.getChildViewForTask(newFocusedTask);
    if (newFocusedTaskView == null) {
        // Log the error if we have no task view, and skip the animation
        Log.e("TaskStackAnimationHelper", "b/27389156 null-task-view prebind:" + taskViewCount + " postbind:" + mStackView.getTaskViews().size() + " prescroll:" + curScroll + " postscroll: " + newScroll);
        return false;
    }
    newFocusedTaskView.setFocusedState(true, requestViewFocus);
    // Setup the end listener to return all the hidden views to the view pool after the
    // focus animation
    ReferenceCountedTrigger postAnimTrigger = new ReferenceCountedTrigger();
    postAnimTrigger.addLastDecrementRunnable(new Runnable() {

        @Override
        public void run() {
            mStackView.bindVisibleTaskViews(newScroll);
        }
    });
    List<TaskView> taskViews = mStackView.getTaskViews();
    taskViewCount = taskViews.size();
    int newFocusTaskViewIndex = taskViews.indexOf(newFocusedTaskView);
    for (int i = 0; i < taskViewCount; i++) {
        TaskView tv = taskViews.get(i);
        Task task = tv.getTask();
        if (mStackView.isIgnoredTask(task)) {
            continue;
        }
        int taskIndex = stackTasks.indexOf(task);
        TaskViewTransform fromTransform = mTmpCurrentTaskTransforms.get(taskIndex);
        TaskViewTransform toTransform = mTmpFinalTaskTransforms.get(taskIndex);
        // Update the task to the initial state (for the newly picked up tasks)
        mStackView.updateTaskViewToTransform(tv, fromTransform, AnimationProps.IMMEDIATE);
        int duration;
        Interpolator interpolator;
        if (willScrollToFront) {
            duration = calculateStaggeredAnimDuration(i);
            interpolator = FOCUS_BEHIND_NEXT_TASK_INTERPOLATOR;
        } else {
            if (i < newFocusTaskViewIndex) {
                duration = 150 + ((newFocusTaskViewIndex - i - 1) * 50);
                interpolator = FOCUS_BEHIND_NEXT_TASK_INTERPOLATOR;
            } else if (i > newFocusTaskViewIndex) {
                duration = Math.max(100, 150 - ((i - newFocusTaskViewIndex - 1) * 50));
                interpolator = FOCUS_IN_FRONT_NEXT_TASK_INTERPOLATOR;
            } else {
                duration = 200;
                interpolator = FOCUS_NEXT_TASK_INTERPOLATOR;
            }
        }
        AnimationProps anim = new AnimationProps().setDuration(AnimationProps.BOUNDS, duration).setInterpolator(AnimationProps.BOUNDS, interpolator).setListener(postAnimTrigger.decrementOnAnimationEnd());
        postAnimTrigger.increment();
        mStackView.updateTaskViewToTransform(tv, toTransform, anim);
    }
    return willScroll;
}
Also used : Task(com.android.systemui.recents.model.Task) TaskStack(com.android.systemui.recents.model.TaskStack) ReferenceCountedTrigger(com.android.systemui.recents.misc.ReferenceCountedTrigger) TimeInterpolator(android.animation.TimeInterpolator) PathInterpolator(android.view.animation.PathInterpolator) Interpolator(android.view.animation.Interpolator)

Aggregations

ReferenceCountedTrigger (com.android.systemui.recents.misc.ReferenceCountedTrigger)15 TimeInterpolator (android.animation.TimeInterpolator)5 Interpolator (android.view.animation.Interpolator)5 PathInterpolator (android.view.animation.PathInterpolator)5 Task (com.android.systemui.recents.model.Task)5 TaskStack (com.android.systemui.recents.model.TaskStack)5