Search in sources :

Example 1 with PendingItemDragHelper

use of com.android.launcher3.widget.PendingItemDragHelper in project android_packages_apps_Launcher3 by crdroidandroid.

the class PinItemDragListener method createDragHelper.

@Override
protected PendingItemDragHelper createDragHelper() {
    final PendingAddItemInfo item;
    if (mRequest.getRequestType() == PinItemRequest.REQUEST_TYPE_SHORTCUT) {
        item = new PendingAddShortcutInfo(new PinShortcutRequestActivityInfo(mRequest, mLauncher));
    } else {
        // mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_APPWIDGET
        LauncherAppWidgetProviderInfo providerInfo = LauncherAppWidgetProviderInfo.fromProviderInfo(mLauncher, mRequest.getAppWidgetProviderInfo(mLauncher));
        final PinWidgetFlowHandler flowHandler = new PinWidgetFlowHandler(providerInfo, mRequest);
        item = new PendingAddWidgetInfo(providerInfo, CONTAINER_PIN_WIDGETS) {

            @Override
            public WidgetAddFlowHandler getHandler() {
                return flowHandler;
            }
        };
    }
    View view = new View(mLauncher);
    view.setTag(item);
    PendingItemDragHelper dragHelper = new PendingItemDragHelper(view);
    if (mRequest.getRequestType() == PinItemRequest.REQUEST_TYPE_APPWIDGET) {
        dragHelper.setRemoteViewsPreview(getPreview(mRequest));
    }
    return dragHelper;
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) PendingAddItemInfo(com.android.launcher3.PendingAddItemInfo) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) PendingItemDragHelper(com.android.launcher3.widget.PendingItemDragHelper) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) WidgetAddFlowHandler(com.android.launcher3.widget.WidgetAddFlowHandler) View(android.view.View)

Example 2 with PendingItemDragHelper

use of com.android.launcher3.widget.PendingItemDragHelper in project android_packages_apps_Launcher3 by crdroidandroid.

the class BaseWidgetSheet method beginDraggingWidget.

private boolean beginDraggingWidget(WidgetCell v) {
    // Get the widget preview as the drag representation
    WidgetImageView image = v.getWidgetView();
    // we abort the drag.
    if (image.getDrawable() == null && v.getAppWidgetHostViewPreview() == null) {
        return false;
    }
    PendingItemDragHelper dragHelper = new PendingItemDragHelper(v);
    dragHelper.setRemoteViewsPreview(v.getRemoteViewsPreview());
    dragHelper.setAppWidgetHostViewPreview(v.getAppWidgetHostViewPreview());
    if (image.getDrawable() != null) {
        int[] loc = new int[2];
        getPopupContainer().getLocationInDragLayer(image, loc);
        dragHelper.startDrag(image.getBitmapBounds(), image.getDrawable().getIntrinsicWidth(), image.getWidth(), new Point(loc[0], loc[1]), this, new DragOptions());
    } else {
        View preview = v.getAppWidgetHostViewPreview();
        int[] loc = new int[2];
        getPopupContainer().getLocationInDragLayer(preview, loc);
        Rect r = new Rect(0, 0, preview.getWidth(), preview.getHeight());
        dragHelper.startDrag(r, preview.getMeasuredWidth(), preview.getMeasuredWidth(), new Point(loc[0], loc[1]), this, new DragOptions());
    }
    close(true);
    return true;
}
Also used : DragOptions(com.android.launcher3.dragndrop.DragOptions) Rect(android.graphics.Rect) Point(android.graphics.Point) View(android.view.View) AbstractSlideInView(com.android.launcher3.views.AbstractSlideInView) ArrowTipView(com.android.launcher3.views.ArrowTipView)

Aggregations

View (android.view.View)2 Point (android.graphics.Point)1 Rect (android.graphics.Rect)1 PendingAddItemInfo (com.android.launcher3.PendingAddItemInfo)1 DragOptions (com.android.launcher3.dragndrop.DragOptions)1 AbstractSlideInView (com.android.launcher3.views.AbstractSlideInView)1 ArrowTipView (com.android.launcher3.views.ArrowTipView)1 LauncherAppWidgetProviderInfo (com.android.launcher3.widget.LauncherAppWidgetProviderInfo)1 PendingAddShortcutInfo (com.android.launcher3.widget.PendingAddShortcutInfo)1 PendingAddWidgetInfo (com.android.launcher3.widget.PendingAddWidgetInfo)1 PendingItemDragHelper (com.android.launcher3.widget.PendingItemDragHelper)1 WidgetAddFlowHandler (com.android.launcher3.widget.WidgetAddFlowHandler)1