Search in sources :

Example 1 with DragPreviewProvider

use of com.android.launcher3.graphics.DragPreviewProvider in project android_packages_apps_Launcher3 by crdroidandroid.

the class Workspace method beginDragShared.

public void beginDragShared(View child, DragSource source, DragOptions options) {
    Object dragObject = child.getTag();
    if (!(dragObject instanceof ItemInfo)) {
        String msg = "Drag started with a view that has no tag set. This " + "will cause a crash (issue 11627249) down the line. " + "View: " + child + "  tag: " + child.getTag();
        throw new IllegalStateException(msg);
    }
    beginDragShared(child, null, source, (ItemInfo) dragObject, new DragPreviewProvider(child), options);
}
Also used : WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) DragPreviewProvider(com.android.launcher3.graphics.DragPreviewProvider)

Example 2 with DragPreviewProvider

use of com.android.launcher3.graphics.DragPreviewProvider in project android_packages_apps_Launcher3 by crdroidandroid.

the class Workspace method beginDragShared.

/**
 * Core functionality for beginning a drag operation for an item that will be dropped within
 * the workspace
 */
public DragView beginDragShared(View child, DraggableView draggableView, DragSource source, ItemInfo dragObject, DragPreviewProvider previewProvider, DragOptions dragOptions) {
    float iconScale = 1f;
    if (child instanceof BubbleTextView) {
        Drawable icon = ((BubbleTextView) child).getIcon();
        if (icon instanceof FastBitmapDrawable) {
            iconScale = ((FastBitmapDrawable) icon).getAnimatedScale();
        }
    }
    // Clear the pressed state if necessary
    child.clearFocus();
    child.setPressed(false);
    if (child instanceof BubbleTextView) {
        BubbleTextView icon = (BubbleTextView) child;
        icon.clearPressedBackground();
    }
    mOutlineProvider = previewProvider;
    if (draggableView == null && child instanceof DraggableView) {
        draggableView = (DraggableView) child;
    }
    final View contentView = previewProvider.getContentView();
    final float scale;
    // The draggable drawable follows the touch point around on the screen
    final Drawable drawable;
    if (contentView == null) {
        drawable = previewProvider.createDrawable();
        scale = previewProvider.getScaleAndPosition(drawable, mTempXY);
    } else {
        drawable = null;
        scale = previewProvider.getScaleAndPosition(contentView, mTempXY);
    }
    int halfPadding = previewProvider.previewPadding / 2;
    int dragLayerX = mTempXY[0];
    int dragLayerY = mTempXY[1];
    Point dragVisualizeOffset = null;
    Rect dragRect = new Rect();
    if (draggableView != null) {
        draggableView.getSourceVisualDragBounds(dragRect);
        dragLayerY += dragRect.top;
        dragVisualizeOffset = new Point(-halfPadding, halfPadding);
    }
    if (child.getParent() instanceof ShortcutAndWidgetContainer) {
        mDragSourceInternal = (ShortcutAndWidgetContainer) child.getParent();
    }
    if (child instanceof BubbleTextView && !dragOptions.isAccessibleDrag) {
        PopupContainerWithArrow popupContainer = PopupContainerWithArrow.showForIcon((BubbleTextView) child);
        if (popupContainer != null) {
            dragOptions.preDragCondition = popupContainer.createPreDragCondition();
        }
    }
    final DragView dv;
    if (contentView instanceof View) {
        if (contentView instanceof LauncherAppWidgetHostView) {
            mDragController.addDragListener(new AppWidgetHostViewDragListener(mLauncher));
        }
        dv = mDragController.startDrag(contentView, draggableView, dragLayerX, dragLayerY, source, dragObject, dragVisualizeOffset, dragRect, scale * iconScale, scale, dragOptions);
    } else {
        dv = mDragController.startDrag(drawable, draggableView, dragLayerX, dragLayerY, source, dragObject, dragVisualizeOffset, dragRect, scale * iconScale, scale, dragOptions);
    }
    return dv;
}
Also used : Rect(android.graphics.Rect) Drawable(android.graphics.drawable.Drawable) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) DragView(com.android.launcher3.dragndrop.DragView) Point(android.graphics.Point) DraggableView(com.android.launcher3.dragndrop.DraggableView) DraggableView(com.android.launcher3.dragndrop.DraggableView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) AppWidgetHostViewDragListener(com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 AppWidgetHostView (android.appwidget.AppWidgetHostView)1 Point (android.graphics.Point)1 Rect (android.graphics.Rect)1 Drawable (android.graphics.drawable.Drawable)1 View (android.view.View)1 DragView (com.android.launcher3.dragndrop.DragView)1 DraggableView (com.android.launcher3.dragndrop.DraggableView)1 DragPreviewProvider (com.android.launcher3.graphics.DragPreviewProvider)1 PreloadIconDrawable (com.android.launcher3.graphics.PreloadIconDrawable)1 FastBitmapDrawable (com.android.launcher3.icons.FastBitmapDrawable)1 ItemInfo (com.android.launcher3.model.data.ItemInfo)1 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)1 PopupContainerWithArrow (com.android.launcher3.popup.PopupContainerWithArrow)1 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)1 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)1 AppWidgetHostViewDragListener (com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener)1