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.imageview.picasso.ImageView.java

public ImageView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageView, defStyleAttr, 0);

    Drawable errorDrawable = a.getDrawable(R.styleable.ImageView_error);
    setErrorDrawable(errorDrawable != null ? errorDrawable : getDrawable());

    a.recycle();/*w w  w . j a  v  a2s  .c  om*/

    if (!isInEditMode()) {
        mManager = Picasso.with(context);
    }
}

From source file:com.imageview.glide.ImageView.java

public ImageView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageView, defStyleAttr, 0);

    Drawable errorDrawable = a.getDrawable(R.styleable.ImageView_error);
    setErrorDrawable(errorDrawable != null ? errorDrawable : getDrawable());

    a.recycle();/*  w  w w  .jav  a  2 s  .com*/

    if (!isInEditMode()) {
        mManager = Glide.with(context);
    }
}

From source file:com.camnter.newlife.widget.decorator.DividerItemDecoration.java

public DividerItemDecoration(Context context, int orientation) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    this.mDivider = a.getDrawable(0);
    a.recycle();/*w w  w.j a  va  2  s  .  c  o m*/
    this.setOrientation(orientation);
}

From source file:com.example.lz.android_recycler_view_sample.DividerListItemDecoration.java

/**
 * 2px?//from   w  ww.  j  a va2s .  co m
 *
 * @param context
 * @param orientation ?
 */

public DividerListItemDecoration(Context context, int orientation) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);
    a.recycle();
    setOrientation(orientation);
}

From source file:com.jvacx.appcoes.auth.fragments.ScreenSlidePageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false);

    TypedArray bgs = getResources().obtainTypedArray(R.array.bgs);
    View view = rootView.findViewById(R.id.imgBackground);
    view.setBackground(bgs.getDrawable(getPageNumber()));

    return rootView;
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static Drawable getWindowBackground(final Context context, final int themeRes) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.windowBackground }, 0,
            themeRes);//from w  w w.ja  v a2s .c o m
    final Drawable d = a.getDrawable(0);
    a.recycle();
    if (isTransparentBackground(themeRes)) {
        applyThemeBackgroundAlphaToDrawable(context, d);
    }
    return d;
}

From source file:com.aqtc.bmobnews.widget.MultiSwipeRefreshLayout.java

public MultiSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MultiSwipeRefreshLayout, 0, 0);

    this.mForegroundDrawable = a.getDrawable(R.styleable.MultiSwipeRefreshLayout_foreground);
    if (this.mForegroundDrawable != null) {
        this.mForegroundDrawable.setCallback(this);
        setWillNotDraw(false);//from  ww w. j a va2  s  .  co m
    }

    a.recycle();
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

@Deprecated
public static Drawable getActionBarBackground(final Context context, final boolean applyAlpha) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.background },
            android.R.attr.actionBarStyle, 0);
    final Drawable d = a.getDrawable(0);
    a.recycle();//from   ww  w .  j  av  a 2s.  c om
    return applyActionBarDrawable(context, d, applyAlpha);
}

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

/**
 * Creates a divider {@link RecyclerView.ItemDecoration} that can be used with a
 * {@link LinearLayoutManager}.//w  w  w . ja v a 2  s  .  c  o m
 *
 * @param context Current context, it will be used to access resources.
 * @param orientation Divider orientation. Should be {@link #HORIZONTAL} or {@link #VERTICAL}.
 */
public DividerItemDecoration(Context context, int orientation) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);
    a.recycle();
    setOrientation(orientation);
}

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

public DividerItemDecoration(Context context, int orientation) {
    mPadding = new Rect();
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);
    a.recycle();/* w w w  .  j  a  v  a2 s. c o  m*/
    setOrientation(orientation);
}