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.github.shareme.gwsmaterialuikit.library.material.drawable.PaddingDrawable.java

@Override
public boolean getPadding(@NonNull Rect padding) {
    boolean hasPadding = mDrawable != null && mDrawable.getPadding(padding);
    if (hasPadding) {
        padding.left += mPaddingLeft;/*from w  ww  .  ja  va  2s  . co m*/
        padding.top += mPaddingTop;
        padding.right += mPaddingRight;
        padding.bottom += mPaddingBottom;
    } else {
        padding.set(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
        hasPadding = mPaddingLeft != 0 || mPaddingTop != 0 || mPaddingRight != 0 || mPaddingBottom != 0;
    }

    return hasPadding;
}

From source file:catchla.yep.adapter.decorator.DividerItemDecoration.java

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, State state) {
    if (mDivider == null)
        return;/*ww w.j av  a  2s. c o m*/
    final int childPos = parent.getChildAdapterPosition(view);
    final int start = getDecorationStart(), end = getDecorationEnd(parent);
    if (start >= 0 && childPos < start || end >= 0 && childPos > end) {
        outRect.setEmpty();
        return;
    }
    if (mOrientation == VERTICAL_LIST) {
        outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
    } else {
        outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
    }
}

From source file:ca.barrenechea.widget.recyclerview.decoration.StickyHeaderDecoration.java

/**
 * {@inheritDoc}/*from w  w w  . j av a  2 s.c o m*/
 */
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    int position = parent.getChildAdapterPosition(view);
    int headerHeight = 0;

    if (position != RecyclerView.NO_POSITION && hasHeader(position) && showHeaderAboveItem(position)) {

        View header = getHeader(parent, position).itemView;
        headerHeight = getHeaderHeightForLayout(header);
    }

    outRect.set(0, headerHeight, 0, 0);
}

From source file:cc.solart.turbo.decoration.LinearDividerItemDecoration.java

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    final int adapterPosition = parent.getChildAdapterPosition(view);
    if (adapterPosition == parent.getAdapter().getItemCount() - 1) {
        return;//from www  .j  av  a  2  s.  c  o  m
    }

    if (mDividerOffsets.indexOfKey(adapterPosition) < 0) {
        mDividerOffsets.put(adapterPosition, getDivider(parent, adapterPosition).getIntrinsicHeight());
    }

    if (mOrientation == VERTICAL) {
        outRect.set(0, 0, 0, mDividerOffsets.get(parent.getChildAdapterPosition(view)));
    } else {
        outRect.set(0, 0, mDividerOffsets.get(parent.getChildAdapterPosition(view)), 0);
    }
}

From source file:android.support.design.widget.ShadowDrawableWrapper.java

@Override
public boolean getPadding(Rect padding) {
    int vOffset = (int) Math
            .ceil(calculateVerticalPadding(mRawMaxShadowSize, mCornerRadius, mAddPaddingForCorners));
    int hOffset = (int) Math
            .ceil(calculateHorizontalPadding(mRawMaxShadowSize, mCornerRadius, mAddPaddingForCorners));
    padding.set(hOffset, vOffset, hOffset, vOffset);
    return true;/*from   ww w.  j av  a 2  s  . co m*/
}

From source file:com.android.utils.traversal.DirectionalTraversalStrategy.java

/**
 * Returns the bounding rect of the given node for directional navigation purposes.
 * Any node that is a container of a focusable node will be reduced to a strip at its very
 * top edge./*from w w w  .j a  v a2s.c o  m*/
 */
private void getAssumedRectInScreen(AccessibilityNodeInfoCompat node, Rect assumedRect) {
    node.getBoundsInScreen(assumedRect);
    if (mContainers.contains(node)) {
        assumedRect.set(assumedRect.left, assumedRect.top, assumedRect.right, assumedRect.top + 1);
    }
}

From source file:android.support.designox.widget.FloatingActionButtonLollipop.java

void getPadding(Rect rect) {
    if (mShadowViewDelegate.isCompatPaddingEnabled()) {
        final float radius = mShadowViewDelegate.getRadius();
        final float maxShadowSize = getElevation() + mPressedTranslationZ;
        final int hPadding = (int) Math
                .ceil(ShadowDrawableWrapper.calculateHorizontalPadding(maxShadowSize, radius, false));
        final int vPadding = (int) Math
                .ceil(ShadowDrawableWrapper.calculateVerticalPadding(maxShadowSize, radius, false));
        rect.set(hPadding, vPadding, hPadding, vPadding);
    } else {/*from w ww.  j a v  a 2 s.c om*/
        rect.set(0, 0, 0, 0);
    }
}

From source file:com.dat.complexrecyclerviewdemo.recyclerviewinsidecardviewdemo.StickyHeaderDecoration.java

/**
 * {@inheritDoc}/*from  w  ww  .j  av a  2s .com*/
 */
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    int position = parent.getChildAdapterPosition(view);
    int headerHeight = 0;
    if (position == 0) {
        outRect.bottom = -4;
        return;
    }
    if (position != RecyclerView.NO_POSITION && hasHeader(position) && showHeaderAboveItem(position)) {

        View header = getHeader(parent, position).itemView;
        headerHeight = getHeaderHeightForLayout(header);
    }

    outRect.set(0, headerHeight, 0, 0);
}

From source file:android.support.design.widget.FloatingActionButtonLollipop.java

@Override
void getPadding(Rect rect) {
    if (mShadowViewDelegate.isCompatPaddingEnabled()) {
        final float radius = mShadowViewDelegate.getRadius();
        final float maxShadowSize = getElevation() + mPressedTranslationZ;
        final int hPadding = (int) Math
                .ceil(ShadowDrawableWrapper.calculateHorizontalPadding(maxShadowSize, radius, false));
        final int vPadding = (int) Math
                .ceil(ShadowDrawableWrapper.calculateVerticalPadding(maxShadowSize, radius, false));
        rect.set(hPadding, vPadding, hPadding, vPadding);
    } else {/*from  ww  w  .  j  a va  2 s. c  om*/
        rect.set(0, 0, 0, 0);
    }
}

From source file:ticwear.design.widget.FloatingActionButton.java

/**
 * Return in {@code rect} the bounds of the actual floating action button content in view-local
 * coordinates. This is defined as anything within any visible shadow.
 *
 * @return true if this view actually has been laid out and has a content rect, else false.
 *///w w  w.  j  a  va 2  s.c o m
public boolean getContentRect(@NonNull Rect rect) {
    if (ViewCompat.isLaidOut(this)) {
        rect.set(0, 0, getWidth(), getHeight());
        rect.left += mProgressPadding.left;
        rect.top += mProgressPadding.top;
        rect.right -= mProgressPadding.right;
        rect.bottom -= mProgressPadding.bottom;
        return true;
    } else {
        return false;
    }
}