List of usage examples for android.graphics Rect set
public void set(int left, int top, int right, int bottom)
From source file:android.support.v7.widget.RecyclerView.java
Rect getItemDecorInsetsForChild(View child) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (!lp.mInsetsDirty) { return lp.mDecorInsets; }/* w w w. j ava 2 s . c o m*/ final Rect insets = lp.mDecorInsets; insets.set(0, 0, 0, 0); final int decorCount = mItemDecorations.size(); for (int i = 0; i < decorCount; i++) { mTempRect.set(0, 0, 0, 0); mItemDecorations.get(i).getItemOffsets(mTempRect, lp.getViewPosition(), this); insets.left += mTempRect.left; insets.top += mTempRect.top; insets.right += mTempRect.right; insets.bottom += mTempRect.bottom; } lp.mInsetsDirty = false; return insets; }
From source file:com.cognizant.trumobi.PersonaLauncher.java
protected void editWidget(final View widget) { if (mWorkspace != null) { mIsWidgetEditMode = true;/* w w w .j av a 2s . com*/ final PersonaCellLayout screen = (PersonaCellLayout) mWorkspace .getChildAt(mWorkspace.getCurrentScreen()); if (screen != null) { mlauncherAppWidgetInfo = (PersonaLauncherAppWidgetInfo) widget.getTag(); final Intent motosize = new Intent("com.motorola.blur.home.ACTION_SET_WIDGET_SIZE"); final int appWidgetId = ((AppWidgetHostView) widget).getAppWidgetId(); final AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId); if (appWidgetInfo != null) { motosize.setComponent(appWidgetInfo.provider); } motosize.putExtra("appWidgetId", appWidgetId); motosize.putExtra("com.motorola.blur.home.EXTRA_NEW_WIDGET", true); final int minw = (mWorkspace.getWidth() - screen.getLeftPadding() - screen.getRightPadding()) / screen.getCountX(); final int minh = (mWorkspace.getHeight() - screen.getBottomPadding() - screen.getTopPadding()) / screen.getCountY(); mScreensEditor = new PersonaResizeViewHandler(this); // Create a default HightlightView if we found no face in the // picture. int width = (mlauncherAppWidgetInfo.spanX * minw); int height = (mlauncherAppWidgetInfo.spanY * minh); final Rect screenRect = new Rect(0, 0, mWorkspace.getWidth() - screen.getRightPadding(), mWorkspace.getHeight() - screen.getBottomPadding()); final int x = mlauncherAppWidgetInfo.cellX * minw; final int y = mlauncherAppWidgetInfo.cellY * minh; final int[] spans = new int[] { 1, 1 }; final int[] position = new int[] { 1, 1 }; final PersonaCellLayout.LayoutParams lp = (PersonaCellLayout.LayoutParams) widget.getLayoutParams(); RectF widgetRect = new RectF(x, y, x + width, y + height); ((PersonaResizeViewHandler) mScreensEditor).setup(null, screenRect, widgetRect, false, false, minw - 10, minh - 10); mDragLayer.addView(mScreensEditor); ((PersonaResizeViewHandler) mScreensEditor) .setOnValidateSizingRect(new PersonaResizeViewHandler.OnSizeChangedListener() { @Override public void onTrigger(RectF r) { if (r != null) { final float left = Math.round(r.left / minw) * minw; final float top = Math.round(r.top / minh) * minh; final float right = left + (Math.max(Math.round(r.width() / (minw)), 1) * minw); final float bottom = top + (Math.max(Math.round(r.height() / (minh)), 1) * minh); r.set(left, top, right, bottom); } } }); final Rect checkRect = new Rect(); ((PersonaResizeViewHandler) mScreensEditor) .setOnSizeChangedListener(new PersonaResizeViewHandler.OnSizeChangedListener() { @Override public void onTrigger(RectF r) { int[] tmpspans = { Math.max(Math.round(r.width() / (minw)), 1), Math.max(Math.round(r.height() / (minh)), 1) }; int[] tmpposition = { Math.round(r.left / minw), Math.round(r.top / minh) }; checkRect.set(tmpposition[0], tmpposition[1], tmpposition[0] + tmpspans[0], tmpposition[1] + tmpspans[1]); boolean ocupada = getModel().ocuppiedArea(screen.getScreen(), appWidgetId, checkRect); if (!ocupada) { ((PersonaResizeViewHandler) mScreensEditor).setColliding(false); } else { ((PersonaResizeViewHandler) mScreensEditor).setColliding(true); } if (tmpposition[0] != position[0] || tmpposition[1] != position[1] || tmpspans[0] != spans[0] || tmpspans[1] != spans[1]) { if (!ocupada) { position[0] = tmpposition[0]; position[1] = tmpposition[1]; spans[0] = tmpspans[0]; spans[1] = tmpspans[1]; lp.cellX = position[0]; lp.cellY = position[1]; lp.cellHSpan = spans[0]; lp.cellVSpan = spans[1]; widget.setLayoutParams(lp); mlauncherAppWidgetInfo.cellX = lp.cellX; mlauncherAppWidgetInfo.cellY = lp.cellY; mlauncherAppWidgetInfo.spanX = lp.cellHSpan; mlauncherAppWidgetInfo.spanY = lp.cellVSpan; widget.setTag(mlauncherAppWidgetInfo); // send the broadcast motosize.putExtra("spanX", spans[0]); motosize.putExtra("spanY", spans[1]); PersonaLauncher.this.sendBroadcast(motosize); PersonaLog.d("RESIZEHANDLER", "sent resize broadcast"); } } } }); } } }
From source file:com.appunite.list.AbsHorizontalListView.java
void positionSelector(int position, View sel) { if (position != INVALID_POSITION) { mSelectorPosition = position;/* w w w. jav a2 s . co m*/ } final Rect selectorRect = mSelectorRect; selectorRect.set(sel.getLeft(), sel.getTop(), sel.getRight(), sel.getBottom()); if (sel instanceof SelectionBoundsAdjuster) { ((SelectionBoundsAdjuster) sel).adjustListItemSelectionBounds(selectorRect); } positionSelector(selectorRect.left, selectorRect.top, selectorRect.right, selectorRect.bottom); final boolean isChildViewEnabled = mIsChildViewEnabled; if (sel.isEnabled() != isChildViewEnabled) { mIsChildViewEnabled = !isChildViewEnabled; if (getSelectedItemPosition() != INVALID_POSITION) { refreshDrawableState(); } } }
From source file:android.support.v7.widget.RecyclerViewEx.java
Rect getItemDecorInsetsForChild(View child) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (!lp.mInsetsDirty) { return lp.mDecorInsets; }//from w w w. j a v a2s .c o m final Rect insets = lp.mDecorInsets; insets.set(0, 0, 0, 0); final int decorCount = mItemDecorations.size(); for (int i = 0; i < decorCount; i++) { mTempRect.set(0, 0, 0, 0); mItemDecorations.get(i).getItemOffsets(mTempRect, child, this, mState); insets.left += mTempRect.left; insets.top += mTempRect.top; insets.right += mTempRect.right; insets.bottom += mTempRect.bottom; } lp.mInsetsDirty = false; return insets; }
From source file:android.support.v71.widget.RecyclerView.java
/** * ??//from w w w . j a v a2 s . c om * * @param child * @return */ Rect getItemDecorInsetsForChild(View child) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (!lp.mInsetsDirty) { // ? return lp.mDecorInsets; } final Rect insets = lp.mDecorInsets; insets.set(0, 0, 0, 0); final int decorCount = mItemDecorations.size(); for (int i = 0; i < decorCount; i++) { mTempRect.set(0, 0, 0, 0); mItemDecorations.get(i).getItemOffsets(mTempRect, child, this, mState); insets.left += mTempRect.left; insets.top += mTempRect.top; insets.right += mTempRect.right; insets.bottom += mTempRect.bottom; } // lp.mInsetsDirty = false; return insets; }
From source file:com.ferdi2005.secondgram.support.widget.RecyclerView.java
static void getDecoratedBoundsWithMarginsInt(View view, Rect outBounds) { final LayoutParams lp = (LayoutParams) view.getLayoutParams(); final Rect insets = lp.mDecorInsets; outBounds.set(view.getLeft() - insets.left - lp.leftMargin, view.getTop() - insets.top - lp.topMargin, view.getRight() + insets.right + lp.rightMargin, view.getBottom() + insets.bottom + lp.bottomMargin); }
From source file:cn.ismartv.tvrecyclerview.widget.RecyclerView.java
Rect getItemDecorInsetsForChild(View child) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (!lp.mInsetsDirty) { return lp.mDecorInsets; }// ww w . j a v a 2s . c o m if (mState.isPreLayout() && (lp.isItemChanged() || lp.isViewInvalid())) { // changed/invalid items should not be updated until they are rebound. return lp.mDecorInsets; } final Rect insets = lp.mDecorInsets; insets.set(0, 0, 0, 0); final int decorCount = mItemDecorations.size(); for (int i = 0; i < decorCount; i++) { mTempRect.set(0, 0, 0, 0); mItemDecorations.get(i).getItemOffsets(mTempRect, child, this, mState); insets.left += mTempRect.left; insets.top += mTempRect.top; insets.right += mTempRect.right; insets.bottom += mTempRect.bottom; } lp.mInsetsDirty = false; return insets; }