Search in sources :

Example 1 with R

use of com.android.launcher3.R in project Launcher3 by chislon.

the class CellLayout method animateChildToPosition.

public boolean animateChildToPosition(final View child, int cellX, int cellY, int duration, int delay, boolean permanent, boolean adjustOccupied) {
    ShortcutAndWidgetContainer clc = getShortcutsAndWidgets();
    boolean[][] occupied = mOccupied;
    if (!permanent) {
        occupied = mTmpOccupied;
    }
    if (clc.indexOfChild(child) != -1) {
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        final ItemInfo info = (ItemInfo) child.getTag();
        // We cancel any existing animations
        if (mReorderAnimators.containsKey(lp)) {
            mReorderAnimators.get(lp).cancel();
            mReorderAnimators.remove(lp);
        }
        final int oldX = lp.x;
        final int oldY = lp.y;
        if (adjustOccupied) {
            occupied[lp.cellX][lp.cellY] = false;
            occupied[cellX][cellY] = true;
        }
        lp.isLockedToGrid = true;
        if (permanent) {
            lp.cellX = info.cellX = cellX;
            lp.cellY = info.cellY = cellY;
        } else {
            lp.tmpCellX = cellX;
            lp.tmpCellY = cellY;
        }
        clc.setupLp(lp);
        lp.isLockedToGrid = false;
        final int newX = lp.x;
        final int newY = lp.y;
        lp.x = oldX;
        lp.y = oldY;
        // Exit early if we're not actually moving the view
        if (oldX == newX && oldY == newY) {
            lp.isLockedToGrid = true;
            return true;
        }
        ValueAnimator va = LauncherAnimUtils.ofFloat(child, 0f, 1f);
        va.setDuration(duration);
        mReorderAnimators.put(lp, va);
        va.addUpdateListener(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float r = ((Float) animation.getAnimatedValue()).floatValue();
                lp.x = (int) ((1 - r) * oldX + r * newX);
                lp.y = (int) ((1 - r) * oldY + r * newY);
                child.requestLayout();
            }
        });
        va.addListener(new AnimatorListenerAdapter() {

            boolean cancelled = false;

            public void onAnimationEnd(Animator animation) {
                // place just yet.
                if (!cancelled) {
                    lp.isLockedToGrid = true;
                    child.requestLayout();
                }
                if (mReorderAnimators.containsKey(lp)) {
                    mReorderAnimators.remove(lp);
                }
            }

            public void onAnimationCancel(Animator animation) {
                cancelled = true;
            }
        });
        va.setStartDelay(delay);
        va.start();
        return true;
    }
    return false;
}
Also used : FolderRingAnimator(com.android.launcher3.FolderIcon.FolderRingAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 2 with R

use of com.android.launcher3.R in project android_packages_apps_Launcher3 by crdroidandroid.

the class DragController method findDropTarget.

private DropTarget findDropTarget(int x, int y, int[] dropCoordinates) {
    mDragObject.x = x;
    mDragObject.y = y;
    final Rect r = mRectTemp;
    final ArrayList<DropTarget> dropTargets = mDropTargets;
    final int count = dropTargets.size();
    for (int i = count - 1; i >= 0; i--) {
        DropTarget target = dropTargets.get(i);
        if (!target.isDropEnabled())
            continue;
        target.getHitRectRelativeToDragLayer(r);
        if (r.contains(x, y)) {
            dropCoordinates[0] = x;
            dropCoordinates[1] = y;
            mActivity.getDragLayer().mapCoordInSelfToDescendant((View) target, dropCoordinates);
            return target;
        }
    }
    // Pass all unhandled drag to workspace. Workspace finds the correct
    // cell layout to drop to in the existing drag/drop logic.
    dropCoordinates[0] = x;
    dropCoordinates[1] = y;
    return getDefaultDropTarget(dropCoordinates);
}
Also used : Rect(android.graphics.Rect) DropTarget(com.android.launcher3.DropTarget) Point(android.graphics.Point)

Example 3 with R

use of com.android.launcher3.R in project android_packages_apps_Launcher3 by crdroidandroid.

the class ShortcutAndWidgetContainer method onLayout.

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
            layoutChild(child);
        }
    }
}
Also used : NavigableAppWidgetHostView(com.android.launcher3.widget.NavigableAppWidgetHostView) View(android.view.View)

Example 4 with R

use of com.android.launcher3.R 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 5 with R

use of com.android.launcher3.R in project android_packages_apps_Launcher3 by crdroidandroid.

the class PredictedAppIcon method prepareDrawDragView.

@Override
public SafeCloseable prepareDrawDragView() {
    mDrawForDrag = true;
    invalidate();
    SafeCloseable r = super.prepareDrawDragView();
    return () -> {
        r.close();
        mDrawForDrag = false;
    };
}
Also used : SafeCloseable(com.android.launcher3.util.SafeCloseable)

Aggregations

View (android.view.View)6 Point (android.graphics.Point)5 Rect (android.graphics.Rect)5 Animator (android.animation.Animator)3 ValueAnimator (android.animation.ValueAnimator)3 Paint (android.graphics.Paint)3 GridOccupancy (com.android.launcher3.util.GridOccupancy)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)2 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)2 FolderRingAnimator (com.android.launcher3.FolderIcon.FolderRingAnimator)2 ItemInfo (com.android.launcher3.model.data.ItemInfo)2 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)2 ArrowTipView (com.android.launcher3.views.ArrowTipView)2 ObjectAnimator (android.animation.ObjectAnimator)1 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1