Search in sources :

Example 1 with DragObject

use of org.fairphone.launcher.DropTarget.DragObject in project Fairphone by Kwamecorp.

the class LauncherTransitionable method completeAddShortcut.

/**
	 * Add a shortcut to the workspace.
	 * 
	 * @param data
	 *            The intent describing the shortcut.
	 * @param cellInfo
	 *            The position on screen where to create the shortcut.
	 */
private void completeAddShortcut(Intent data, long container, int screen, int cellX, int cellY) {
    int[] cellXY = mTmpAddItemCellCoordinates;
    int[] touchXY = mPendingAddInfo.dropPos;
    CellLayout layout = getCellLayout(container, screen);
    boolean foundCellSpan = false;
    ShortcutInfo info = mModel.infoFromShortcutIntent(this, data, null);
    if (info == null) {
        return;
    }
    final View view = createShortcut(info);
    // add this item.
    if (cellX >= 0 && cellY >= 0) {
        cellXY[0] = cellX;
        cellXY[1] = cellY;
        foundCellSpan = true;
        // folder
        if (mWorkspace.createUserFolderIfNecessary(view, container, layout, cellXY, 0, true, null, null)) {
            return;
        }
        DragObject dragObject = new DragObject();
        dragObject.dragInfo = info;
        if (mWorkspace.addToExistingFolderIfNecessary(view, layout, cellXY, 0, dragObject, true)) {
            return;
        }
    } else if (touchXY != null) {
        // when dragging and dropping, just find the closest free spot
        int[] result = layout.findNearestVacantArea(touchXY[0], touchXY[1], 1, 1, cellXY);
        foundCellSpan = (result != null);
    } else {
        foundCellSpan = layout.findCellForSpan(cellXY, 1, 1);
    }
    if (!foundCellSpan) {
        showOutOfSpaceMessage(isHotseatLayout(layout));
        return;
    }
    LauncherModel.addItemToDatabase(this, info, container, screen, cellXY[0], cellXY[1], false);
    if (!mRestoring) {
        mWorkspace.addInScreen(view, container, screen, cellXY[0], cellXY[1], 1, 1, isWorkspaceLocked());
    }
}
Also used : DragObject(org.fairphone.launcher.DropTarget.DragObject) ImageView(android.widget.ImageView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

AppWidgetHostView (android.appwidget.AppWidgetHostView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 DragObject (org.fairphone.launcher.DropTarget.DragObject)1