Example usage for android.graphics Rect set

List of usage examples for android.graphics Rect set

Introduction

In this page you can find the example usage for android.graphics Rect set.

Prototype

public void set(int left, int top, int right, int bottom) 

Source Link

Document

Set the rectangle's coordinates to the specified values.

Usage

From source file:com.retropoktan.rptrello.widget.DividerItemDecoration.java

@Override
public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
    if (itemPosition == parent.getAdapter().getItemCount() - 1) {
        outRect.set(0, 0, 0, 0);
        return;//from   w  ww. j a v  a  2  s .  co  m
    }
    if (mOrientation == VERTICAL_LIST) {
        outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
    } else {
        outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
    }
}

From source file:ingvar.android.literepo.examples.widget.DividerItemDecoration.java

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    if (mOrientation == LinearLayoutManager.VERTICAL) {
        outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
    } else {//from   w  w w.  ja  va  2 s.c  o  m
        outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
    }
}

From source file:android.support.design.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;
        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();
        }/*w  ww . j  a va  2 s  .  c  om*/

        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.study.newsclient.pages.design.behavior.helper.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;
        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();
         }*//*w w w  .jav a2s  .co  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.github.shareme.gwsmaterialuikit.library.advancerv.decoration.SimpleListDividerDecorator.java

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    if (mOverlap) {
        outRect.set(0, 0, 0, 0);
    } else {/*from  w  ww  . j  av a2  s .  co  m*/
        outRect.set(0, 0, mVerticalDividerWidth, mHorizontalDividerHeight);
    }
}

From source file:com.example.lz.android_recycler_view_sample.DividerListItemDecoration.java

@Override
public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
    if (mOrientation == VERTICAL_LIST) {
        outRect.set(0, 0, 0, mDividerHeight);
    } else {//ww  w  .j  a v a 2  s  . co m
        outRect.set(0, 0, mDividerHeight, 0);
    }
}

From source file:com.mlxing.mlguide.adapter.base.recyclerview.DividerItemDecoration.java

@Override
public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
    if (mOrientation == VERTICAL_LIST) {
        outRect.set(0, 0, 0, mDividerHeight);
    } else {/* w w  w  .j av  a2s . c o  m*/
        //mDivider.getIntrinsicWidth()
        outRect.set(0, 0, mDividerHeight, 0);
    }
}

From source file:com.yu.common.widget.ListItemDecoration.java

@Override
public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
    if (mOrientation == VERTICAL_LIST) {
        outRect.set(0, 0, 0, getDividerHeight());
    } else {//from w w w . j  a  v a 2  s.co  m
        outRect.set(0, 0, getDividerWidth(), 0);
    }
}

From source file:com.camnter.newlife.widget.decorator.DividerItemDecoration.java

/**
 * Retrieve any offsets for the given item. Each field of <code>outRect</code> specifies
 * the number of pixels that the item view should be inset by, similar to padding or margin.
 * The default implementation sets the bounds of outRect to 0 and returns.
 * <p/>//ww  w  .j av a 2 s. c o  m
 * <p/>
 * If this ItemDecoration does not affect the positioning of item views, it should set
 * all four fields of <code>outRect</code> (left, top, right, bottom) to zero
 * before returning.
 * <p/>
 * <p/>
 * If you need to access Adapter for additional data, you can call
 * {@link RecyclerView#getChildAdapterPosition(View)} to get the adapter position of the
 * View.
 *
 * @param outRect Rect to receive the output.
 * @param view    The child view to decorate
 * @param parent  RecyclerView this ItemDecoration is decorating
 * @param state   The current state of RecyclerView.
 */
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    if (mOrientation == VERTICAL_LIST) {
        outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
    } else {
        outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
    }
}

From source file:net.nym.napply.library.recycler.RecyclerViewLinearDivider.java

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    super.getItemOffsets(outRect, view, parent, state);
    outRect.set(0, 0, 0, mDividerHeight);
}