use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Launcher3 by crdroidandroid.
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);
}
}
use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Launcher3 by crdroidandroid.
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);
}
}
}
}
use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Launcher3 by crdroidandroid.
the class CellLayout method rearrangementExists.
private boolean rearrangementExists(int cellX, int cellY, int spanX, int spanY, int[] direction, View ignoreView, ItemConfiguration solution) {
// Return early if get invalid cell positions
if (cellX < 0 || cellY < 0)
return false;
mIntersectingViews.clear();
mOccupiedRect.set(cellX, cellY, cellX + spanX, cellY + spanY);
// Mark the desired location of the view currently being dragged.
if (ignoreView != null) {
CellAndSpan c = solution.map.get(ignoreView);
if (c != null) {
c.cellX = cellX;
c.cellY = cellY;
}
}
Rect r0 = new Rect(cellX, cellY, cellX + spanX, cellY + spanY);
Rect r1 = new Rect();
for (View child : solution.map.keySet()) {
if (child == ignoreView)
continue;
CellAndSpan c = solution.map.get(child);
LayoutParams lp = (LayoutParams) child.getLayoutParams();
r1.set(c.cellX, c.cellY, c.cellX + c.spanX, c.cellY + c.spanY);
if (Rect.intersects(r0, r1)) {
if (!lp.canReorder) {
return false;
}
mIntersectingViews.add(child);
}
}
solution.intersectingViews = new ArrayList<>(mIntersectingViews);
// without also displacing that item.
if (attemptPushInDirection(mIntersectingViews, mOccupiedRect, direction, ignoreView, solution)) {
return true;
}
// Next we try moving the views as a block, but without requiring the push mechanic.
if (addViewsToTempLocation(mIntersectingViews, mOccupiedRect, direction, ignoreView, solution)) {
return true;
}
// Ok, they couldn't move as a block, let's move them individually
for (View v : mIntersectingViews) {
if (!addViewToTempLocation(v, mOccupiedRect, direction, solution)) {
return false;
}
}
return true;
}
use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Launcher3 by crdroidandroid.
the class CellLayout method copySolutionToTempState.
private void copySolutionToTempState(ItemConfiguration solution, View dragView) {
mTmpOccupied.clear();
int childCount = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = mShortcutsAndWidgets.getChildAt(i);
if (child == dragView)
continue;
LayoutParams lp = (LayoutParams) child.getLayoutParams();
CellAndSpan c = solution.map.get(child);
if (c != null) {
lp.tmpCellX = c.cellX;
lp.tmpCellY = c.cellY;
lp.cellHSpan = c.spanX;
lp.cellVSpan = c.spanY;
mTmpOccupied.markCells(c, true);
}
}
mTmpOccupied.markCells(solution, true);
}
use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project Neo-Launcher by NeoApplications.
the class AbstractQsbLayout method onMeasure.
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
DeviceProfile dp = mLauncher.getDeviceProfile();
int round = Math.round(((float) dp.iconSizePx) * 0.92f);
setMeasuredDimension(calculateMeasuredDimension(dp, round, widthMeasureSpec), View.MeasureSpec.getSize(heightMeasureSpec));
for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
View childAt = getChildAt(childCount);
measureChildWithMargins(childAt, widthMeasureSpec, 0, heightMeasureSpec, 0);
if (childAt.getMeasuredWidth() <= round) {
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
int measuredWidth = (round - childAt.getMeasuredWidth()) / 2;
layoutParams.rightMargin = measuredWidth;
layoutParams.leftMargin = measuredWidth;
}
}
}
Aggregations