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;
}
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;
}
Aggregations