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

下面列出了怎么用android.support.annotation.DrawableRes的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ZadakNotification   文件: Wear.java
@SuppressLint("ResourceType")
public Wear remoteInput(@DrawableRes int icon, String title, PendingIntent pendingIntent) {
    if (icon <= 0) {
        throw new IllegalArgumentException("Resource ID Icon Should Not Be Less Than Or Equal To Zero!");
    }

    if (title == null) {
        throw new IllegalArgumentException("Title Must Not Be Null!");
    }

    if (pendingIntent == null) {
        throw new IllegalArgumentException("PendingIntent Must Not Be Null!");
    }

    this.remoteInput = new RemoteInput.Builder(ZadakNotification.mSingleton.mContext.getString(R.string.key_voice_reply))
            .setLabel(ZadakNotification.mSingleton.mContext.getString(R.string.label_voice_reply))
            .setChoices(ZadakNotification.mSingleton.mContext.getResources().getStringArray(R.array.reply_choices))
            .build();
    wearableExtender.addAction(new NotificationCompat.Action.Builder(icon,
            title, pendingIntent)
            .addRemoteInput(remoteInput)
            .build());
    return this;
}
 
源代码2 项目: timecat   文件: SpecialTab.java
/**
 * 方便初始化的方法
 * @param drawableRes           默认状态的图标
 * @param checkedDrawableRes    选中状态的图标
 * @param title                 标题
 */
public void initialize(@DrawableRes int drawableRes, @DrawableRes int checkedDrawableRes, String title)
{
    mDefaultDrawable = drawableRes;
    mCheckedDrawable = checkedDrawableRes;
    mTitle.setText(title);
}
 
源代码3 项目: weMessage   文件: AttachmentView.java
protected Drawable getMessageSelector(@ColorInt int normalColor, @ColorInt int selectedColor, @ColorInt int pressedColor, @DrawableRes int shape) {
    Drawable drawable = DrawableCompat.wrap(getVectorDrawable(shape)).mutate();
    DrawableCompat.setTintList(
            drawable,
            new ColorStateList(
                    new int[][]{
                            new int[]{android.R.attr.state_selected},
                            new int[]{android.R.attr.state_pressed},
                            new int[]{-android.R.attr.state_pressed, -android.R.attr.state_selected}
                    },
                    new int[]{selectedColor, pressedColor, normalColor}
            ));
    return drawable;
}
 
源代码4 项目: input-samples   文件: RemoteViewsHelper.java
private static RemoteViews simpleRemoteViews(String packageName, String remoteViewsText,
        @DrawableRes int drawableId) {
    RemoteViews presentation = new RemoteViews(packageName,
            R.layout.multidataset_service_list_item);
    presentation.setTextViewText(R.id.text, remoteViewsText);
    presentation.setImageViewResource(R.id.icon, drawableId);
    return presentation;
}
 
源代码5 项目: input-samples   文件: RecyclerViewActivity.java
FieldMetadata(AutofillId autofillId, String autofillHint, @StringRes int labelRes,
        @DrawableRes int iconRes, int inputType) {
    mAutofillId = autofillId;
    mAutofillHint = autofillHint;
    mLabelRes = labelRes;
    mIconRes = iconRes;
    mInputType = inputType;
}
 
源代码6 项目: AndroidWallet   文件: SpannableStringUtils.java
/**
 * 设置图片
 *
 * @param resourceId 图片资源id
 * @param align      对齐
 * @return {@link Builder}
 */
public Builder setResourceId(@DrawableRes int resourceId, @Align int align) {
    this.resourceId = resourceId;
    this.align = align;
    this.text = " " + this.text;
    imageIsResourceId = true;
    return this;
}
 
源代码7 项目: FlexItemDecoration   文件: BaseItemDecoration.java
/**
 * @param drawableId 定制分割线的drawable资源id
 * @return
 */
public BaseBuilder redrawDividerDrawable(@DrawableRes int drawableId) {
	this.mDividerDrawable = ContextCompat.getDrawable(mContext.getApplicationContext(), drawableId);
	if (mOrientation == VERTICAL) {
		if (this.mRedrawDividerHeight == 0) {
			this.mRedrawDividerHeight = mDividerDrawable.getIntrinsicHeight();
		}
	} else {
		if (mRedrawDividerWidth == 0) {
			this.mRedrawDividerWidth = mDividerDrawable.getIntrinsicWidth();
		}
	}
	return this;
}
 
源代码8 项目: SimpleProject   文件: ToolbarEx.java
/**
 * 设置右边Icon的资源
 * @param resId
 * @param horizontalPadding
 * @param marginRight 最右边Icon的右边距
 * @param listeners
 * @return
 */
public ToolbarEx setRightIcon(@DrawableRes int resId, int horizontalPadding, int marginRight, OnClickListener listeners) {
	Toolbar.LayoutParams params = generateDefaultLayoutParams();
	params.rightMargin = marginRight;
	params.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;
	rightIcon = new ImageView(getContext());
	rightIcon.setImageResource(resId);
	rightIcon.setPadding(horizontalPadding, 0, horizontalPadding, 0);
	rightIcon.setOnClickListener(listeners);
	addView(rightIcon, params);

	return this;
}
 
源代码9 项目: OmniList   文件: PalmApp.java
public static Drawable getDrawableCompact(@DrawableRes int resId) {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        return getContext().getDrawable(resId);
    } else {
        return getContext().getResources().getDrawable(resId);
    }
}
 
public Builder setStickyDrawable(@DrawableRes int drawableId) {
	this.mStickyDrawable = ContextCompat.getDrawable(mContext.getApplicationContext(), drawableId);
	;
	if (this.mStickyHeightOrWidth == 0) {
		this.mStickyHeightOrWidth = mStickyDrawable.getIntrinsicHeight();
	}
	return this;
}
 
源代码11 项目: WheelViewDemo   文件: CompatResourceUtils.java
public static Drawable getDrawable(@NonNull Context context, @DrawableRes int resId){
    Drawable drawable;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M){
        drawable = context.getResources().getDrawable(resId, context.getTheme());
    } else {
        drawable = context.getResources().getDrawable(resId);
    }
    return drawable;
}
 
源代码12 项目: styT   文件: ActivityResourceFinder.java
@Nullable
@Override
public Drawable getDrawable(@DrawableRes int resId)
{
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
    {
        return mActivity.getDrawable(resId);
    }
    else
    {
        //noinspection deprecation
        return mActivity.getResources().getDrawable(resId);
    }
}
 
源代码13 项目: sealrtc-android   文件: BaseRecyclerAdapter.java
/**
 * ImageView 设置图片 res
 *
 * @param id
 * @param drawable
 * @return
 */
public BaseViewHolder setImageResource(@IdRes int id, @DrawableRes int drawable) {
    View view = getViewById(id);
    if (view instanceof ImageView) {
        ((ImageView) view).setImageResource(drawable);
    }
    return this;
}
 
源代码14 项目: Android-utils   文件: ImageUtils.java
public static Bitmap getBitmap(@DrawableRes final int resId) {
    Drawable drawable = ContextCompat.getDrawable(UtilsApp.getApp(), resId);
    Canvas canvas = new Canvas();
    Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
            drawable.getIntrinsicHeight(),
            Bitmap.Config.ARGB_8888);
    canvas.setBitmap(bitmap);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    drawable.draw(canvas);
    return bitmap;
}
 
源代码15 项目: landlord_client   文件: CardsPack.java
private @DrawableRes
int getName2ResId(String resName) {
    int imgRid = 0;
    try {
        imgRid = R.mipmap.class.getDeclaredField(resName).getInt(R.mipmap.class);
    } catch (Exception e) {
        Logger.e(e.getMessage());
    }
    return imgRid;
}
 
源代码16 项目: LoopBanner   文件: LoopBanner.java
private void setIndicatorResource(@DrawableRes int selectRes, @DrawableRes int unSelectRes, boolean byUser) {
    if (byUser) {
        checkAdapter("setIndicatorResource");
    }
    Drawable selectDrawable = ContextCompat.getDrawable(getContext(), selectRes);
    Drawable unSelectDrawable = ContextCompat.getDrawable(getContext(), unSelectRes);
    this.mSelectDrawable = selectDrawable;
    this.mUnSelectDrawable = unSelectDrawable;
}
 
源代码17 项目: Common   文件: BottomThirdBar.java
public Item(@Type int type, @DrawableRes int res, String content,
            @FloatRange(from = 0f, to = 1f) float weight) {
    this.type = type;
    this.res = res;
    this.content = content;
    this.weight = weight;
}
 
@DrawableRes
private static int getDrawable(State currentState, State newState, boolean animate) {
    switch (newState) {
        case OFF:
            if (animate) {
                if (currentState == State.ON) {
                    return R.drawable.fingerprint_draw_off_animation;
                } else if (currentState == State.ERROR) {
                    return R.drawable.fingerprint_error_off_animation;
                }
            }

            return 0;
        case ON:
            if (animate) {
                if (currentState == State.OFF) {
                    return R.drawable.fingerprint_draw_on_animation;
                } else if (currentState == State.ERROR) {
                    return R.drawable.fingerprint_error_state_to_fp_animation;
                }
            }

            return R.drawable.fingerprint_fingerprint;
        case ERROR:
            if (animate) {
                if (currentState == State.ON) {
                    return R.drawable.fingerprint_fp_to_error_state_animation;
                } else if (currentState == State.OFF) {
                    return R.drawable.fingerprint_error_on_animation;
                }
            }

            return R.drawable.fingerprint_error;
        default:
            throw new IllegalArgumentException("Unknown state: " + newState);
    }
}
 
源代码19 项目: FlexItemDecoration   文件: BaseItemDecoration.java
/**
 * @param drawableId 最右边分割线的drawable资源id
 * @return
 */
public BaseBuilder redrawRightDividerDrawable(@DrawableRes int drawableId) {
	this.mRightDividerDrawable = ContextCompat.getDrawable(mContext.getApplicationContext(), drawableId);
	if (this.mRightDividerWidth == 0) {
		this.mRightDividerWidth = mRightDividerDrawable.getIntrinsicWidth();
	}
	return this;
}
 
源代码20 项目: FlexItemDecoration   文件: BaseItemDecoration.java
public BaseItemDecoration redrawFooterDividerDrawable(@DrawableRes int drawableId) {
	this.mFooterDividerDrawable = ContextCompat.getDrawable(mContext.getApplicationContext(), drawableId);
	if (this.mFooterDividerHeight == 0) {
		this.mFooterDividerHeight = this.mFooterDividerDrawable.getIntrinsicHeight();
	}
	return this;
}
 
源代码21 项目: MvpRoute   文件: FragmentUtils.java
/**
 * 设置背景资源
 *
 * @param drawid
 * @return
 */
public FragmentWrapper setBackgroundResource(@DrawableRes int drawid) {

	View view = baseFragment.getView();
	if (view != null) {
		view.setBackgroundResource(drawid);
	}
	return this;
}
 
源代码22 项目: MorphView   文件: MorphView.java
private void init(Context context, AttributeSet attrs) {
    if (isInEditMode()) {
        setImageResource(android.R.drawable.ic_media_play);
        return;
    }

    TypedArray a = context.getTheme().obtainStyledAttributes(
            attrs,
            R.styleable.MorphView,
            0, 0);

    @DrawableRes int avdFromRes;
    @DrawableRes int avdToRes;
    try {
        avdFromRes = a.getResourceId(R.styleable.MorphView_avdFirst, -1);
        avdToRes = a.getResourceId(R.styleable.MorphView_avdSecond, -1);
    } finally {
        a.recycle();
    }

    showingAvdFirst = true;
    avdFirstToSecond = AnimatedVectorDrawableCompat.create(getContext(), avdFromRes);
    avdSecondToFirst = AnimatedVectorDrawableCompat.create(getContext(), avdToRes);

    if (avdSecondToFirst == null || avdFirstToSecond == null) {
        throw new RuntimeException("Drawable is not a valid AnimatedVectorDrawable");
    } else {
        setImageDrawable(avdFirstToSecond);
    }
}
 
源代码23 项目: PowerFileExplorer   文件: ImageFragment.java
private void setInfo(String txt, @DrawableRes int drawableId) {
      Log.d(TAG, "setInfo " + txt);
centerInfo.setVisibility(View.VISIBLE);
      centerInfo.setText(txt);
      centerInfo.setTextColor(0xffffffff);
      centerInfo.setCompoundDrawablesWithIntrinsicBounds(0, drawableId, 0, 0);
  }
 
源代码24 项目: styT   文件: FragmentUtils.java
/**
 * 设置背景资源
 *
 * @param fragment fragment
 * @param resId    资源Id
 */
public static void setBackgroundResource(@NonNull final Fragment fragment, @DrawableRes final int resId) {
    View view = fragment.getView();
    if (view != null) {
        view.setBackgroundResource(resId);
    }
}
 
源代码25 项目: ChannelView   文件: ChannelView.java
/**
 * 设置频道正常状态下背景
 *
 * @see StyleAdapter#setNormalStyle(ViewHolder)
 */
@Deprecated
public void setChannelNormalBackground(@DrawableRes int channelNormalBackground) {
    if (checkDefaultAdapter()) {
        for (View view : allTextView) {
            defaultStyleAdapter.setBackgroundResource(view, channelNormalBackground);
        }
    }
}
 
源代码26 项目: ChannelView   文件: ChannelView.java
/**
 * 设置固定频道的背景
 *
 * @param channelFixedBackground
 * @see StyleAdapter#setFixedStyle(ViewHolder)
 */
@Deprecated
public void setChannelFixedBackground(@DrawableRes int channelFixedBackground) {
    if (checkDefaultAdapter()) {
        for (View view : fixedTextView) {
            defaultStyleAdapter.setBackgroundResource(view, channelFixedBackground);
        }
    }
}
 
源代码27 项目: ChannelView   文件: ChannelView.java
/**
 * 设置编辑按键背景
 *
 * @param tipEditBackground
 */
public void setTipEditBackground(@DrawableRes int tipEditBackground) {
    this.tipEditBackground = tipEditBackground;
    if (channelLayout != null && channelLayout.tipEdit != null) {
        channelLayout.tipEdit.setBackgroundResource(tipEditBackground);
    }
}
 
源代码28 项目: ChannelView   文件: ChannelView.java
/**
 * 设置完成按键背景
 *
 * @param tipFinishBackground
 */
public void setTipFinishBackground(@DrawableRes int tipFinishBackground) {
    this.tipFinishBackground = tipFinishBackground;
    if (channelLayout != null && channelLayout.tipFinish != null) {
        channelLayout.tipFinish.setBackgroundResource(tipFinishBackground);
    }
}
 
源代码29 项目: SmartLoadingView   文件: CircleImageView.java
@Override
public void setImageResource(@DrawableRes int resId) {
    super.setImageResource(resId);
    mBitmap = getBitmapFromDrawable(getDrawable());
    setup();
}
 
源代码30 项目: star-zone-android   文件: CircleImageView.java
@Override
public void setImageResource(@DrawableRes int resId) {
    super.setImageResource(resId);
    mBitmap = getBitmapFromDrawable(getDrawable());
    setup();
}
 
 类方法
 同包方法