Example usage for android.support.v4.graphics.drawable DrawableCompat setHotspotBounds

List of usage examples for android.support.v4.graphics.drawable DrawableCompat setHotspotBounds

Introduction

In this page you can find the example usage for android.support.v4.graphics.drawable DrawableCompat setHotspotBounds.

Prototype

public static void setHotspotBounds(Drawable drawable, int i, int i2, int i3, int i4) 

Source Link

Usage

From source file:com.acious.android.paginationseekbar.internal.compat.SeekBarCompat.java

public static void setHotspotBounds(Drawable drawable, int left, int top, int right, int bottom) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        //We don't want the full size rect, Lollipop ripple would be too big
        int size = (right - left) / 8;
        DrawableCompat.setHotspotBounds(drawable, left + size, top + size, right - size, bottom - size);
    } else {/*from w  w  w  . j  ava 2 s.  c  o  m*/
        drawable.setBounds(left, top, right, bottom);
    }
}

From source file:com.doomy.library.Internal.Compat.SeekBarCompat.java

/**
 * As our DiscreteSeekBar implementation uses a circular drawable on API < 21
 * we want to use the same method to set its bounds as the Ripple's hotspot bounds.
 *
 * @param drawable//from  ww  w  .  java  2 s  .  co  m
 * @param left
 * @param top
 * @param right
 * @param bottom
 */
public static void setHotspotBounds(Drawable drawable, int left, int top, int right, int bottom) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        //We don't want the full size rect, Lollipop ripple would be too big
        int size = (right - left) / 8;
        DrawableCompat.setHotspotBounds(drawable, left + size, top + size, right - size, bottom - size);
    } else {
        drawable.setBounds(left, top, right, bottom);
    }
}

From source file:android.support.graphics.drawable.VectorDrawableCommon.java

@Override
public void setHotspotBounds(int left, int top, int right, int bottom) {
    if (mDelegateDrawable != null) {
        DrawableCompat.setHotspotBounds(mDelegateDrawable, left, top, right, bottom);
        return;/*from  ww w .  j  av a 2  s . co m*/
    }
}

From source file:android.support.v7.graphics.drawable.DrawableWrapper.java

@Override
public void setHotspotBounds(int left, int top, int right, int bottom) {
    DrawableCompat.setHotspotBounds(mDrawable, left, top, right, bottom);
}

From source file:com.negusoft.greenmatter.drawable.CompoundDrawableWrapper.java

@Override
public void setHotspotBounds(int left, int top, int right, int bottom) {
    for (Drawable d : mSecondaryDrawables)
        DrawableCompat.setHotspotBounds(d, left, top, right, bottom);
    super.setHotspotBounds(left, top, right, bottom);
}

From source file:com.github.shareme.gwsmaterialuikit.library.material.drawable.PaddingDrawable.java

@Override
public void setHotspotBounds(int left, int top, int right, int bottom) {
    if (mDrawable != null)
        DrawableCompat.setHotspotBounds(mDrawable, left, top, right, bottom);
}

From source file:com.albedinsky.android.support.ui.graphics.drawable.DrawableWrapper.java

/**
 *//*from  w  w  w.  j a  va 2  s.  c  o m*/
@Override
public void setHotspotBounds(int left, int top, int right, int bottom) {
    DrawableCompat.setHotspotBounds(mDrawable, left, top, right, bottom);
}

From source file:codetail.graphics.drawables.LayerDrawable.java

@Override
public void setHotspotBounds(int left, int top, int right, int bottom) {
    final ChildDrawable[] array = mLayerState.mChildren;
    final int N = mLayerState.mNum;
    for (int i = 0; i < N; i++) {
        DrawableCompat.setHotspotBounds(array[i].mDrawable, left, top, right, bottom);
    }//  www. j a v  a2 s. c o  m

    if (mHotspotBounds == null) {
        mHotspotBounds = new Rect(left, top, right, bottom);
    } else {
        mHotspotBounds.set(left, top, right, bottom);
    }
}

From source file:android.support.v7.widget.SwitchCompat.java

@Override
public void draw(Canvas c) {
    final Rect padding = mTempRect;
    final int switchLeft = mSwitchLeft;
    final int switchTop = mSwitchTop;
    final int switchRight = mSwitchRight;
    final int switchBottom = mSwitchBottom;

    int thumbInitialLeft = switchLeft + getThumbOffset();

    final Rect thumbInsets;
    if (mThumbDrawable != null) {
        thumbInsets = DrawableUtils.getOpticalBounds(mThumbDrawable);
    } else {//from   www.j av  a2s .  c  o m
        thumbInsets = DrawableUtils.INSETS_NONE;
    }

    // Layout the track.
    if (mTrackDrawable != null) {
        mTrackDrawable.getPadding(padding);

        // Adjust thumb position for track padding.
        thumbInitialLeft += padding.left;

        // If necessary, offset by the optical insets of the thumb asset.
        int trackLeft = switchLeft;
        int trackTop = switchTop;
        int trackRight = switchRight;
        int trackBottom = switchBottom;
        if (thumbInsets != null && !thumbInsets.isEmpty()) {
            if (thumbInsets.left > padding.left) {
                trackLeft += thumbInsets.left - padding.left;
            }
            if (thumbInsets.top > padding.top) {
                trackTop += thumbInsets.top - padding.top;
            }
            if (thumbInsets.right > padding.right) {
                trackRight -= thumbInsets.right - padding.right;
            }
            if (thumbInsets.bottom > padding.bottom) {
                trackBottom -= thumbInsets.bottom - padding.bottom;
            }
        }
        mTrackDrawable.setBounds(trackLeft, trackTop, trackRight, trackBottom);
    }

    // Layout the thumb.
    if (mThumbDrawable != null) {
        mThumbDrawable.getPadding(padding);

        final int thumbLeft = thumbInitialLeft - padding.left;
        final int thumbRight = thumbInitialLeft + mThumbWidth + padding.right;
        mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom);

        final Drawable background = getBackground();
        if (background != null) {
            DrawableCompat.setHotspotBounds(background, thumbLeft, switchTop, thumbRight, switchBottom);
        }
    }

    // Draw the background.
    super.draw(c);
}

From source file:io.intrepid.russell.smileyswitch.support.SwitchCompat.java

@Override
public void draw(Canvas c) {
    final Rect padding = mTempRect;
    final int switchLeft = mSwitchLeft;
    final int switchTop = mSwitchTop;
    final int switchRight = mSwitchRight;
    final int switchBottom = mSwitchBottom;

    int thumbInitialLeft = switchLeft + getThumbOffset();

    final Rect thumbInsets;
    if (mThumbDrawable != null) {
        thumbInsets = DrawableUtils.getOpticalBounds(mThumbDrawable);
    } else {/*from   ww  w  .  j  ava2 s  .  c o  m*/
        thumbInsets = DrawableUtils.INSETS_NONE;
    }

    // Layout the track.
    if (mTrackDrawable != null) {
        mTrackDrawable.getPadding(padding);

        // Adjust thumb position for track padding.
        thumbInitialLeft += padding.left;

        // If necessary, offset by the optical insets of the thumb asset.
        int trackLeft = switchLeft;
        int trackTop = switchTop;
        int trackRight = switchRight;
        int trackBottom = switchBottom;
        if (thumbInsets != null) {
            if (thumbInsets.left > padding.left) {
                trackLeft += thumbInsets.left - padding.left;
            }
            if (thumbInsets.top > padding.top) {
                trackTop += thumbInsets.top - padding.top;
            }
            if (thumbInsets.right > padding.right) {
                trackRight -= thumbInsets.right - padding.right;
            }
            if (thumbInsets.bottom > padding.bottom) {
                trackBottom -= thumbInsets.bottom - padding.bottom;
            }
        }
        mTrackDrawable.setBounds(trackLeft, trackTop, trackRight, trackBottom);
    }

    // Layout the thumb.
    if (mThumbDrawable != null) {
        mThumbDrawable.getPadding(padding);

        final int thumbLeft = thumbInitialLeft - padding.left;
        final int thumbRight = thumbInitialLeft + mThumbWidth + padding.right;
        mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom);

        final Drawable background = getBackground();
        if (background != null) {
            DrawableCompat.setHotspotBounds(background, thumbLeft, switchTop, thumbRight, switchBottom);
        }
    }

    // Draw the background.
    super.draw(c);
}