android.support.annotation.DrawableRes Java Examples

The following examples show how to use android.support.annotation.DrawableRes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: ZadakNotification   Author: mehrdadsafari   File: Wear.java    License: MIT License 6 votes vote down vote up
@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;
}
 
Example #2
Source Project: timecat   Author: triline3   File: SpecialTab.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 方便初始化的方法
 * @param drawableRes           默认状态的图标
 * @param checkedDrawableRes    选中状态的图标
 * @param title                 标题
 */
public void initialize(@DrawableRes int drawableRes, @DrawableRes int checkedDrawableRes, String title)
{
    mDefaultDrawable = drawableRes;
    mCheckedDrawable = checkedDrawableRes;
    mTitle.setText(title);
}
 
Example #3
Source Project: weMessage   Author: RomanScott   File: AttachmentView.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #4
Source Project: input-samples   Author: android   File: RemoteViewsHelper.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #5
Source Project: input-samples   Author: android   File: RecyclerViewActivity.java    License: Apache License 2.0 5 votes vote down vote up
FieldMetadata(AutofillId autofillId, String autofillHint, @StringRes int labelRes,
        @DrawableRes int iconRes, int inputType) {
    mAutofillId = autofillId;
    mAutofillHint = autofillHint;
    mLabelRes = labelRes;
    mIconRes = iconRes;
    mInputType = inputType;
}
 
Example #6
Source Project: AndroidWallet   Author: Cocos-BCX   File: SpannableStringUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 设置图片
 *
 * @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;
}
 
Example #7
Source Project: FlexItemDecoration   Author: ckrgithub   File: BaseItemDecoration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #8
Source Project: SimpleProject   Author: Liberuman   File: ToolbarEx.java    License: MIT License 5 votes vote down vote up
/**
 * 设置右边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;
}
 
Example #9
Source Project: OmniList   Author: Shouheng88   File: PalmApp.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example #10
Source Project: FlexItemDecoration   Author: ckrgithub   File: DividerGridItemDecoration.java    License: Apache License 2.0 5 votes vote down vote up
public Builder setStickyDrawable(@DrawableRes int drawableId) {
	this.mStickyDrawable = ContextCompat.getDrawable(mContext.getApplicationContext(), drawableId);
	;
	if (this.mStickyHeightOrWidth == 0) {
		this.mStickyHeightOrWidth = mStickyDrawable.getIntrinsicHeight();
	}
	return this;
}
 
Example #11
Source Project: WheelViewDemo   Author: JustinRoom   File: CompatResourceUtils.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #12
Source Project: sealrtc-android   Author: rongcloud   File: BaseRecyclerAdapter.java    License: MIT License 5 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source Project: Android-utils   Author: Shouheng88   File: ImageUtils.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #14
Source Project: landlord_client   Author: GramYang   File: CardsPack.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #15
Source Project: LoopBanner   Author: wenjiangit   File: LoopBanner.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #16
Source Project: Common   Author: Dsiner   File: BottomThirdBar.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #17
Source Project: BiometricPromptCompat   Author: fython   File: FingerprintIconView.java    License: Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #18
Source Project: FlexItemDecoration   Author: ckrgithub   File: BaseItemDecoration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #19
Source Project: FlexItemDecoration   Author: ckrgithub   File: BaseItemDecoration.java    License: Apache License 2.0 5 votes vote down vote up
public BaseItemDecoration redrawFooterDividerDrawable(@DrawableRes int drawableId) {
	this.mFooterDividerDrawable = ContextCompat.getDrawable(mContext.getApplicationContext(), drawableId);
	if (this.mFooterDividerHeight == 0) {
		this.mFooterDividerHeight = this.mFooterDividerDrawable.getIntrinsicHeight();
	}
	return this;
}
 
Example #20
Source Project: MvpRoute   Author: TLocation   File: FragmentUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置背景资源
 *
 * @param drawid
 * @return
 */
public FragmentWrapper setBackgroundResource(@DrawableRes int drawid) {

	View view = baseFragment.getView();
	if (view != null) {
		view.setBackgroundResource(drawid);
	}
	return this;
}
 
Example #21
Source Project: MorphView   Author: akaita   File: MorphView.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #22
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ImageFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
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);
  }
 
Example #23
Source Project: styT   Author: stytooldex   File: FragmentUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置背景资源
 *
 * @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);
    }
}
 
Example #24
Source Project: ChannelView   Author: chengzhicao   File: ChannelView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置频道正常状态下背景
 *
 * @see StyleAdapter#setNormalStyle(ViewHolder)
 */
@Deprecated
public void setChannelNormalBackground(@DrawableRes int channelNormalBackground) {
    if (checkDefaultAdapter()) {
        for (View view : allTextView) {
            defaultStyleAdapter.setBackgroundResource(view, channelNormalBackground);
        }
    }
}
 
Example #25
Source Project: ChannelView   Author: chengzhicao   File: ChannelView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置固定频道的背景
 *
 * @param channelFixedBackground
 * @see StyleAdapter#setFixedStyle(ViewHolder)
 */
@Deprecated
public void setChannelFixedBackground(@DrawableRes int channelFixedBackground) {
    if (checkDefaultAdapter()) {
        for (View view : fixedTextView) {
            defaultStyleAdapter.setBackgroundResource(view, channelFixedBackground);
        }
    }
}
 
Example #26
Source Project: ChannelView   Author: chengzhicao   File: ChannelView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置编辑按键背景
 *
 * @param tipEditBackground
 */
public void setTipEditBackground(@DrawableRes int tipEditBackground) {
    this.tipEditBackground = tipEditBackground;
    if (channelLayout != null && channelLayout.tipEdit != null) {
        channelLayout.tipEdit.setBackgroundResource(tipEditBackground);
    }
}
 
Example #27
Source Project: ChannelView   Author: chengzhicao   File: ChannelView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置完成按键背景
 *
 * @param tipFinishBackground
 */
public void setTipFinishBackground(@DrawableRes int tipFinishBackground) {
    this.tipFinishBackground = tipFinishBackground;
    if (channelLayout != null && channelLayout.tipFinish != null) {
        channelLayout.tipFinish.setBackgroundResource(tipFinishBackground);
    }
}
 
Example #28
Source Project: SmartLoadingView   Author: lihangleo2   File: CircleImageView.java    License: MIT License 4 votes vote down vote up
@Override
public void setImageResource(@DrawableRes int resId) {
    super.setImageResource(resId);
    mBitmap = getBitmapFromDrawable(getDrawable());
    setup();
}
 
Example #29
Source Project: star-zone-android   Author: bootsrc   File: CircleImageView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setImageResource(@DrawableRes int resId) {
    super.setImageResource(resId);
    mBitmap = getBitmapFromDrawable(getDrawable());
    setup();
}
 
Example #30
Source Project: scene   Author: bytedance   File: NavigationSceneCompatUtility.java    License: Apache License 2.0 4 votes vote down vote up
@NonNull
public Builder sceneBackground(@DrawableRes int resId) {
    this.mSceneBackgroundResId = resId;
    return this;
}