Search in sources :

Example 31 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project Neo-Launcher by NeoApplications.

the class InsettableLinearLayout method setLinearLayoutChildInsets.

public void setLinearLayoutChildInsets(View child, Rect newInsets, Rect oldInsets) {
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    int childIndex = indexOfChild(child);
    int newTop = childIndex == 0 ? newInsets.top : 0;
    int oldTop = childIndex == 0 ? oldInsets.top : 0;
    int newBottom = childIndex == getChildCount() - 1 ? newInsets.bottom : 0;
    int oldBottom = childIndex == getChildCount() - 1 ? oldInsets.bottom : 0;
    if (child instanceof Insettable) {
        ((Insettable) child).setInsets(new Rect(newInsets.left, newTop, newInsets.right, newBottom));
    } else if (!lp.ignoreInsets) {
        lp.topMargin += (newTop - oldTop);
        lp.leftMargin += (newInsets.left - oldInsets.left);
        lp.rightMargin += (newInsets.right - oldInsets.right);
        lp.bottomMargin += (newBottom - oldBottom);
    }
    child.setLayoutParams(lp);
}
Also used : Rect(android.graphics.Rect) Insettable(com.android.launcher3.Insettable)

Example 32 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project Neo-Launcher by NeoApplications.

the class CellLayout method revertTempState.

void revertTempState() {
    completeAndClearReorderPreviewAnimations();
    if (isItemPlacementDirty() && !DESTRUCTIVE_REORDER) {
        final int count = mShortcutsAndWidgets.getChildCount();
        for (int i = 0; i < count; i++) {
            View child = mShortcutsAndWidgets.getChildAt(i);
            LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (lp.tmpCellX != lp.cellX || lp.tmpCellY != lp.cellY) {
                lp.tmpCellX = lp.cellX;
                lp.tmpCellY = lp.cellY;
                animateChildToPosition(child, lp.cellX, lp.cellY, REORDER_ANIMATION_DURATION, 0, false, false);
            }
        }
        setItemPlacementDirty(false);
    }
}
Also used : View(android.view.View) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 33 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project Neo-Launcher by NeoApplications.

the class CellLayout method copyCurrentStateToSolution.

private void copyCurrentStateToSolution(ItemConfiguration solution, boolean temp) {
    int childCount = mShortcutsAndWidgets.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = mShortcutsAndWidgets.getChildAt(i);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        CellAndSpan c;
        if (temp) {
            c = new CellAndSpan(lp.tmpCellX, lp.tmpCellY, lp.cellHSpan, lp.cellVSpan);
        } else {
            c = new CellAndSpan(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan);
        }
        solution.add(child, c);
    }
}
Also used : CellAndSpan(com.android.launcher3.util.CellAndSpan) View(android.view.View) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 34 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project Neo-Launcher by NeoApplications.

the class CellLayout method getViewsIntersectingRegion.

// For a given cell and span, fetch the set of views intersecting the region.
private void getViewsIntersectingRegion(int cellX, int cellY, int spanX, int spanY, View dragView, Rect boundingRect, ArrayList<View> intersectingViews) {
    if (boundingRect != null) {
        boundingRect.set(cellX, cellY, cellX + spanX, cellY + spanY);
    }
    intersectingViews.clear();
    Rect r0 = new Rect(cellX, cellY, cellX + spanX, cellY + spanY);
    Rect r1 = new Rect();
    final int count = mShortcutsAndWidgets.getChildCount();
    for (int i = 0; i < count; i++) {
        View child = mShortcutsAndWidgets.getChildAt(i);
        if (child == dragView)
            continue;
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        r1.set(lp.cellX, lp.cellY, lp.cellX + lp.cellHSpan, lp.cellY + lp.cellVSpan);
        if (Rect.intersects(r0, r1)) {
            mIntersectingViews.add(child);
            if (boundingRect != null) {
                boundingRect.union(r1);
            }
        }
    }
}
Also used : Rect(android.graphics.Rect) View(android.view.View) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 35 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project Neo-Launcher by NeoApplications.

the class CellLayout method commitTempPlacement.

private void commitTempPlacement() {
    mTmpOccupied.copyTo(mOccupied);
    int screenId = Launcher.cast(mActivity).getWorkspace().getIdForScreen(this);
    int container = Favorites.CONTAINER_DESKTOP;
    if (mContainerType == HOTSEAT) {
        screenId = -1;
        container = Favorites.CONTAINER_HOTSEAT;
    }
    int childCount = mShortcutsAndWidgets.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = mShortcutsAndWidgets.getChildAt(i);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        ItemInfo info = (ItemInfo) child.getTag();
        // AllApps button in the hotseat.
        if (info != null) {
            final boolean requiresDbUpdate = (info.cellX != lp.tmpCellX || info.cellY != lp.tmpCellY || info.spanX != lp.cellHSpan || info.spanY != lp.cellVSpan);
            info.cellX = lp.cellX = lp.tmpCellX;
            info.cellY = lp.cellY = lp.tmpCellY;
            info.spanX = lp.cellHSpan;
            info.spanY = lp.cellVSpan;
            if (requiresDbUpdate) {
                Launcher.cast(mActivity).getModelWriter().modifyItemInDatabase(info, container, screenId, info.cellX, info.cellY, info.spanX, info.spanY);
            }
        }
    }
}
Also used : View(android.view.View) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Aggregations

View (android.view.View)79 SuppressLint (android.annotation.SuppressLint)61 Paint (android.graphics.Paint)59 Point (android.graphics.Point)58 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)49 DraggableView (com.android.launcher3.dragndrop.DraggableView)40 CellAndSpan (com.android.launcher3.util.CellAndSpan)35 Rect (android.graphics.Rect)23 BubbleTextView (com.android.launcher3.BubbleTextView)21 ItemInfo (com.android.launcher3.model.data.ItemInfo)17 Animator (android.animation.Animator)16 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)16 ObjectAnimator (android.animation.ObjectAnimator)15 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)15 FrameLayout (android.widget.FrameLayout)13 DeviceProfile (com.android.launcher3.DeviceProfile)13 PagedOrientationHandler (com.android.launcher3.touch.PagedOrientationHandler)10 ValueAnimator (android.animation.ValueAnimator)9 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)8 TimeInterpolator (android.animation.TimeInterpolator)7