Java 类android.support.annotation.DrawableRes 实例源码

项目:q-mail    文件:SecurityInfoDialog.java   
private void setCryptoMessageSingleLine(@AttrRes int colorAttr,
        @StringRes int topTextRes, @DrawableRes int statusIconRes,
        @DrawableRes Integer statusDotsRes) {
    @ColorInt int color = ThemeUtils.getStyledColor(getActivity(), colorAttr);

    authenticationIcon_1.setImageResource(statusIconRes);
    authenticationIcon_1.setColorFilter(color);
    authenticationText.setText(topTextRes);

    if (statusDotsRes != null) {
        authenticationIcon_3.setImageResource(statusDotsRes);
        authenticationIcon_3.setColorFilter(color);
        authenticationIcon_3.setVisibility(View.VISIBLE);
    } else {
        authenticationIcon_3.setVisibility(View.GONE);
    }

    trustText.setVisibility(View.GONE);
    trustIconFrame.setVisibility(View.GONE);
}
项目:q-mail    文件:SecurityInfoDialog.java   
private void setCryptoMessageWithAnimation(@AttrRes int colorAttr,
        @StringRes int topTextRes, @DrawableRes int statusIconRes,
        @StringRes int bottomTextRes, @DrawableRes int statusDotsRes) {
    authenticationIcon_1.setImageResource(statusIconRes);
    authenticationIcon_2.setImageResource(statusDotsRes);
    authenticationIcon_3.setVisibility(View.GONE);
    authenticationText.setText(topTextRes);

    trustIcon_1.setImageResource(statusIconRes);
    trustIcon_2.setImageResource(statusDotsRes);
    trustText.setText(bottomTextRes);

    authenticationIcon_1.setColorFilter(ThemeUtils.getStyledColor(getActivity(), colorAttr));
    trustIcon_2.setColorFilter(ThemeUtils.getStyledColor(getActivity(), colorAttr));

    prepareIconAnimation();
}
项目:Steps_Android    文件:CircleImageSteps.java   
/**
 * Function to add view to component
 *
 * @param tag              View tag usually the step number
 * @param drawableResource drawable resource of view
 */
private void addView(int tag, @DrawableRes int drawableResource, boolean isLastStep) {
    // inflate view to component
    View view = LayoutInflater.from(getContext()).inflate(R.layout.step_view_item, rootView, false);

    //set view size and margins
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(stepSize, stepSize);
    layoutParams.setMargins(10, 10, 10, 10);
    view.findViewById(R.id.iv_main_step_image).setLayoutParams(layoutParams);
    view.setTag(tag);

    //set view background color
    setStepColorStatus(false, view);

    //add Image icon to view and add view
    ((ImageView) view.findViewById(R.id.iv_main_step_image)).setImageResource(drawableResource);
    rootView.addView(view);

    if (!isLastStep) {
        view = LayoutInflater.from(getContext()).inflate(R.layout.split_view_item, rootView, false);
        rootView.addView(view);
    }

}
项目:GifEmoji    文件:EmoticonDecoder.java   
private void load(Context context, @DrawableRes int drawableRes, int textSize, String url) {
    if (!nativeLoad(handle, url)) {
        nativeClose(handle);
        throw new RuntimeException("not gif");
    } else {
        frameNum = nativeGetFrameCount(handle);
        for (int i = 0; i < frameNum; i++) {
            BitmapDrawable drawable = new BitmapDrawable(context.getResources(), nativeGetFrame(handle, i));
            int width = (textSize * drawable.getIntrinsicWidth()) / drawable.getIntrinsicHeight();
            drawable.setBounds(0, 0, width, textSize);
            EmoticonCache.saveDrawable(drawableRes, i, drawable);
            delay = nativeGetDelay(handle, i);
        }
        nativeClose(handle);
    }
}
项目:butterknife-parent    文件:Utils.java   
@UiThread // Implicit synchronization for use of shared resource VALUE.
public static Drawable getTintedDrawable(Context context,
    @DrawableRes int id, @AttrRes int tintAttrId) {
  boolean attributeFound = context.getTheme().resolveAttribute(tintAttrId, VALUE, true);
  if (!attributeFound) {
    throw new Resources.NotFoundException("Required tint color attribute with name "
        + context.getResources().getResourceEntryName(tintAttrId)
        + " and attribute ID "
        + tintAttrId
        + " was not found.");
  }

  Drawable drawable = ContextCompat.getDrawable(context, id);
  drawable = DrawableCompat.wrap(drawable.mutate());
  int color = ContextCompat.getColor(context, VALUE.resourceId);
  DrawableCompat.setTint(drawable, color);
  return drawable;
}
项目:memetastic    文件:ContextUtils.java   
public Bitmap drawTextToDrawable(@DrawableRes int resId, String text, int textSize) {
    Resources resources = _context.getResources();
    float scale = resources.getDisplayMetrics().density;
    Bitmap bitmap = getBitmapFromDrawable(resId);

    bitmap = bitmap.copy(bitmap.getConfig(), true);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.rgb(61, 61, 61));
    paint.setTextSize((int) (textSize * scale));
    paint.setShadowLayer(1f, 0f, 1f, Color.WHITE);

    Rect bounds = new Rect();
    paint.getTextBounds(text, 0, text.length(), bounds);
    int x = (bitmap.getWidth() - bounds.width()) / 2;
    int y = (bitmap.getHeight() + bounds.height()) / 2;
    canvas.drawText(text, x, y, paint);

    return bitmap;
}
项目:GitHub    文件:CircleIndicator.java   
private void addIndicator(int orientation, @DrawableRes int backgroundDrawableId,
        Animator animator) {
    if (animator.isRunning()) {
        animator.end();
        animator.cancel();
    }

    View Indicator = new View(getContext());
    Indicator.setBackgroundResource(backgroundDrawableId);
    addView(Indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) Indicator.getLayoutParams();

    if (orientation == HORIZONTAL) {
        lp.leftMargin = mIndicatorMargin;
        lp.rightMargin = mIndicatorMargin;
    } else {
        lp.topMargin = mIndicatorMargin;
        lp.bottomMargin = mIndicatorMargin;
    }

    Indicator.setLayoutParams(lp);

    animator.setTarget(Indicator);
    animator.start();
}
项目:ImmerseMode    文件:TpSbTlNbwFCImmerseMode.java   
@Override
public boolean setStatusDrawableRes(@DrawableRes int drawableRes) {
    Activity activity = mActivityRef.get();
    if (activity != null) {
        Drawable drawable = ContextCompat.getDrawable(activity, drawableRes);
        setStatusDrawable(drawable);
    }
    return true;
}
项目:Android-skin-support    文件:SkinCompatRadioButton.java   
@Override
public void setCompoundDrawablesRelativeWithIntrinsicBounds(
        @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
    super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
    if (mTextHelper != null) {
        mTextHelper.onSetCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
    }
}
项目:xlight_android_native    文件:Ui.java   
public static Drawable getTintedDrawable(Context ctx, @DrawableRes int drawableResId,
                                         @ColorRes int colorResId) {
    Resources res = ctx.getResources();
    Drawable drawable = ContextCompat.getDrawable(ctx, drawableResId);
    int color = res.getColor(colorResId);
    drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
    return drawable;
}
项目:Android-skin-support    文件:SkinCompatImageView.java   
@Override
public void setImageResource(@DrawableRes int resId) {
    // Intercept this call and instead retrieve the Drawable via the image helper
    if (mImageHelper != null) {
        mImageHelper.setImageResource(resId);
    }
}
项目:microMathematics    文件:CompatUtils.java   
/**
 * Procedure sets the background for given view as a drawable with given resource id
 */
@SuppressWarnings("deprecation")
public static void updateBackground(Context c, View v, @DrawableRes int drawableId)
{
    Drawable bg = null;

    if (drawableId >= 0)
    {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        {
            bg = c.getResources().getDrawable(drawableId, c.getTheme());
        }
        else
        {
            bg = c.getResources().getDrawable(drawableId);
        }
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        v.setBackground(bg);
    }
    else
    {
        v.setBackgroundDrawable(bg);
    }
}
项目:baselibrary-master    文件:BaseFragment.java   
/**
 * 淡入淡出加载图片
 *
 * @param imageview        图片控件
 * @param uri              图片uri
 * @param errorResId       加载失败时显示的图片资源id
 * @param placeholderResId 加载时的占位图资源id
 */
public void setImageUri(@NonNull ImageView imageview, Uri uri, @DrawableRes int errorResId, @DrawableRes int placeholderResId) {
    Glide.with(mContext)
            .load(uri)
            .crossFade()
            .error(errorResId)
            .placeholder(placeholderResId)
            .into(imageview);
}
项目:Android-skin-support    文件:SkinCompatCircleImageView.java   
@Override
public void setImageResource(@DrawableRes int resId) {
    super.setImageResource(resId);
    if (mImageHelper != null) {
        mImageHelper.setImageResource(resId);
    }
}
项目:loadingdots    文件:LoadingDots.java   
@Override
public void setImageResource(@DrawableRes int resId) {
    if (animation != null) {
        throw new IllegalStateException("Changing the LoadingDots image resource is not supported");
    } else {
        super.setImageResource(resId);
    }
}
项目:TextEmoji    文件:CombinedTabView.java   
public CombinedTabView(Context context, AttributeSet attrs, @StringRes int name, @DrawableRes int normal, @DrawableRes int selected, @ColorRes int colorNormal, @ColorRes int colorSelected) {
    super(context, attrs);
    inflate(context, R.layout.tab_item, this);
    mNormal = normal;
    mSelected = selected;
    mColorNormal = colorNormal;
    mColorSelected = colorSelected;
    mName = name;

    mItemIcon = (ImageView) findViewById(R.id.icon);
    mItemName = (TextView) findViewById(R.id.name);

    init();
}
项目:Android-skin-support    文件:SkinCompatRadioButton.java   
@Override
public void setButtonDrawable(@DrawableRes int resId) {
    super.setButtonDrawable(resId);
    if (mCompoundButtonHelper != null) {
        mCompoundButtonHelper.setButtonDrawable(resId);
    }
}
项目:markor    文件:ShareUtilBase.java   
public void createLauncherDesktopShortcut(Intent shortcutIntent, @DrawableRes int shortcutIconRes, String shortcutTitle, String shortcutCreateToast) {
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    Intent addIntent = new Intent();
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutTitle);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(_context, shortcutIconRes));
    addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    _context.sendBroadcast(addIntent);

    Toast.makeText(_context, shortcutCreateToast, Toast.LENGTH_LONG).show();
}
项目:Sendroid    文件:SenImage.java   
public ImageRequest load(@DrawableRes int drawableId) {
    final ImageRequest req = ImageTypeRequest.buildImageRequest(drawableId);
    final String cacheKey = req.getCacheKey();
    // mCancelableRequestDelegate.putRequest();
    // Bitmap bitmap = mLruCache.get(cacheKey);
    return req.request();
}
项目:Pluto-Android    文件:PlutoActivity.java   
/** 设置ActionBar左上角图标 */
protected void setHomeAsUpIndicator(@DrawableRes int resId) {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeAsUpIndicator(resId);
    }
}
项目:Android-skin-support    文件:SkinCompatMultiAutoCompleteTextView.java   
@Override
public void setBackgroundResource(@DrawableRes int resId) {
    super.setBackgroundResource(resId);
    if (mBackgroundTintHelper != null) {
        mBackgroundTintHelper.onSetBackgroundResource(resId);
    }
}
项目:Android-skin-support    文件:SkinSegmentTabLayout.java   
@Override
public void setBackgroundResource(@DrawableRes int resId) {
    super.setBackgroundResource(resId);
    if (mBackgroundTintHelper != null) {
        mBackgroundTintHelper.onSetBackgroundResource(resId);
    }
}
项目:GitHub    文件:GlideRequest.java   
/**
 * @see GlideOptions#placeholder(int)
 */
@CheckResult
public GlideRequest<TranscodeType> placeholder(@DrawableRes int arg0) {
  if (getMutableOptions() instanceof GlideOptions) {
    this.requestOptions = ((GlideOptions) getMutableOptions()).placeholder(arg0);
  } else {
    this.requestOptions = new GlideOptions().apply(this.requestOptions).placeholder(arg0);
  }
  return this;
}
项目:GitHub    文件:GlideRequest.java   
/**
 * @see GlideOptions#error(int)
 */
@CheckResult
public GlideRequest<TranscodeType> error(@DrawableRes int arg0) {
  if (getMutableOptions() instanceof GlideOptions) {
    this.requestOptions = ((GlideOptions) getMutableOptions()).error(arg0);
  } else {
    this.requestOptions = new GlideOptions().apply(this.requestOptions).error(arg0);
  }
  return this;
}
项目:boohee_v5.6    文件:VectorDrawableCompat.java   
@Nullable
public static VectorDrawableCompat create(@NonNull Resources res, @DrawableRes int resId, @Nullable Theme theme) {
    if (VERSION.SDK_INT >= 21) {
        VectorDrawableCompat drawable = new VectorDrawableCompat();
        drawable.mDelegateDrawable = ResourcesCompat.getDrawable(res, resId, theme);
        drawable.mCachedConstantStateDelegate = new VectorDrawableDelegateState(drawable.mDelegateDrawable.getConstantState());
        return drawable;
    }
    try {
        int type;
        XmlPullParser parser = res.getXml(resId);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        do {
            type = parser.next();
            if (type == 2) {
                break;
            }
        } while (type != 1);
        if (type == 2) {
            return createFromXmlInner(res, parser, attrs, theme);
        }
        throw new XmlPullParserException("No start tag found");
    } catch (XmlPullParserException e) {
        Log.e(LOGTAG, "parser error", e);
        return null;
    } catch (IOException e2) {
        Log.e(LOGTAG, "parser error", e2);
        return null;
    }
}
项目:Neuronizer    文件:SliderPageFactory.java   
private SliderPage createPageWith(@StringRes int title, @DrawableRes int drawable, @StringRes int description) {
    SliderPage page = new SliderPage();
    page.setTitle(context.getResources().getString(title));
    page.setImageDrawable(drawable);
    page.setDescription(context.getResources().getString(description));

    page.setBgColor(context.getResources().getColor(R.color.colorPrimary));
    page.setTitleTypeface(FONT_NAME_FULL);
    return page;
}
项目:boohee_v5.6    文件:AppCompatDrawableManager.java   
private static boolean tintDrawableUsingColorFilter(@NonNull Context context, @DrawableRes int resId, @NonNull Drawable drawable) {
    Mode tintMode = DEFAULT_MODE;
    boolean colorAttrSet = false;
    int colorAttr = 0;
    int alpha = -1;
    if (arrayContains(COLORFILTER_TINT_COLOR_CONTROL_NORMAL, resId)) {
        colorAttr = R.attr.colorControlNormal;
        colorAttrSet = true;
    } else if (arrayContains(COLORFILTER_COLOR_CONTROL_ACTIVATED, resId)) {
        colorAttr = R.attr.colorControlActivated;
        colorAttrSet = true;
    } else if (arrayContains(COLORFILTER_COLOR_BACKGROUND_MULTIPLY, resId)) {
        colorAttr = 16842801;
        colorAttrSet = true;
        tintMode = Mode.MULTIPLY;
    } else if (resId == R.drawable.abc_list_divider_mtrl_alpha) {
        colorAttr = 16842800;
        colorAttrSet = true;
        alpha = Math.round(40.8f);
    }
    if (!colorAttrSet) {
        return false;
    }
    if (DrawableUtils.canSafelyMutateDrawable(drawable)) {
        drawable = drawable.mutate();
    }
    drawable.setColorFilter(getPorterDuffColorFilter(ThemeUtils.getThemeAttrColor(context, colorAttr), tintMode));
    if (alpha != -1) {
        drawable.setAlpha(alpha);
    }
    return true;
}
项目:XERUNG    文件:MaterialEditText.java   
private Bitmap[] generateIconBitmaps(@DrawableRes int origin) {
  if (origin == -1) {
    return null;
  }
  BitmapFactory.Options options = new BitmapFactory.Options();
  options.inJustDecodeBounds = true;
  BitmapFactory.decodeResource(getResources(), origin, options);
  int size = Math.max(options.outWidth, options.outHeight);
  options.inSampleSize = size > iconSize ? size / iconSize : 1;
  options.inJustDecodeBounds = false;
  return generateIconBitmaps(BitmapFactory.decodeResource(getResources(), origin, options));
}
项目:Alerter    文件:Alerter.java   
/**
 * Set the Alert's Background Drawable Resource
 *
 * @param drawableResId Drawable Resource Id
 * @return This Alerter
 */
public Alerter setBackgroundResource(@DrawableRes final int drawableResId) {
    if (getAlert() != null) {
        getAlert().setAlertBackgroundResource(drawableResId);
    }

    return this;
}
项目:LiteReader    文件:ImageLoader.java   
public static void loadCircleWithPlaceHolder(ImageView imageView, String url, @DrawableRes int placeHolder) {
    Glide.with(imageView.getContext())
            .load(url)
            .bitmapTransform(new CropCircleTransformation(imageView.getContext()))
            .placeholder(placeHolder == 0 ? R.drawable.ic_placeholder : placeHolder)
            .into(imageView);
}
项目:XERUNG    文件:CircleIndicator.java   
private void addIndicator(@DrawableRes int backgroundDrawableId, Animator animator) {
    if (animator.isRunning()) animator.end();

    View Indicator = new View(getContext());
    Indicator.setBackgroundResource(backgroundDrawableId);
    addView(Indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) Indicator.getLayoutParams();
    lp.leftMargin = mIndicatorMargin;
    lp.rightMargin = mIndicatorMargin;
    Indicator.setLayoutParams(lp);

    animator.setTarget(Indicator);
    animator.start();
}
项目:Android-skin-support    文件:SkinCompatImageButton.java   
@Override
public void setBackgroundResource(@DrawableRes int resId) {
    super.setBackgroundResource(resId);
    if (mBackgroundTintHelper != null) {
        mBackgroundTintHelper.onSetBackgroundResource(resId);
    }
}
项目:QiangHongBao    文件:LViewHolder.java   
public LViewHolder setBackgroundResource(@IdRes int viewId, @DrawableRes int resId) {
    getView(viewId).setBackgroundResource(resId);
    return this;
}
项目:aDictOnCopy    文件:DictionaryOnCopyService.java   
@Override
public @DrawableRes int getNotificationSmallIcon() { return R.drawable.dictionary; }
项目:login    文件:BottomSheetBuilder.java   
public BottomSheetBuilder addItem(int id, @StringRes int title, @DrawableRes int icon) {
    return addItem(id, mContext.getString(title), ContextCompat.getDrawable(mContext, icon));
}
项目:MultiViewAdapter    文件:GridItem.java   
public GridItem(@ColorInt int color, @DrawableRes int drawable, String data) {
  this.color = color;
  this.drawable = drawable;
  this.data = data;
}
项目:XERUNG    文件:CircleImageView.java   
@Override
public void setImageResource(@DrawableRes int resId) {
    super.setImageResource(resId);
    mBitmap = getBitmapFromDrawable(getDrawable());
    setup();
}
项目:yphoto    文件:CircleImageView.java   
@Override
public void setImageResource(@DrawableRes int resId) {
    super.setImageResource(resId);
    initializeBitmap();
}
项目:XERUNG    文件:MaterialMultiAutoCompleteTextView.java   
public void setIconRight(@DrawableRes int res) {
  iconRightBitmaps = generateIconBitmaps(res);
  initPadding();
}
项目:Rx_java2_soussidev    文件:RxAlertDialogBuilder.java   
@Nullable @DrawableRes public Integer getIconRes()
{
    return iconRes;
}