Example usage for android.support.v4.content.res ResourcesCompat getDrawable

List of usage examples for android.support.v4.content.res ResourcesCompat getDrawable

Introduction

In this page you can find the example usage for android.support.v4.content.res ResourcesCompat getDrawable.

Prototype

public static Drawable getDrawable(Resources resources, int i, Theme theme) throws NotFoundException 

Source Link

Usage

From source file:com.nttec.everychan.chans.cirno.NowereModule.java

@Override
public Drawable getChanFavicon() {
    return ResourcesCompat.getDrawable(resources, R.drawable.favicon_nowere, null);
}

From source file:com.nttec.everychan.ui.theme.ThemeUtils.java

/**
 *   (drawable) ? Action Bar.  ? Android 5.0    ??   android:attr/textColorPrimary
 * @param theme //from   www. j av a2s.c o  m
 * @param resources ??
 * @param attrId id  (R.attr.[...])
 * @return  Drawable ? ,  null, ?  ? 
 */
public static Drawable getActionbarIcon(Theme theme, Resources resources, int attrId) {
    try {
        int id = getThemeResId(theme, attrId);
        Drawable drawable = ResourcesCompat.getDrawable(resources, id, theme);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            int color = getThemeColor(theme, android.R.attr.textColorPrimary, Color.TRANSPARENT);
            if (color != Color.TRANSPARENT) {
                drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
            }
        }
        return drawable;
    } catch (Exception e) {
        return null;
    }
}

From source file:com.nttec.everychan.chans.lainchan.LainModule.java

@Override
public Drawable getChanFavicon() {
    return ResourcesCompat.getDrawable(resources, R.drawable.favicon_lain, null);
}

From source file:com.xbm.android.matisse.internal.ui.widget.CheckView.java

private void init(Context context) {
    mDensity = context.getResources().getDisplayMetrics().density;

    mStrokePaint = new Paint();
    mStrokePaint.setAntiAlias(true);//w w  w .j  ava 2 s  .  c  o m
    mStrokePaint.setStyle(Paint.Style.STROKE);
    mStrokePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));
    mStrokePaint.setStrokeWidth(STROKE_WIDTH * mDensity);
    TypedArray ta = getContext().getTheme()
            .obtainStyledAttributes(new int[] { R.attr.item_checkCircle_borderColor });
    int defaultColor = ResourcesCompat.getColor(getResources(), R.color.zhihu_item_checkCircle_borderColor,
            getContext().getTheme());
    int color = ta.getColor(0, defaultColor);
    ta.recycle();
    mStrokePaint.setColor(color);

    mCheckDrawable = ResourcesCompat.getDrawable(context.getResources(), R.drawable.ic_check_white_18dp,
            context.getTheme());
}

From source file:nya.miku.wishmaster.chans.infinity.LolifoxModule.java

@Override
public Drawable getChanFavicon() {
    return ResourcesCompat.getDrawable(resources, R.drawable.favicon_lolifox, null);
}

From source file:im.vector.util.VectorImageGetter.java

@Override
public Drawable getDrawable(String source) {

    // allow only url which starts with mxc://
    if ((null != source) && source.toLowerCase().startsWith(ContentManager.MATRIX_CONTENT_URI_SCHEME)) {
        if (mBitmapCache.containsKey(source)) {
            Log.d(LOG_TAG, "## getDrawable() : " + source + " already cached");
            return mBitmapCache.get(source);
        }/*ww w  .j  a v  a 2 s  .c o  m*/

        if (!mPendingDownloads.contains(source)) {
            Log.d(LOG_TAG, "## getDrawable() : starts a task to download " + source);
            try {
                new ImageDownloaderTask().execute(source);
                mPendingDownloads.add(source);
            } catch (Throwable t) {
                Log.e(LOG_TAG, "## getDrawable() failed " + t.getMessage());
            }
        } else {
            Log.d(LOG_TAG, "## getDrawable() : " + source + " is downloading");
        }

    }

    if (null == mPlaceHolder) {
        mPlaceHolder = ResourcesCompat.getDrawable(VectorApp.getInstance().getResources(),
                R.drawable.filetype_image, null);
        mPlaceHolder.setBounds(0, 0, mPlaceHolder.getIntrinsicWidth(), mPlaceHolder.getIntrinsicHeight());
    }

    return mPlaceHolder;
}

From source file:com.arlib.floatingsearchview.util.Util.java

/**
 * Gets a reference to a given drawable and prepares it for use with tinting through.
 *
 * @param resId the resource id for the given drawable
 * @return a wrapped drawable ready fo use
 * with {@link android.support.v4.graphics.drawable.DrawableCompat}'s tinting methods
 * @throws Resources.NotFoundException//from  ww  w.  j  a v  a 2 s  . c o m
 */
public static Drawable getWrappedDrawable(Context context, @DrawableRes int resId)
        throws Resources.NotFoundException {
    return DrawableCompat.wrap(ResourcesCompat.getDrawable(context.getResources(), resId, null));
}

From source file:com.nttec.everychan.chans.chan420.Chan420Module.java

@Override
public Drawable getChanFavicon() {
    return ResourcesCompat.getDrawable(resources, R.drawable.favicon_420chan, null);
}

From source file:com.aprz.easy_iosched.ui.widget.CustomRatingBar.java

public CustomRatingBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CustomRatingBar, 0, 0);

    try {//from w ww.ja  va2 s. c o  m
        mMaxRating = typedArray.getInt(R.styleable.CustomRatingBar_maxRating, DEFAULT_MAX_RATING);
        mFilledDrawable = typedArray.getDrawable(R.styleable.CustomRatingBar_filledDrawable);
        if (mFilledDrawable == null) {
            mFilledDrawable = ResourcesCompat.getDrawable(getResources(), DEFAULT_FILLED_DRAWABLE_ID, null);
        }
        mUnfilledDrawable = typedArray.getDrawable(R.styleable.CustomRatingBar_unfilledDrawable);
        if (mUnfilledDrawable == null) {
            mUnfilledDrawable = ResourcesCompat.getDrawable(getResources(), DEFAULT_UNFILLED_DRAWABLE_ID, null);
        }
    } finally {
        typedArray.recycle();
    }
    setSaveEnabled(true);
}

From source file:com.nttec.everychan.chans.cirno.Chan410Module.java

@Override
public Drawable getChanFavicon() {
    return ResourcesCompat.getDrawable(resources, R.drawable.favicon_410chan, null);
}