Search in sources :

Example 1 with AnimatorControllerWithResistance

use of com.android.quickstep.util.AnimatorControllerWithResistance in project android_packages_apps_Launcher3 by crdroidandroid.

the class NoButtonQuickSwitchTouchController method setupOverviewAnimators.

private void setupOverviewAnimators() {
    final LauncherState fromState = QUICK_SWITCH;
    final LauncherState toState = OVERVIEW;
    // Set RecentView's initial properties.
    RECENTS_SCALE_PROPERTY.set(mRecentsView, fromState.getOverviewScaleAndOffset(mLauncher)[0]);
    ADJACENT_PAGE_HORIZONTAL_OFFSET.set(mRecentsView, 1f);
    mRecentsView.setContentAlpha(1);
    mRecentsView.setFullscreenProgress(fromState.getOverviewFullscreenProgress());
    mLauncher.getActionsView().getVisibilityAlpha().setValue((fromState.getVisibleElements(mLauncher) & OVERVIEW_ACTIONS) != 0 ? 1f : 0f);
    float[] scaleAndOffset = toState.getOverviewScaleAndOffset(mLauncher);
    // As we drag right, animate the following properties:
    // - RecentsView translationX
    // - OverviewScrim
    // - RecentsView fade (if it's empty)
    PendingAnimation xAnim = new PendingAnimation((long) (mXRange * 2));
    xAnim.setFloat(mRecentsView, ADJACENT_PAGE_HORIZONTAL_OFFSET, scaleAndOffset[1], LINEAR);
    xAnim.setViewBackgroundColor(mLauncher.getScrimView(), toState.getWorkspaceScrimColor(mLauncher), LINEAR);
    if (mRecentsView.getTaskViewCount() == 0) {
        xAnim.addFloat(mRecentsView, CONTENT_ALPHA, 0f, 1f, LINEAR);
    }
    mXOverviewAnim = xAnim.createPlaybackController();
    mXOverviewAnim.dispatchOnStart();
    // As we drag up, animate the following properties:
    // - RecentsView scale
    // - RecentsView fullscreenProgress
    PendingAnimation yAnim = new PendingAnimation((long) (mYRange * 2));
    yAnim.setFloat(mRecentsView, RECENTS_SCALE_PROPERTY, scaleAndOffset[0], SCALE_DOWN_INTERPOLATOR);
    yAnim.setFloat(mRecentsView, FULLSCREEN_PROGRESS, toState.getOverviewFullscreenProgress(), SCALE_DOWN_INTERPOLATOR);
    AnimatorPlaybackController yNormalController = yAnim.createPlaybackController();
    AnimatorControllerWithResistance yAnimWithResistance = AnimatorControllerWithResistance.createForRecents(yNormalController, mLauncher, mRecentsView.getPagedViewOrientedState(), mLauncher.getDeviceProfile(), mRecentsView, RECENTS_SCALE_PROPERTY, mRecentsView, TASK_SECONDARY_TRANSLATION);
    mYOverviewAnim = new AnimatedFloat(() -> {
        if (mYOverviewAnim != null) {
            yAnimWithResistance.setProgress(mYOverviewAnim.value, mMaxYProgress);
        }
    });
    yNormalController.dispatchOnStart();
}
Also used : AnimatedFloat(com.android.quickstep.AnimatedFloat) LauncherState(com.android.launcher3.LauncherState) PendingAnimation(com.android.launcher3.anim.PendingAnimation) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) AnimatorControllerWithResistance(com.android.quickstep.util.AnimatorControllerWithResistance)

Aggregations

LauncherState (com.android.launcher3.LauncherState)1 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)1 PendingAnimation (com.android.launcher3.anim.PendingAnimation)1 AnimatedFloat (com.android.quickstep.AnimatedFloat)1 AnimatorControllerWithResistance (com.android.quickstep.util.AnimatorControllerWithResistance)1