Search in sources :

Example 21 with SnapTarget

use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project android_frameworks_base by DirtyUnicorns.

the class DividerView method fling.

private void fling(int position, float velocity, boolean avoidDismissStart, boolean logMetrics) {
    SnapTarget snapTarget = mSnapAlgorithm.calculateSnapTarget(position, velocity);
    if (avoidDismissStart && snapTarget == mSnapAlgorithm.getDismissStartTarget()) {
        snapTarget = mSnapAlgorithm.getFirstSplitTarget();
    }
    if (logMetrics) {
        logResizeEvent(snapTarget);
    }
    ValueAnimator anim = getFlingAnimator(position, snapTarget, 0);
    mFlingAnimationUtils.apply(anim, position, snapTarget.position, velocity);
    anim.start();
}
Also used : ValueAnimator(android.animation.ValueAnimator) SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Example 22 with SnapTarget

use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project android_frameworks_base by DirtyUnicorns.

the class DividerView method applyDismissingParallax.

/**
     * Applies a parallax to the task when dismissing.
     */
private void applyDismissingParallax(Rect taskRect, int dockSide, SnapTarget snapTarget, int position, int taskPosition) {
    float fraction = Math.min(1, Math.max(0, mSnapAlgorithm.calculateDismissingFraction(position)));
    SnapTarget dismissTarget = null;
    SnapTarget splitTarget = null;
    int start = 0;
    if (position <= mSnapAlgorithm.getLastSplitTarget().position && dockSideTopLeft(dockSide)) {
        dismissTarget = mSnapAlgorithm.getDismissStartTarget();
        splitTarget = mSnapAlgorithm.getFirstSplitTarget();
        start = taskPosition;
    } else if (position >= mSnapAlgorithm.getLastSplitTarget().position && dockSideBottomRight(dockSide)) {
        dismissTarget = mSnapAlgorithm.getDismissEndTarget();
        splitTarget = mSnapAlgorithm.getLastSplitTarget();
        start = splitTarget.position;
    }
    if (dismissTarget != null && fraction > 0f && isDismissing(splitTarget, position, dockSide)) {
        fraction = calculateParallaxDismissingFraction(fraction, dockSide);
        int offsetPosition = (int) (start + fraction * (dismissTarget.position - splitTarget.position));
        int width = taskRect.width();
        int height = taskRect.height();
        switch(dockSide) {
            case WindowManager.DOCKED_LEFT:
                taskRect.left = offsetPosition - width;
                taskRect.right = offsetPosition;
                break;
            case WindowManager.DOCKED_RIGHT:
                taskRect.left = offsetPosition + mDividerSize;
                taskRect.right = offsetPosition + width + mDividerSize;
                break;
            case WindowManager.DOCKED_TOP:
                taskRect.top = offsetPosition - height;
                taskRect.bottom = offsetPosition;
                break;
            case WindowManager.DOCKED_BOTTOM:
                taskRect.top = offsetPosition + mDividerSize;
                taskRect.bottom = offsetPosition + height + mDividerSize;
                break;
        }
    }
}
Also used : SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Example 23 with SnapTarget

use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project platform_frameworks_base by android.

the class DividerView method applyDismissingParallax.

/**
     * Applies a parallax to the task when dismissing.
     */
private void applyDismissingParallax(Rect taskRect, int dockSide, SnapTarget snapTarget, int position, int taskPosition) {
    float fraction = Math.min(1, Math.max(0, mSnapAlgorithm.calculateDismissingFraction(position)));
    SnapTarget dismissTarget = null;
    SnapTarget splitTarget = null;
    int start = 0;
    if (position <= mSnapAlgorithm.getLastSplitTarget().position && dockSideTopLeft(dockSide)) {
        dismissTarget = mSnapAlgorithm.getDismissStartTarget();
        splitTarget = mSnapAlgorithm.getFirstSplitTarget();
        start = taskPosition;
    } else if (position >= mSnapAlgorithm.getLastSplitTarget().position && dockSideBottomRight(dockSide)) {
        dismissTarget = mSnapAlgorithm.getDismissEndTarget();
        splitTarget = mSnapAlgorithm.getLastSplitTarget();
        start = splitTarget.position;
    }
    if (dismissTarget != null && fraction > 0f && isDismissing(splitTarget, position, dockSide)) {
        fraction = calculateParallaxDismissingFraction(fraction, dockSide);
        int offsetPosition = (int) (start + fraction * (dismissTarget.position - splitTarget.position));
        int width = taskRect.width();
        int height = taskRect.height();
        switch(dockSide) {
            case WindowManager.DOCKED_LEFT:
                taskRect.left = offsetPosition - width;
                taskRect.right = offsetPosition;
                break;
            case WindowManager.DOCKED_RIGHT:
                taskRect.left = offsetPosition + mDividerSize;
                taskRect.right = offsetPosition + width + mDividerSize;
                break;
            case WindowManager.DOCKED_TOP:
                taskRect.top = offsetPosition - height;
                taskRect.bottom = offsetPosition;
                break;
            case WindowManager.DOCKED_BOTTOM:
                taskRect.top = offsetPosition + mDividerSize;
                taskRect.bottom = offsetPosition + height + mDividerSize;
                break;
        }
    }
}
Also used : SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Example 24 with SnapTarget

use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project android_frameworks_base by DirtyUnicorns.

the class TaskStack method snapDockedStackAfterRotation.

/**
     * Snaps the bounds after rotation to the closest snap target for the docked stack.
     */
private void snapDockedStackAfterRotation(Rect outBounds) {
    // Calculate the current position.
    final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
    final int dividerSize = mService.getDefaultDisplayContentLocked().getDockedDividerController().getContentWidth();
    final int dockSide = getDockSide(outBounds);
    final int dividerPosition = DockedDividerUtils.calculatePositionForBounds(outBounds, dockSide, dividerSize);
    final int displayWidth = mDisplayContent.getDisplayInfo().logicalWidth;
    final int displayHeight = mDisplayContent.getDisplayInfo().logicalHeight;
    // Snap the position to a target.
    final int rotation = displayInfo.rotation;
    final int orientation = mService.mCurConfiguration.orientation;
    mService.mPolicy.getStableInsetsLw(rotation, displayWidth, displayHeight, outBounds);
    final DividerSnapAlgorithm algorithm = new DividerSnapAlgorithm(mService.mContext.getResources(), displayWidth, displayHeight, dividerSize, orientation == Configuration.ORIENTATION_PORTRAIT, outBounds);
    final SnapTarget target = algorithm.calculateNonDismissingSnapTarget(dividerPosition);
    // Recalculate the bounds based on the position of the target.
    DockedDividerUtils.calculateBoundsForPosition(target.position, dockSide, outBounds, displayInfo.logicalWidth, displayInfo.logicalHeight, dividerSize);
}
Also used : DisplayInfo(android.view.DisplayInfo) DividerSnapAlgorithm(com.android.internal.policy.DividerSnapAlgorithm) SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Example 25 with SnapTarget

use of com.android.internal.policy.DividerSnapAlgorithm.SnapTarget in project android_frameworks_base by AOSPA.

the class DividerView method fling.

private void fling(int position, float velocity, boolean avoidDismissStart, boolean logMetrics) {
    SnapTarget snapTarget = mSnapAlgorithm.calculateSnapTarget(position, velocity);
    if (avoidDismissStart && snapTarget == mSnapAlgorithm.getDismissStartTarget()) {
        snapTarget = mSnapAlgorithm.getFirstSplitTarget();
    }
    if (logMetrics) {
        logResizeEvent(snapTarget);
    }
    ValueAnimator anim = getFlingAnimator(position, snapTarget, 0);
    mFlingAnimationUtils.apply(anim, position, snapTarget.position, velocity);
    anim.start();
}
Also used : ValueAnimator(android.animation.ValueAnimator) SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Aggregations

SnapTarget (com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)34 ValueAnimator (android.animation.ValueAnimator)5 Rect (android.graphics.Rect)5 DisplayInfo (android.view.DisplayInfo)4 DividerSnapAlgorithm (com.android.internal.policy.DividerSnapAlgorithm)4