List of usage examples for android.graphics Rect set
public void set(int left, int top, int right, int bottom)
From source file:com.ruesga.rview.widget.DividerItemDecoration.java
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (parent.getChildAdapterPosition(view) == parent.getChildCount() - 1) { return;// w w w.j a v a 2s . c om } if (mOrientation == VERTICAL) { outRect.set(0, 0, 0, mDivider.getIntrinsicHeight()); } else { outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0); } }
From source file:com.seongil.recyclerviewlife.decor.RecyclerViewDividerItemDecor.java
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); if (mOrientation == RecyclerView.VERTICAL) { outRect.set(0, 0, 0, mDividerDrawable.getIntrinsicHeight()); } else {/*from w ww. ja v a 2 s . c o m*/ outRect.set(0, 0, mDividerDrawable.getIntrinsicWidth(), 0); } }
From source file:com.loopeer.codereader.ui.decoration.DividerItemDecorationMainList.java
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); if (mOrientation == VERTICAL_LIST) { if (parent.getChildAdapterPosition(view) == 0) { outRect.set(0, 0, 0, mContext.getResources().getDimensionPixelSize(R.dimen.medium_padding)); } else if (parent.getChildAdapterPosition(view) != parent.getAdapter().getItemCount() - 1) { outRect.set(0, 0, 0, dividerHeight); } else {/* w ww . j av a 2 s.c o m*/ outRect.set(0, 0, 0, 0); } } else { if (parent.getChildAdapterPosition(view) != parent.getAdapter().getItemCount() - 1) { outRect.set(0, 0, dividerHeight, 0); } else { outRect.set(0, 0, 0, 0); } } }
From source file:com.pachong.android.baseuicomponent.DividerItemDecoration.java
@Override public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) { //Add for ignore header view and footer view offsets if (!shouldDrawItemAtAdapterPosi(parent, itemPosition)) { outRect.set(0, 0, 0, 0); return;/*from w w w.j a va 2 s. c o m*/ } //End added if (mOrientation == VERTICAL_LIST) { outRect.set(0, 0, 0, mDivider.getIntrinsicHeight()); } else { outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0); } }
From source file:com.huyn.demogroup.bahavior.widget.HeaderScrollingViewBehavior.java
@Override protected void layoutChild(final CoordinatorLayout parent, final View child, final int layoutDirection) { final List<View> dependencies = parent.getDependencies(child); final View header = findFirstDependency(dependencies); if (header != null) { final CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); final Rect available = mTempRect1; SysoutUtil.sysout("HeaderScrollingViewBehavior", "layoutChild", "header.bottom:" + header.getBottom()); available.set(parent.getPaddingLeft() + lp.leftMargin, header.getBottom() + lp.topMargin, parent.getWidth() - parent.getPaddingRight() - lp.rightMargin, parent.getHeight() + header.getBottom() - parent.getPaddingBottom() - lp.bottomMargin); final WindowInsetsCompat parentInsets = parent.getLastWindowInsets(); if (parentInsets != null && ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { // If we're set to handle insets but this child isn't, then it has been measured as // if there are no insets. We need to lay it out to match horizontally. // Top and bottom and already handled in the logic above available.left += parentInsets.getSystemWindowInsetLeft(); available.right -= parentInsets.getSystemWindowInsetRight(); }//from w w w.jav a 2 s . c o m final Rect out = mTempRect2; GravityCompat.apply(resolveGravity(lp.gravity), child.getMeasuredWidth(), child.getMeasuredHeight(), available, out, layoutDirection); final int overlap = getOverlapPixelsForOffset(header); child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap); mVerticalLayoutGap = out.top - header.getBottom(); } else { // If we don't have a dependency, let super handle it super.layoutChild(parent, child, layoutDirection); mVerticalLayoutGap = 0; } }
From source file:com.hgdendi.contactslist.common.FloatingBarItemDecoration.java
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); int position = ((RecyclerView.LayoutParams) view.getLayoutParams()).getViewAdapterPosition(); outRect.set(0, mList.containsKey(position) ? mTitleHeight : 0, 0, 0); }
From source file:Main.java
/** * Returns a Bitmap representing the thumbnail of the specified Bitmap. The * size of the thumbnail is defined by the dimension * android.R.dimen.launcher_application_icon_size. * <p>/* ww w.j a v a 2s. co m*/ * This method is not thread-safe and should be invoked on the UI thread * only. * * @param bitmap The bitmap to get a thumbnail of. * @param context The application's context. * @return A thumbnail for the specified bitmap or the bitmap itself if the * thumbnail could not be created. */ public static Bitmap createThumbnailBitmap(Bitmap bitmap, Context context) { int sIconWidth = -1; int sIconHeight = -1; final Resources resources = context.getResources(); sIconWidth = sIconHeight = (int) resources.getDimension(android.R.dimen.app_icon_size); final Paint sPaint = new Paint(); final Rect sBounds = new Rect(); final Rect sOldBounds = new Rect(); Canvas sCanvas = new Canvas(); int width = sIconWidth; int height = sIconHeight; sCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG, Paint.FILTER_BITMAP_FLAG)); final int bitmapWidth = bitmap.getWidth(); final int bitmapHeight = bitmap.getHeight(); if (width > 0 && height > 0) { if (width < bitmapWidth || height < bitmapHeight) { final float ratio = (float) bitmapWidth / bitmapHeight; if (bitmapWidth > bitmapHeight) { height = (int) (width / ratio); } else if (bitmapHeight > bitmapWidth) { width = (int) (height * ratio); } final Config c = (width == sIconWidth && height == sIconHeight) ? bitmap.getConfig() : Config.ARGB_8888; final Bitmap thumb = Bitmap.createBitmap(sIconWidth, sIconHeight, c); final Canvas canvas = sCanvas; final Paint paint = sPaint; canvas.setBitmap(thumb); paint.setDither(false); paint.setFilterBitmap(true); sBounds.set((sIconWidth - width) / 2, (sIconHeight - height) / 2, width, height); sOldBounds.set(0, 0, bitmapWidth, bitmapHeight); canvas.drawBitmap(bitmap, sOldBounds, sBounds, paint); return thumb; } else if (bitmapWidth < width || bitmapHeight < height) { final Config c = Config.ARGB_8888; final Bitmap thumb = Bitmap.createBitmap(sIconWidth, sIconHeight, c); final Canvas canvas = sCanvas; final Paint paint = sPaint; canvas.setBitmap(thumb); paint.setDither(false); paint.setFilterBitmap(true); canvas.drawBitmap(bitmap, (sIconWidth - bitmapWidth) / 2, (sIconHeight - bitmapHeight) / 2, paint); return thumb; } } return bitmap; }
From source file:ru.jango.j0widget.imagebrowser.ImageBrowserView.java
/** * Viewport determines some special part of the bitmap, that should be shown. But a View * itself also has paddings and margins. This method creates a rect, that determines, where * View's content should actually be drawn. * * @param ret object, through witch the result would be returned *///from www . j a v a 2 s.c om private void makeViewportDestRect(final Rect ret) { ret.set(0, 0, 0, 0); ret.right = (int) Math.floor(viewport.width() / getViewportScaleFactor()); ret.bottom = (int) Math.floor(viewport.height() / getViewportScaleFactor()); if (contentRect.width() - ret.right > 1) ret.offset((int) Math.ceil((contentRect.width() - ret.right) / 2), 0); if (contentRect.height() - ret.bottom > 1) ret.offset(0, (int) Math.ceil((contentRect.height() - ret.bottom) / 2)); }
From source file:com.jun.jokedaquan.widget.divider.DividerItemDecoration.java
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (enabled) { if (mOrientation == VERTICAL_LIST) { outRect.set(0, 0, 0, mDivider.getIntrinsicHeight()); } else {//from w w w .jav a 2s.c om outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0); } } }
From source file:com.hippo.widget.recyclerview.LinearDividerItemDecoration.java
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (parent.getAdapter() == null) { outRect.set(0, 0, 0, 0); return;/*from w w w .jav a 2 s . c o m*/ } if (mOverlap) { outRect.set(0, 0, 0, 0); return; } final int position = parent.getChildLayoutPosition(view); final int itemCount = parent.getAdapter().getItemCount(); if (mShowDividerHelper != null) { if (mOrientation == VERTICAL) { if (position == 0 && mShowDividerHelper.showDivider(0)) { outRect.top = mThickness; } if (mShowDividerHelper.showDivider(position + 1)) { outRect.bottom = mThickness; } } else { if (position == 0 && mShowDividerHelper.showDivider(0)) { outRect.left = mThickness; } if (mShowDividerHelper.showDivider(position + 1)) { outRect.right = mThickness; } } } else { if (mOrientation == VERTICAL) { if (position == 0 && mShowFirstDivider) { outRect.top = mThickness; } outRect.bottom = mThickness; if (position == itemCount - 1 && !mShowLastDivider) { outRect.bottom = 0; } } else { if (position == 0 && mShowFirstDivider) { outRect.left = mThickness; } outRect.right = mThickness; if (position == itemCount - 1 && !mShowLastDivider) { outRect.right = 0; } } } }