Search in sources :

Example 6 with WidgetCell

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

the class WidgetsRecommendationTableLayout method addItemCell.

private WidgetCell addItemCell(ViewGroup parent) {
    WidgetCell widget = (WidgetCell) LayoutInflater.from(getContext()).inflate(R.layout.widget_cell, parent, false);
    widget.setOnTouchListener(mWidgetCellOnTouchListener);
    View previewContainer = widget.findViewById(R.id.widget_preview_container);
    previewContainer.setOnClickListener(mWidgetCellOnClickListener);
    previewContainer.setOnLongClickListener(mWidgetCellOnLongClickListener);
    widget.setAnimatePreview(false);
    widget.setSourceContainer(CONTAINER_WIDGETS_PREDICTION);
    parent.addView(widget);
    return widget;
}
Also used : WidgetCell(com.android.launcher3.widget.WidgetCell) View(android.view.View)

Example 7 with WidgetCell

use of com.android.launcher3.widget.WidgetCell 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

TableRow (android.widget.TableRow)5 WidgetCell (com.android.launcher3.widget.WidgetCell)5 WidgetItem (com.android.launcher3.model.WidgetItem)4 View (android.view.View)3 Bitmap (android.graphics.Bitmap)1 Point (android.graphics.Point)1 Rect (android.graphics.Rect)1 Size (android.util.Size)1 TableLayout (android.widget.TableLayout)1 DragOptions (com.android.launcher3.dragndrop.DragOptions)1 PackageUserKey (com.android.launcher3.util.PackageUserKey)1 AbstractSlideInView (com.android.launcher3.views.AbstractSlideInView)1 ArrowTipView (com.android.launcher3.views.ArrowTipView)1 ArrayList (java.util.ArrayList)1