Search in sources :

Example 11 with GridOccupancy

use of com.android.launcher3.util.GridOccupancy in project android_packages_apps_Launcher3 by crdroidandroid.

the class CellLayout method animateItemsToSolution.

private void animateItemsToSolution(ItemConfiguration solution, View dragView, boolean commitDragView) {
    GridOccupancy occupied = DESTRUCTIVE_REORDER ? mOccupied : mTmpOccupied;
    occupied.clear();
    int childCount = mShortcutsAndWidgets.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = mShortcutsAndWidgets.getChildAt(i);
        if (child == dragView)
            continue;
        CellAndSpan c = solution.map.get(child);
        if (c != null) {
            animateChildToPosition(child, c.cellX, c.cellY, REORDER_ANIMATION_DURATION, 0, DESTRUCTIVE_REORDER, false);
            occupied.markCells(c, true);
        }
    }
    if (commitDragView) {
        occupied.markCells(solution, true);
    }
}
Also used : CellAndSpan(com.android.launcher3.util.CellAndSpan) GridOccupancy(com.android.launcher3.util.GridOccupancy) View(android.view.View) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 12 with GridOccupancy

use of com.android.launcher3.util.GridOccupancy in project android_packages_apps_Launcher3 by crdroidandroid.

the class AddWorkspaceItemsTaskTest method writeWorkspaceWithHoles.

private int writeWorkspaceWithHoles(BgDataModel bgDataModel, int startId, int screenId, Rect... holes) {
    GridOccupancy occupancy = new GridOccupancy(mIdp.numColumns, mIdp.numRows);
    occupancy.markCells(0, 0, mIdp.numColumns, mIdp.numRows, true);
    for (Rect r : holes) {
        occupancy.markCells(r, false);
    }
    mExistingScreens.add(screenId);
    mScreenOccupancy.append(screenId, occupancy);
    for (int x = 0; x < mIdp.numColumns; x++) {
        for (int y = 0; y < mIdp.numRows; y++) {
            if (!occupancy.cells[x][y]) {
                continue;
            }
            WorkspaceItemInfo info = new WorkspaceItemInfo();
            info.intent = new Intent().setComponent(mComponent1);
            info.id = startId++;
            info.screenId = screenId;
            info.cellX = x;
            info.cellY = y;
            info.container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
            bgDataModel.addItem(mTargetContext, info, false);
            ContentWriter writer = new ContentWriter(mTargetContext);
            info.writeToValues(writer);
            writer.put(Favorites._ID, info.id);
            mTargetContext.getContentResolver().insert(Favorites.CONTENT_URI, writer.getValues(mTargetContext));
        }
    }
    return startId;
}
Also used : Rect(android.graphics.Rect) ContentWriter(com.android.launcher3.util.ContentWriter) Intent(android.content.Intent) GridOccupancy(com.android.launcher3.util.GridOccupancy) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

GridOccupancy (com.android.launcher3.util.GridOccupancy)12 Point (android.graphics.Point)5 SuppressLint (android.annotation.SuppressLint)3 Paint (android.graphics.Paint)3 Rect (android.graphics.Rect)2 View (android.view.View)2 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)2 Utilities.parsePoint (com.android.launcher3.Utilities.parsePoint)2 ItemInfo (com.android.launcher3.model.data.ItemInfo)2 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)2 CellAndSpan (com.android.launcher3.util.CellAndSpan)2 IntSparseArrayMap (com.android.launcher3.util.IntSparseArrayMap)2 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 ValueAnimator (android.animation.ValueAnimator)1 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)1 Intent (android.content.Intent)1 Workspace (com.android.launcher3.Workspace)1