Search in sources :

Example 21 with WidgetImageView

use of com.android.launcher3.widget.WidgetImageView in project android_packages_apps_Launcher3 by AOSPA.

the class BaseWidgetSheet method beginDraggingWidget.

private boolean beginDraggingWidget(WidgetCell v) {
    if (TestProtocol.sDebugTracing) {
        Log.d(TestProtocol.NO_DROP_TARGET, "2");
    }
    // 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);
    // RemoteViews are being rendered in AppWidgetHostView in WidgetCell. And thus, the scale of
    // RemoteViews is equivalent to the AppWidgetHostView scale.
    dragHelper.setRemoteViewsPreview(v.getRemoteViewsPreview(), v.getAppWidgetHostViewScale());
    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 {
        NavigableAppWidgetHostView preview = v.getAppWidgetHostViewPreview();
        int[] loc = new int[2];
        getPopupContainer().getLocationInDragLayer(preview, loc);
        Rect r = new Rect();
        preview.getWorkspaceVisualDragBounds(r);
        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)

Aggregations

Point (android.graphics.Point)21 Rect (android.graphics.Rect)19 ClipData (android.content.ClipData)7 ClipDescription (android.content.ClipDescription)7 Intent (android.content.Intent)7 Canvas (android.graphics.Canvas)7 Paint (android.graphics.Paint)7 Drawable (android.graphics.drawable.Drawable)7 DragShadowBuilder (android.view.View.DragShadowBuilder)7 DeviceProfile (com.android.launcher3.DeviceProfile)7 Launcher (com.android.launcher3.Launcher)7 LauncherAppState (com.android.launcher3.LauncherAppState)7 DragOptions (com.android.launcher3.dragndrop.DragOptions)7 LauncherIcons (com.android.launcher3.icons.LauncherIcons)7 WidgetImageView (com.android.launcher3.widget.WidgetImageView)7 DraggableView (com.android.launcher3.dragndrop.DraggableView)6 FastBitmapDrawable (com.android.launcher3.icons.FastBitmapDrawable)5 RoundDrawableWrapper (com.android.launcher3.icons.RoundDrawableWrapper)5 NavigableAppWidgetHostView (com.android.launcher3.widget.NavigableAppWidgetHostView)5 AppWidgetHostViewDragListener (com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener)5