Example usage for android.content.res TypedArray getDrawable

List of usage examples for android.content.res TypedArray getDrawable

Introduction

In this page you can find the example usage for android.content.res TypedArray getDrawable.

Prototype

@Nullable
public Drawable getDrawable(@StyleableRes int index) 

Source Link

Document

Retrieve the Drawable for the attribute at index.

Usage

From source file:com.mobidev.myliveonavigationmaterial.ui.widget.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;/*from   w  ww. j ava  2 s.co m*/
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForeground);
    a.recycle();
    setWillNotDraw(true);
}

From source file:com.holmes.ponderosa.ui.debug.NonConsumingScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NonConsumingScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;/* www . j  a v a 2s  .c  om*/
    }
    insetForeground = a.getDrawable(R.styleable.NonConsumingScrimInsetsView_insetForeground);
    a.recycle();

    setWillNotDraw(true);
}

From source file:com.team2052.frckrawler.views.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;/*  w  w  w  .  j av a2  s  .c  o m*/
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForeground_mine);
    a.recycle();

    setWillNotDraw(true);
}

From source file:com.appeaser.sublimenavigationviewlibrary.ScrimInsetsFrameLayout.java

public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.mTempRect = new Rect();
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SnvScrimInsetsFrameLayout, defStyleAttr,
            R.style.SnvScrimInsetsFrameLayout);
    this.mInsetForeground = a.getDrawable(R.styleable.SnvScrimInsetsFrameLayout_snvInsetForeground);
    a.recycle();//w  ww  .  j  av a2 s.  com
    this.setWillNotDraw(true);
    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            if (null == ScrimInsetsFrameLayout.this.mInsets) {
                ScrimInsetsFrameLayout.this.mInsets = new Rect();
            }

            ScrimInsetsFrameLayout.this.mInsets.set(insets.getSystemWindowInsetLeft(),
                    insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(),
                    insets.getSystemWindowInsetBottom());
            ScrimInsetsFrameLayout.this.setWillNotDraw(ScrimInsetsFrameLayout.this.mInsets.isEmpty()
                    || ScrimInsetsFrameLayout.this.mInsetForeground == null);
            ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
            return insets.consumeSystemWindowInsets();
        }
    });
}

From source file:com.saarang.samples.apps.iosched.ui.widget.DrawShadowFrameLayout.java

public DrawShadowFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs,
            com.saarang.samples.apps.iosched.R.styleable.DrawShadowFrameLayout, 0, 0);

    mShadowDrawable = a
            .getDrawable(com.saarang.samples.apps.iosched.R.styleable.DrawShadowFrameLayout_shadowDrawable);
    if (mShadowDrawable != null) {
        mShadowDrawable.setCallback(this);
        if (mShadowDrawable instanceof NinePatchDrawable) {
            mShadowNinePatchDrawable = (NinePatchDrawable) mShadowDrawable;
        }/*from   w ww .j  av a 2 s.c o  m*/
    }

    mShadowVisible = a
            .getBoolean(com.saarang.samples.apps.iosched.R.styleable.DrawShadowFrameLayout_shadowVisible, true);
    setWillNotDraw(!mShadowVisible || mShadowDrawable == null);

    a.recycle();
}

From source file:com.appdevper.mediaplayer.ui.ScrimInsetsRelativeLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;// www . ja  v  a2  s .  co m
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetFore);
    a.recycle();

    setWillNotDraw(true);
}

From source file:at.linuxtage.companion.widgets.ScrimInsetsFrameLayout.java

public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr,
            R.style.Widget_Design_ScrimInsetsFrameLayout);
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
    a.recycle();/*from  w  w w.  j  av  a2s . c  om*/
    setWillNotDraw(true); // No need to draw until the insets are adjusted
    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            if (null == mInsets) {
                mInsets = new Rect();
            }
            mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
            setWillNotDraw(mInsets.isEmpty() || mInsetForeground == null);
            ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
            return insets.consumeSystemWindowInsets();
        }
    });
}

From source file:com.commit451.springy.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;/*ww w. j a v  a2  s  .co  m*/
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForegroundDrawable);
    a.recycle();

    setWillNotDraw(true);
}

From source file:com.trabajo.sdm.blow.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;//w  w  w .  ja v  a  2s. c  o  m
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insForeground);
    a.recycle();

    setWillNotDraw(true);
}

From source file:com.vendomatica.vendroid.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;//from w  w  w.jav  a 2  s  .  c o  m
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForegroundSV);
    a.recycle();

    setWillNotDraw(true);
}