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

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

源代码1 项目: timecat   文件: TintManager.java
@Nullable
public ColorStateList getColorStateList(@ColorRes int resId) {
    if (resId == 0) return null;

    final Context context = mContextRef.get();
    if (context == null) return null;

    ColorStateList colorStateList = mCacheTintList != null ? mCacheTintList.get(resId) : null;
    if (colorStateList == null) {
        colorStateList = ColorStateListUtils.createColorStateList(context, resId);
        if (colorStateList != null) {
            if (mCacheTintList == null) {
                mCacheTintList = new SparseArray<>();
            }
            mCacheTintList.append(resId, colorStateList);
        }
    }
    return colorStateList;
}
 
源代码2 项目: Tok-Android   文件: ScreenUtils.java
public static int getColor(@NonNull Context context, @ColorRes int id) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        return context.getColor(id);
    } else {
        return context.getResources().getColor(id);
    }
}
 
源代码3 项目: SimpleAdapterDemo   文件: CompatResourceUtils.java
public static int getColor(@NonNull Context context, @ColorRes int resId){
    int color;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M){
        color = context.getResources().getColor(resId, context.getTheme());
    } else {
        color = context.getResources().getColor(resId);
    }
    return color;
}
 
源代码4 项目: PocketEOS-Android   文件: ImmersionBar.java
/**
 * 解决布局与状态栏重叠问题,支持侧滑返回
 * Fits system windows immersion bar.
 *
 * @param fits                               the fits
 * @param statusBarColorContentView          the status bar color content view 状态栏颜色
 * @param statusBarColorContentViewTransform the status bar color content view transform  状态栏变色后的颜色
 * @param statusBarContentViewAlpha          the status bar content view alpha  透明度
 * @return the immersion bar
 */
public ImmersionBar fitsSystemWindows(boolean fits, @ColorRes int statusBarColorContentView
        , @ColorRes int statusBarColorContentViewTransform, @FloatRange(from = 0f, to = 1f) float statusBarContentViewAlpha) {
    mBarParams.fits = fits;
    mBarParams.statusBarColorContentView = ContextCompat.getColor(mActivity, statusBarColorContentView);
    mBarParams.statusBarColorContentViewTransform = ContextCompat.getColor(mActivity, statusBarColorContentViewTransform);
    mBarParams.statusBarContentViewAlpha = statusBarContentViewAlpha;
    mBarParams.statusBarColorContentView = ContextCompat.getColor(mActivity, statusBarColorContentView);
    mContentView.setBackgroundColor(ColorUtils.blendARGB(mBarParams.statusBarColorContentView,
            mBarParams.statusBarColorContentViewTransform, mBarParams.statusBarContentViewAlpha));
    return this;
}
 
源代码5 项目: DanDanPlayForAndroid   文件: CommonUtils.java
/**
 * 获取加透明度的资源颜色
 */
@ColorInt
public static int getResColor(@IntRange(from = 0, to = 255) int alpha, @ColorRes int colorId) {
    int color = getResColor(colorId);

    int red = Color.red(color);
    int green = Color.green(color);
    int blue = Color.blue(color);

    return Color.argb(alpha, red, green, blue);
}
 
源代码6 项目: timecat   文件: TimeCatApp.java
@Override
public int replaceColorById(Context context, @ColorRes int colorId) {
    if (ThemeManager.isDefaultTheme(context)) {
        return context.getResources().getColor(colorId);
    }
    String theme = getTheme(context);
    if (theme != null) {
        colorId = getThemeColorId(context, colorId, theme);
    }
    return context.getResources().getColor(colorId);
}
 
源代码7 项目: styT   文件: TapTarget.java
@Nullable
private Integer colorResOrInt(Context context, @Nullable Integer value, @ColorRes int resource) {
    if (resource != -1) {
        return ContextCompat.getColor(context, resource);
    }

    return value;
}
 
源代码8 项目: PowerFileExplorer   文件: ColorPref.java
@ColorRes
private int getColorResAt(int position) {
    Integer item = getItem(position);

    if (item == null) {
        return usage.getDefaultColor();
    } else {
        return item.intValue();
    }
}
 
源代码9 项目: timecat   文件: TimeCatApp.java
private @ColorRes
int getThemeColorId(Context context, int colorId, String theme) {
    switch (colorId) {
        case R.color.theme_color_primary:
            return context.getResources().getIdentifier(theme, "color", getPackageName());
        case R.color.theme_color_primary_dark:
            return context.getResources().getIdentifier(theme + "_dark", "color", getPackageName());
        case R.color.playbarProgressColor:
            return context.getResources().getIdentifier(theme + "_trans", "color", getPackageName());
    }
    return colorId;
}
 
源代码10 项目: timecat   文件: AppCompatTextHelper.java
private void setTextColor(@ColorRes int resId) {
    if (mTextColorId != resId) {
        resetTextColorTintResource(resId);

        if (resId != 0) {
            setSupportTextColorTint(resId);
        }
    }
}
 
源代码11 项目: OmniList   文件: PalmApp.java
public static @ColorInt int getColorCompact(@ColorRes int colorRes) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        return PalmApp.getContext().getColor(colorRes);
    } else {
        return PalmApp.getContext().getResources().getColor(colorRes);
    }
}
 
源代码12 项目: timecat   文件: TintRadioButton.java
@Override
public void setTextColorById(@ColorRes int colorId) {
    if (mTextHelper != null) {
        mTextHelper.setTextColorById(colorId);
    }
}
 
源代码13 项目: SmartLoadingView   文件: CircleImageView.java
public void setBorderColorResource(@ColorRes int borderColorRes) {
    setBorderColor(getContext().getResources().getColor(borderColorRes));
}
 
public void setSecondaryLineColor(@ColorRes int color) {
    GREY = color;
}
 
源代码15 项目: input-samples   文件: NavigationItem.java
public NavigationItem(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr,
        int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationItem,
            defStyleAttr, defStyleRes);
    int activityMinSdk = typedArray.getInteger(R.styleable.NavigationItem_minSdk, 26);

    // TODO: Remove BuildCompat.isAtLeastP() check when API 28 is finalized.
    int deviceMinSdk = BuildCompat.isAtLeastP() ? 28 : Build.VERSION.SDK_INT;
    if (deviceMinSdk < activityMinSdk) {
        // If device's SDK is lower than the minSdk specified by the NavigationItem, hide it.
        setVisibility(View.GONE);
        return;
    }
    String labelText = typedArray.getString(R.styleable.NavigationItem_labelText);
    String infoText = typedArray.getString(R.styleable.NavigationItem_infoText);
    Drawable logoDrawable = typedArray.getDrawable(R.styleable.NavigationItem_itemLogo);
    @ColorRes int colorRes = typedArray.getResourceId(R.styleable.NavigationItem_imageColor, 0);
    String launchingActivityName = typedArray.getString(R.styleable.NavigationItem_destinationActivityName);
    int imageColor = ContextCompat.getColor(getContext(), colorRes);
    typedArray.recycle();
    View rootView = LayoutInflater.from(context).inflate(R.layout.navigation_item, this);
    TextView buttonLabel = rootView.findViewById(R.id.buttonLabel);
    buttonLabel.setText(labelText);
    if (logoDrawable != null) {
        Drawable mutatedLogoDrawable = logoDrawable.mutate();
        mutatedLogoDrawable.setColorFilter(imageColor, PorterDuff.Mode.SRC_IN);
        buttonLabel.setCompoundDrawablesRelativeWithIntrinsicBounds(mutatedLogoDrawable, null,
                null, null);
    }
    InfoButton infoButton = rootView.findViewById(R.id.infoButton);
    infoButton.setInfoText(infoText);
    infoButton.setColorFilter(imageColor);
    CardView outerView = rootView.findViewById(R.id.cardView);
    outerView.setOnClickListener((view) -> {
        if (launchingActivityName != null) {
            Intent intent = new Intent();
            intent.setClassName(getContext().getPackageName(), launchingActivityName);
            context.startActivity(intent);
        } else {
            Log.w(TAG, "Launching Activity name not set.");
        }
    });
}
 
源代码16 项目: Android-utils   文件: ResUtils.java
@ColorInt
public static int getColor(@ColorRes int id) {
    return UtilsApp.getApp().getResources().getColor(id);
}
 
源代码17 项目: FeedbackDialog   文件: FeedBackDialog.java
public FeedBackDialog setBackgroundColor(@ColorRes int mBackgroundColor) {
    this.mBackgroundColor = mBackgroundColor;
    return this;
}
 
源代码18 项目: FeedbackDialog   文件: FeedBackDialog.java
public FeedBackDialog setIconColor(@ColorRes int mIconColor)
{
    this.mIconColor = mIconColor;
    return this;
}
 
源代码19 项目: OmniList   文件: Colorful.java
ThemeColor(@ColorRes int colorRes, @ColorRes int darkColorRes, String identifyName, String displayName) {
    this.colorRes = colorRes;
    this.darkColorRes = darkColorRes;
    this.identifyName = identifyName;
    this.displayName = displayName;
}
 
源代码20 项目: Hify   文件: SwipeConfiguration.java
public Builder setLeftBackgroundColorResource(@ColorRes int resId) {
    mLeftBackgroundColor = mContext.getResources().getColor(resId);
    return this;
}
 
源代码21 项目: Hify   文件: SwipeConfiguration.java
public Builder setRightBackgroundColorResource(@ColorRes int resId) {
    mRightBackgroundColor = mContext.getResources().getColor(resId);
    return this;
}
 
源代码22 项目: relight   文件: SwipeRefreshWidget.java
public SwipeRefreshWidget colorSchemeResources(@ColorRes int... colorResIds) {
    view.setColorSchemeResources(colorResIds);
    return self();
}
 
源代码23 项目: ToDoList   文件: CircleImageView.java
/**
 * @deprecated Use {@link #setBorderColor(int)} instead
 */
@Deprecated
public void setBorderColorResource(@ColorRes int borderColorRes) {
    setBorderColor(getContext().getResources().getColor(borderColorRes));
}
 
源代码24 项目: relight   文件: MaterialButtonWidget.java
public MaterialButtonWidget iconTintResource(@ColorRes int iconTintResourceId) {
    view.setIconTintResource(iconTintResourceId);
    return self();
}
 
源代码25 项目: imsdk-android   文件: BaseBuilder.java
public H setTextColorRes(@ColorRes int color, @NonNull Context context){
	mProgress.setTextColor(context.getResources().getColor(color));
	return (H) this;
}
 
源代码26 项目: imsdk-android   文件: CircleProgress.java
public Builder setBottomColorRes(@ColorRes int ColorRes, Context context) {
	mProgress.mCircleBottomColor = context.getResources().getColor(ColorRes);
	return this;
}
 
源代码27 项目: imsdk-android   文件: CircleProgress.java
public Builder setProgressColorRes(@ColorRes int ColorRes, Context context) {
	mProgress.mCircleProgressColor = context.getResources().getColor(ColorRes);
	return this;
}
 
源代码28 项目: kAndroid   文件: BaseRateView.java
public int getColor(@ColorRes int resId) {
    return ContextCompat.getColor(getContext(), resId);
}
 
源代码29 项目: DanDanPlayForAndroid   文件: CommonPlayerUtils.java
@ColorInt
public static int getResColor(Context context, @ColorRes int colorId){
    return ContextCompat.getColor(context, colorId);
}
 
源代码30 项目: kAndroid   文件: BaseLineRateView.java
public int getColor(@ColorRes int resId) {
    return ContextCompat.getColor(getContext(), resId);
}
 
 同包方法