Drawable isStateful - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Drawable isStateful method.

This code example shows how to use the following methods:isStateful, setState
    } 
 
    @Override 
    protected void drawableStateChanged() { 
        Drawable d = mBackground;
        if (d != null && d.isStateful()) {
            d.setState(getDrawableState());
        } 
        super.drawableStateChanged(); 
    } 
 
    @Override 
    public void draw(Canvas canvas) {
        final Drawable background = mBackground;
        if (background != null) {
            if (mBackgroundSizeChanged) {
                mBackgroundSizeChanged = false;
                Rect chld = mTmp0;
                Rect bkg = mTmp1;
                mBackground.getPadding(bkg);
7
CodeRank
This code example shows how to use the following methods:getIntrinsicHeight, getIntrinsicWidth, isStateful, setBounds, setCallback
 
            mDotDrawable = dotDrawable;
 
            if (dotDrawable != null) {
 
                if (dotDrawable.getIntrinsicHeight() == -1 || dotDrawable.getIntrinsicWidth() == -1) {
                    // Do not accept Drawable with no intrinsic dimensions. 
                    return; 
                } 
 
                dotDrawable.setBounds(0, 0, dotDrawable.getIntrinsicWidth(), dotDrawable.getIntrinsicHeight());
                dotDrawable.setCallback(this);
                if (dotDrawable.isStateful()) {
                    dotDrawable.setState(getDrawableState());
                } 
            } 
 
            requestLayout(); 
            invalidate(); 
        } 
7
CodeRank
This code example shows how to use the following methods:isStateful, setState
            mBackground.setState(getDrawableState());
        } 
        if (mStackedBackground != null && mStackedBackground.isStateful()) {
            mStackedBackground.setState(getDrawableState());
        } 
        if (mSplitBackground != null && mSplitBackground.isStateful()) {
            mSplitBackground.setState(getDrawableState());
        } 
    } 
 
    @Override 
    public void jumpDrawablesToCurrentState() { 
        super.jumpDrawablesToCurrentState(); 
        if (mBackground != null) {
            mBackground.jumpToCurrentState();
        } 
        if (mStackedBackground != null) {
            mStackedBackground.jumpToCurrentState();
        } 
        if (mSplitBackground != null) {
7
CodeRank
This code example shows how to use the following methods:isStateful
        mDrawable.setColorFilter(cf);
    } 
 
    @Override 
    public boolean isStateful() { 
        return mDrawable.isStateful();
    } 
 
    @Override 
    public boolean setState(final int[] stateSet) {
        return mDrawable.setState(stateSet);
    } 
 
    @Override 
    public int[] getState() { 
        return mDrawable.getState();
    } 
 
    @Override 
    public void jumpToCurrentState() { 
6
CodeRank
This code example shows how to use the following methods:isStateful, setState
    } 
 
    @Override 
    protected void drawableStateChanged() { 
        Drawable d = mBackground;
        if (d != null && d.isStateful()) {
            d.setState(getDrawableState());
        } 
        super.drawableStateChanged(); 
    } 
 
    @Override 
    public void draw(Canvas canvas) {
        final Drawable background = mBackground;
        if (background != null) {
            if (mBackgroundSizeChanged) {
                mBackgroundSizeChanged = false;
                Rect chld = mTmp0;
                Rect bkg = mTmp1;
                mBackground.getPadding(bkg);
7
CodeRank
This code example shows how to use the following methods:isStateful
        return pLeft != 0 && pTop != 0 && pRight != 0 && pBottom != 0;
    } 
 
    @Override 
    public boolean isStateful() { 
        return mLeftCapDrawable.isStateful() || mBottomAnchorDrawable.isStateful() || mRightCapDrawable.isStateful();
    } 
 
    @Override 
    protected boolean onStateChange(int[] state) {
        boolean result = false;
        result |= mLeftCapDrawable.setState(state);
        result |= mBottomAnchorDrawable.setState(state);
        result |= mRightCapDrawable.setState(state);
        if (result) {
            // It's weird but we need to invalidate on our own. The framework is 
            // not doing it by itself depending on the returned value here. 
            invalidateSelf();
        } 
        return result;
6
CodeRank
This code example shows how to use the following methods:isStateful, setState
    protected void drawableStateChanged() { 
        super.drawableStateChanged(); 
 
        // Update the state of the highlight drawable to match 
        // the state of the button. 
        if (mForegroundDrawable.isStateful()) {
            mForegroundDrawable.setState(getDrawableState());
        } 
 
        // Trigger a redraw. 
        invalidate();
    } 
 
    @Override 
    protected void onDraw(Canvas canvas) {
        // First draw the image. 
        super.onDraw(canvas);
 
        // Then draw the highlight on top of it. If the button is neither focused 
        // nor pressed, the drawable will be transparent, so just the image 
7
CodeRank
This code example shows how to use the following methods:isStateful, setState
    } 
 
    @Override 
    protected void drawableStateChanged() { 
        Drawable d = mBackground;
        if (d != null && d.isStateful()) {
            d.setState(getDrawableState());
        } 
        super.drawableStateChanged(); 
    } 
 
    @Override 
    public void draw(Canvas canvas) {
        final Drawable background = mBackground;
        if (background != null) {
            final int scrollX = getScrollX();
            final int scrollY = getScrollY();
 
            if (mBackgroundSizeChanged) {
                background.setBounds(0, 0,  getRight() - getLeft(), getBottom() - getTop());
6
CodeRank
This code example shows how to use the following methods:isStateful, setState
    } 
 
    @Override 
    protected void drawableStateChanged() { 
        Drawable d = mBackground;
        if (d != null && d.isStateful()) {
            d.setState(getDrawableState());
        } 
        super.drawableStateChanged(); 
    } 
 
    @Override 
    public void draw(Canvas canvas) {
        final Drawable background = mBackground;
        if (background != null) {
            final int scrollX = mScrollX;
            final int scrollY = mScrollY;
 
            if (mBackgroundSizeChanged) {
                background.setBounds(0, 0,  mRight - mLeft, mBottom - mTop);
6
CodeRank
This code example shows how to use the following methods:isStateful
		mDrawable.invalidateSelf();
	} 
 
	@Override 
	public boolean isStateful() { 
		return mDrawable.isStateful();
	} 
 
	@Override 
	protected void onBoundsChange( Rect bounds ) {
		super.onBoundsChange( bounds );
 
		mWidth = bounds.width();
		mHeight = bounds.height();
		 
		onTextBoundsChanged(); 
	} 
	 
	private int mTextY = 0;
	 
6
CodeRank
isStateful Method Overview
Indicates whether this view will change its appearance based on state.
See Code Examples for other Android Drawable Methods: