Search in sources :

Example 16 with DragOptions

use of com.android.launcher3.dragndrop.DragOptions in project android_packages_apps_Launcher3 by crdroidandroid.

the class ItemLongClickListener method beginDrag.

public static void beginDrag(View v, Launcher launcher, ItemInfo info, DragOptions dragOptions) {
    if (info.container >= 0) {
        Folder folder = Folder.getOpen(launcher);
        if (folder != null) {
            if (!folder.getIconsInReadingOrder().contains(v)) {
                folder.close(true);
            } else {
                folder.startDrag(v, dragOptions);
                return;
            }
        }
    }
    CellLayout.CellInfo longClickCellInfo = new CellLayout.CellInfo(v, info);
    launcher.getWorkspace().startDrag(longClickCellInfo, dragOptions);
}
Also used : CellLayout(com.android.launcher3.CellLayout) Folder(com.android.launcher3.folder.Folder)

Example 17 with DragOptions

use of com.android.launcher3.dragndrop.DragOptions 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

Point (android.graphics.Point)7 Rect (android.graphics.Rect)6 View (android.view.View)5 AppWidgetHostView (android.appwidget.AppWidgetHostView)4 DragOptions (com.android.launcher3.dragndrop.DragOptions)4 DragView (com.android.launcher3.dragndrop.DragView)4 DraggableView (com.android.launcher3.dragndrop.DraggableView)4 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)4 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)4 SuppressLint (android.annotation.SuppressLint)3 Launcher (com.android.launcher3.Launcher)3 ItemInfo (com.android.launcher3.model.data.ItemInfo)3 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)3 Drawable (android.graphics.drawable.Drawable)2 CellLayout (com.android.launcher3.CellLayout)2 DeviceProfile (com.android.launcher3.DeviceProfile)2 DropTarget (com.android.launcher3.DropTarget)2 AccessibleDragListenerAdapter (com.android.launcher3.accessibility.AccessibleDragListenerAdapter)2 FastBitmapDrawable (com.android.launcher3.icons.FastBitmapDrawable)2 AppWidgetHostViewDragListener (com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener)2