Search in sources :

Example 1 with AnimationSuccessListener

use of com.android.launcher3.anim.AnimationSuccessListener in project android_packages_apps_Launcher3 by crdroidandroid.

the class QuickstepTransitionManager method addCujInstrumentation.

private void addCujInstrumentation(Animator anim, int cuj) {
    anim.addListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationStart(Animator animation) {
            mDragLayer.getViewTreeObserver().addOnDrawListener(new ViewTreeObserver.OnDrawListener() {

                boolean mHandled = false;

                @Override
                public void onDraw() {
                    if (mHandled) {
                        return;
                    }
                    mHandled = true;
                    InteractionJankMonitorWrapper.begin(mDragLayer, cuj);
                    mDragLayer.post(() -> mDragLayer.getViewTreeObserver().removeOnDrawListener(this));
                }
            });
            super.onAnimationStart(animation);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            InteractionJankMonitorWrapper.cancel(cuj);
        }

        @Override
        public void onAnimationSuccess(Animator animator) {
            InteractionJankMonitorWrapper.end(cuj);
        }
    });
}
Also used : ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 2 with AnimationSuccessListener

use of com.android.launcher3.anim.AnimationSuccessListener in project android_packages_apps_Launcher3 by crdroidandroid.

the class AbsSwipeUpHandler method setupWindowAnimation.

private void setupWindowAnimation(RectFSpringAnim anim) {
    anim.addOnUpdateListener((v, r, p) -> {
        updateSysUiFlags(Math.max(p, mCurrentShift.value));
    });
    anim.addAnimatorListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationSuccess(Animator animator) {
            if (mRecentsView != null) {
                mRecentsView.post(mRecentsView::resetTaskVisuals);
            }
            // Make sure recents is in its final state
            maybeUpdateRecentsAttachedState(false);
            mActivityInterface.onSwipeUpToHomeComplete(mDeviceState);
        }
    });
    if (mRecentsAnimationTargets != null) {
        mRecentsAnimationTargets.addReleaseCheck(anim);
    }
}
Also used : SwipePipToHomeAnimator(com.android.quickstep.util.SwipePipToHomeAnimator) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 3 with AnimationSuccessListener

use of com.android.launcher3.anim.AnimationSuccessListener in project android_packages_apps_Launcher3 by crdroidandroid.

the class RecentsView method cancelSplitSelect.

public PendingAnimation cancelSplitSelect(boolean animate) {
    SplitSelectStateController splitController = mSplitPlaceholderView.getSplitController();
    SplitPositionOption splitOption = splitController.getActiveSplitPositionOption();
    Rect initialBounds = splitController.getInitialBounds();
    splitController.resetState();
    int duration = mActivity.getStateManager().getState().getTransitionDuration(getContext());
    PendingAnimation pendingAnim = new PendingAnimation(duration);
    if (!animate) {
        resetFromSplitSelectionState();
        return pendingAnim;
    }
    addViewInLayout(mSplitHiddenTaskView, mSplitHiddenTaskViewIndex, mSplitHiddenTaskView.getLayoutParams());
    mSplitHiddenTaskView.setAlpha(0);
    int[] oldScroll = new int[getChildCount()];
    getPageScrolls(oldScroll, false, view -> view.getVisibility() != GONE && view != mSplitHiddenTaskView);
    int[] newScroll = new int[getChildCount()];
    getPageScrolls(newScroll, false, SIMPLE_SCROLL_LOGIC);
    boolean needsCurveUpdates = false;
    for (int i = mSplitHiddenTaskViewIndex; i >= 0; i--) {
        View child = getChildAt(i);
        if (child == mSplitHiddenTaskView) {
            TaskView taskView = (TaskView) child;
            int dir = mOrientationHandler.getSplitTaskViewDismissDirection(splitOption, mActivity.getDeviceProfile());
            FloatProperty<TaskView> dismissingTaskViewTranslate;
            Rect hiddenBounds = new Rect(taskView.getLeft(), taskView.getTop(), taskView.getRight(), taskView.getBottom());
            int distanceDelta = 0;
            if (dir == PagedOrientationHandler.SPLIT_TRANSLATE_SECONDARY_NEGATIVE) {
                dismissingTaskViewTranslate = taskView.getSecondaryDissmissTranslationProperty();
                distanceDelta = initialBounds.top - hiddenBounds.top;
                taskView.layout(initialBounds.left, hiddenBounds.top, initialBounds.right, hiddenBounds.bottom);
            } else {
                dismissingTaskViewTranslate = taskView.getPrimaryDismissTranslationProperty();
                distanceDelta = initialBounds.left - hiddenBounds.left;
                taskView.layout(hiddenBounds.left, initialBounds.top, hiddenBounds.right, initialBounds.bottom);
                if (dir == PagedOrientationHandler.SPLIT_TRANSLATE_PRIMARY_POSITIVE) {
                    distanceDelta *= -1;
                }
            }
            pendingAnim.add(ObjectAnimator.ofFloat(mSplitHiddenTaskView, dismissingTaskViewTranslate, distanceDelta));
            pendingAnim.add(ObjectAnimator.ofFloat(mSplitHiddenTaskView, ALPHA, 1));
        } else {
            // ignore views to left
            if (showAsGrid()) {
                // TODO(b/186800707) handle more elegantly for grid
                continue;
            }
            int scrollDiff = newScroll[i] - oldScroll[i];
            if (scrollDiff != 0) {
                FloatProperty translationProperty = child instanceof TaskView ? ((TaskView) child).getPrimaryDismissTranslationProperty() : mOrientationHandler.getPrimaryViewTranslate();
                ResourceProvider rp = DynamicResource.provider(mActivity);
                SpringProperty sp = new SpringProperty(SpringProperty.FLAG_CAN_SPRING_ON_END).setDampingRatio(rp.getFloat(R.dimen.dismiss_task_trans_x_damping_ratio)).setStiffness(rp.getFloat(R.dimen.dismiss_task_trans_x_stiffness));
                pendingAnim.add(ObjectAnimator.ofFloat(child, translationProperty, scrollDiff).setDuration(duration), ACCEL, sp);
                needsCurveUpdates = true;
            }
        }
    }
    if (needsCurveUpdates) {
        pendingAnim.addOnFrameCallback(this::updateCurveProperties);
    }
    pendingAnim.addListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationSuccess(Animator animator) {
            // TODO(b/186800707) Figure out how to undo for grid view
            // Need to handle cases where dismissed task is
            // * Top Row
            // * Bottom Row
            // * Focused Task
            updateGridProperties();
            resetFromSplitSelectionState();
        }
    });
    return pendingAnim;
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) SpringProperty(com.android.launcher3.anim.SpringProperty) Rect(android.graphics.Rect) ImageView(android.widget.ImageView) View(android.view.View) ListView(android.widget.ListView) PagedView(com.android.launcher3.PagedView) TextPaint(android.text.TextPaint) Point(android.graphics.Point) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) SplitPositionOption(com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption) ResourceProvider(com.android.systemui.plugins.ResourceProvider) SplitSelectStateController(com.android.quickstep.util.SplitSelectStateController) FloatProperty(android.util.FloatProperty) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 4 with AnimationSuccessListener

use of com.android.launcher3.anim.AnimationSuccessListener in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskMenuView method animateOpenOrClosed.

private void animateOpenOrClosed(boolean closing) {
    if (mOpenCloseAnimator != null && mOpenCloseAnimator.isRunning()) {
        mOpenCloseAnimator.end();
    }
    mOpenCloseAnimator = new AnimatorSet();
    final Animator revealAnimator = createOpenCloseOutlineProvider().createRevealAnimator(this, closing);
    revealAnimator.setInterpolator(Interpolators.DEACCEL);
    mOpenCloseAnimator.playTogether(revealAnimator, ObjectAnimator.ofFloat(mTaskView.getThumbnail(), DIM_ALPHA, closing ? 0 : TaskView.MAX_PAGE_SCRIM_ALPHA), ObjectAnimator.ofFloat(this, ALPHA, closing ? 0 : 1));
    mOpenCloseAnimator.addListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationStart(Animator animation) {
            setVisibility(VISIBLE);
        }

        @Override
        public void onAnimationSuccess(Animator animator) {
            if (closing) {
                closeComplete();
            }
        }
    });
    mOpenCloseAnimator.setDuration(closing ? REVEAL_CLOSE_DURATION : REVEAL_OPEN_DURATION);
    mOpenCloseAnimator.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 5 with AnimationSuccessListener

use of com.android.launcher3.anim.AnimationSuccessListener in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatPredictionController method fillGapsWithPrediction.

private void fillGapsWithPrediction(boolean animate) {
    if (mPauseFlags != 0) {
        return;
    }
    int predictionIndex = 0;
    ArrayList<WorkspaceItemInfo> newItems = new ArrayList<>();
    // make sure predicted icon removal and filling predictions don't step on each other
    if (mIconRemoveAnimators != null && mIconRemoveAnimators.isRunning()) {
        mIconRemoveAnimators.addListener(new AnimationSuccessListener() {

            @Override
            public void onAnimationSuccess(Animator animator) {
                fillGapsWithPrediction(animate);
                mIconRemoveAnimators.removeListener(this);
            }
        });
        return;
    }
    mPauseFlags |= FLAG_FILL_IN_PROGRESS;
    for (int rank = 0; rank < mHotSeatItemsCount; rank++) {
        View child = mHotseat.getChildAt(mHotseat.getCellXFromOrder(rank), mHotseat.getCellYFromOrder(rank));
        if (child != null && !isPredictedIcon(child)) {
            continue;
        }
        if (mPredictedItems.size() <= predictionIndex) {
            // Remove predicted apps from the past
            if (isPredictedIcon(child)) {
                mHotseat.removeView(child);
            }
            continue;
        }
        WorkspaceItemInfo predictedItem = (WorkspaceItemInfo) mPredictedItems.get(predictionIndex++);
        if (isPredictedIcon(child) && child.isEnabled()) {
            PredictedAppIcon icon = (PredictedAppIcon) child;
            icon.applyFromWorkspaceItem(predictedItem);
            icon.finishBinding(mPredictionLongClickListener);
        } else {
            newItems.add(predictedItem);
        }
        preparePredictionInfo(predictedItem, rank);
    }
    bindItems(newItems, animate);
    mPauseFlags &= ~FLAG_FILL_IN_PROGRESS;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) ArrayList(java.util.ArrayList) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Aggregations

Animator (android.animation.Animator)10 AnimationSuccessListener (com.android.launcher3.anim.AnimationSuccessListener)10 ObjectAnimator (android.animation.ObjectAnimator)7 AnimatorSet (android.animation.AnimatorSet)4 ValueAnimator (android.animation.ValueAnimator)4 Rect (android.graphics.Rect)2 View (android.view.View)2 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)2 PredictedAppIcon (com.android.launcher3.uioverrides.PredictedAppIcon)2 SwipePipToHomeAnimator (com.android.quickstep.util.SwipePipToHomeAnimator)2 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 Context (android.content.Context)1 Matrix (android.graphics.Matrix)1 Point (android.graphics.Point)1 RectF (android.graphics.RectF)1 IBinder (android.os.IBinder)1 TextPaint (android.text.TextPaint)1 FloatProperty (android.util.FloatProperty)1 ImageView (android.widget.ImageView)1