Example usage for android.graphics Rect setEmpty

List of usage examples for android.graphics Rect setEmpty

Introduction

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

Prototype

public void setEmpty() 

Source Link

Document

Set the rectangle to (0,0,0,0)

Usage

From source file:com.facebook.litho.utils.IncrementalMountUtils.java

private static void release(Rect rect) {
    rect.setEmpty();
    sRectPool.release(rect);
}

From source file:com.facebook.litho.ComponentsPools.java

@ThreadSafe(enableChecks = false)
static void release(Rect rect) {
    if (!ComponentsConfiguration.usePooling) {
        return;//from w  w w . ja  va 2 s  . c  om
    }
    rect.setEmpty();
    sRectPool.release(rect);
}

From source file:au.com.roadhouse.licensehelper.library.VerticalDividerItemDecorator.java

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    RecyclerView.Adapter adapter = parent.getAdapter();
    if (parent.getChildAdapterPosition(view) != 0
            && parent.getChildAdapterPosition(view) < adapter.getItemCount()) {
        outRect.set(0, 0, 0, mDividerHeight);
    } else {//from   w w  w  .j a v  a  2  s  . c  o  m
        outRect.setEmpty();
    }
}

From source file:de.vanita5.twittnuker.adapter.decorator.DividerItemDecoration.java

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

From source file:org.getlantern.firetweet.adapter.decorator.DividerItemDecoration.java

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, State state) {
    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;/* w  w w  .  j a  v  a 2  s  .  c  o  m*/
    }
    if (mOrientation == VERTICAL_LIST) {
        outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
    } else {
        outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
    }
}

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;//from   w  ww . 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:com.mad.splitlist.util.DividerItemDecoration.java

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();

    // Position in the list.
    final int position = params.getViewAdapterPosition();

    // Add space for the separator except the last.
    if (position < state.getItemCount()) {
        outRect.set(0, 0, 0, (int) mPaint.getStrokeWidth());
    } else {/*from  ww  w  .  j av  a  2s.c om*/
        outRect.setEmpty();
    }
}

From source file:com.android.switchaccess.SwitchAccessNodeCompat.java

/**
 * Find the largest sub-rectangle that doesn't intersect a specified one.
 *
 * @param rectToModify The rect that may be modified to avoid intersections
 * @param otherRect The rect that should be avoided
 *//* ww  w .  j a  v a2 s .  c  o  m*/
private static void adjustRectToAvoidIntersection(Rect rectToModify, Rect otherRect) {
    /*
     * Some rectangles are flipped around (left > right). Make sure we have two Rects free of
     * such pathologies.
     */
    rectToModify.sort();
    otherRect.sort();
    /*
     * Intersect rectToModify with four rects that represent cuts of the entire space along
     * lines defined by the otherRect's edges
     */
    Rect[] cuts = { new Rect(Integer.MIN_VALUE, Integer.MIN_VALUE, otherRect.left, Integer.MAX_VALUE),
            new Rect(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, otherRect.top),
            new Rect(otherRect.right, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE),
            new Rect(Integer.MIN_VALUE, otherRect.bottom, Integer.MAX_VALUE, Integer.MAX_VALUE) };

    int maxIntersectingRectArea = 0;
    int indexOfLargestIntersection = -1;
    for (int i = 0; i < cuts.length; i++) {
        if (cuts[i].intersect(rectToModify)) {
            /* Reassign this cut to its intersection with rectToModify */
            int visibleRectArea = cuts[i].width() * cuts[i].height();
            if (visibleRectArea > maxIntersectingRectArea) {
                maxIntersectingRectArea = visibleRectArea;
                indexOfLargestIntersection = i;
            }
        }
    }
    if (maxIntersectingRectArea <= 0) {
        // The rectToModify isn't within any of our cuts, so it's entirely occuled by otherRect.
        rectToModify.setEmpty();
        return;
    }
    rectToModify.set(cuts[indexOfLargestIntersection]);
}

From source file:org.telegram.ui.Components.Switch.java

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);

    wasLayout = true;//  w w  w.j a v a2  s.  c  o  m
    int opticalInsetLeft = 0;
    int opticalInsetRight = 0;
    if (mThumbDrawable != null) {
        final Rect trackPadding = mTempRect;
        if (mTrackDrawable != null) {
            mTrackDrawable.getPadding(trackPadding);
        } else {
            trackPadding.setEmpty();
        }

        final Insets insets = Insets.NONE;
        opticalInsetLeft = Math.max(0, insets.left - trackPadding.left);
        opticalInsetRight = Math.max(0, insets.right - trackPadding.right);
    }

    final int switchRight;
    final int switchLeft;
    if (LocaleController.isRTL) {
        switchLeft = getPaddingLeft() + opticalInsetLeft;
        switchRight = switchLeft + mSwitchWidth - opticalInsetLeft - opticalInsetRight;
    } else {
        switchRight = getWidth() - getPaddingRight() - opticalInsetRight;
        switchLeft = switchRight - mSwitchWidth + opticalInsetLeft + opticalInsetRight;
    }

    final int switchTop;
    final int switchBottom;
    switch (getGravity() & Gravity.VERTICAL_GRAVITY_MASK) {
    default:
    case Gravity.TOP:
        switchTop = getPaddingTop();
        switchBottom = switchTop + mSwitchHeight;
        break;

    case Gravity.CENTER_VERTICAL:
        switchTop = (getPaddingTop() + getHeight() - getPaddingBottom()) / 2 - mSwitchHeight / 2;
        switchBottom = switchTop + mSwitchHeight;
        break;

    case Gravity.BOTTOM:
        switchBottom = getHeight() - getPaddingBottom();
        switchTop = switchBottom - mSwitchHeight;
        break;
    }

    mSwitchLeft = switchLeft;
    mSwitchTop = switchTop;
    mSwitchBottom = switchBottom;
    mSwitchRight = switchRight;
}

From source file:org.telegram.ui.Components.Switch.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    final Rect padding = mTempRect;
    final Drawable trackDrawable = mTrackDrawable;
    if (trackDrawable != null) {
        trackDrawable.getPadding(padding);
    } else {// w  w  w.  j a  v  a 2s  .  com
        padding.setEmpty();
    }

    final int switchTop = mSwitchTop;
    final int switchBottom = mSwitchBottom;

    final Drawable thumbDrawable = mThumbDrawable;
    if (trackDrawable != null) {
        if (mSplitTrack && thumbDrawable != null) {
            final Insets insets = Insets.NONE;
            thumbDrawable.copyBounds(padding);
            padding.left += insets.left;
            padding.right -= insets.right;

            final int saveCount = canvas.save();
            canvas.clipRect(padding, Region.Op.DIFFERENCE);
            trackDrawable.draw(canvas);
            canvas.restoreToCount(saveCount);
        } else {
            trackDrawable.draw(canvas);
        }
    }

    final int saveCount = canvas.save();

    if (thumbDrawable != null) {
        thumbDrawable.draw(canvas);
    }

    canvas.restoreToCount(saveCount);
}