Java Code Examples for android.support.annotation.ColorRes

The following are top voted examples for showing how to use android.support.annotation.ColorRes. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: leoapp-sources   File: VerificationFragment.java   View source code 6 votes vote down vote up
public static VerificationFragment newInstance(@StringRes int title,
                                               @StringRes int content,
                                               @ColorRes int color,
                                               int position) {

    VerificationFragment fragmentInfo = new VerificationFragment();

    Bundle bundle = new Bundle(4);
    bundle.putInt("title", title);
    bundle.putInt("content", content);
    bundle.putInt("color", color);
    bundle.putInt("order", position);

    fragmentInfo.setArguments(bundle);

    return fragmentInfo;
}
 
Example 2
Project: ImmerseMode   File: NormalImmerseMode.java   View source code 5 votes vote down vote up
@Override
public void setStatusColorRes(@ColorRes int colorRes) {
    Activity activity = mActivityRef.get();
    if (activity != null) {
        int color = ContextCompat.getColor(activity, colorRes);
        setStatusColor(color);
    }
}
 
Example 3
Project: KUtils   File: BuildBean.java   View source code 5 votes vote down vote up
@Override
public BuildBean setMsgColor(@ColorRes int colorRes) {
    if (colorRes > 0) {
        this.msgTxtColor = colorRes;
    }
    return this;
}
 
Example 4
Project: ImmerseMode   File: TlSbNNbImmerseMode.java   View source code 5 votes vote down vote up
@Override
public void setNavigationColorRes(@ColorRes int colorRes) {
    Activity activity = mActivityRef.get();
    if (activity != null) {
        int color = ContextCompat.getColor(activity, colorRes);
        setNavigationColor(color);
    }
}
 
Example 5
Project: AppAuth-OAuth2-Books-Demo   File: BooksApp.java   View source code 5 votes vote down vote up
public int getColorValue(@ColorRes int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        return getColor(color);
    } else {
        return getResources().getColor(color);
    }
}
 
Example 6
Project: goRefresh   File: MulRingProgressBar.java   View source code 5 votes vote down vote up
public void setColors(@ColorRes int... colorResIds) {
    int colorsCount = Math.min(colorResIds.length, mCount);
    int[] colorRes = new int[colorsCount];
    for (int i = 0; i < colorRes.length; i++) {
        colorRes[i] = ContextCompat.getColor(context, colorResIds[i]);
    }
    setColorSchemeColors(colorRes);
}
 
Example 7
Project: boohee_v5.6   File: SwipeRefreshLayout.java   View source code 5 votes vote down vote up
public void setColorSchemeResources(@ColorRes int... colorResIds) {
    Resources res = getResources();
    int[] colorRes = new int[colorResIds.length];
    for (int i = 0; i < colorResIds.length; i++) {
        colorRes[i] = res.getColor(colorResIds[i]);
    }
    setColorSchemeColors(colorRes);
}
 
Example 8
Project: ImmerseMode   File: TpSbTlNbImmerseMode.java   View source code 5 votes vote down vote up
@Override
public void setNavigationColorRes(@ColorRes int colorRes) {
    Activity activity = mActivityRef.get();
    if (activity != null) {
        int color = ContextCompat.getColor(activity, colorRes);
        setNavigationColor(color);
    }
}
 
Example 9
Project: AndroidOpen   File: RevealActivity.java   View source code 5 votes vote down vote up
private Animator animateRevealColorFromCoordinates(ViewGroup viewRoot, @ColorRes int color, int x, int y) {
    float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());

    Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, 0, finalRadius);
    viewRoot.setBackgroundColor(ContextCompat.getColor(this, color));
    anim.setDuration(getResources().getInteger(R.integer.anim_duration_long));
    anim.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.start();
    return anim;
}
 
Example 10
Project: tenor-android-demo-search   File: ColorPalette.java   View source code 5 votes vote down vote up
/**
 * Get a {@link ColorRes} from the given color resource ids
 *
 * @param index the index of the randomized {@link ColorRes}
 * @return a {@link ColorRes}
 */
@ColorRes
public int get(@IntRange(from = 0, to = Integer.MAX_VALUE) int index) {
    if (index < 0) {
        index = Math.abs(index);
    }
    return mColorPalette[index % mCount];
}
 
Example 11
Project: Android-FilterView   File: SingleOption.java   View source code 5 votes vote down vote up
public SingleOption(String title, @ColorRes int titleColor, @DrawableRes int icon, @ColorRes int selectedIconColor,
                    @ColorRes int deselectedIconColor, int borderWidth, @ColorRes int borderColor) {
    super(title, titleColor);
    this.icon = icon;
    this.borderWidth = borderWidth;
    this.borderColor = borderColor;
    this.selectedIconColor = selectedIconColor;
    this.deselectedIconColor = deselectedIconColor;
}
 
Example 12
Project: KUtils   File: BuildBean.java   View source code 5 votes vote down vote up
@Override
public BuildBean setBtnColor(@ColorRes int btn1Color, @ColorRes int btn2Color, @ColorRes int btn3Color) {
    if (btn1Color > 0)
        this.btn1Color = btn1Color;
    if (btn2Color > 0)
        this.btn2Color = btn2Color;
    if (btn3Color > 0)
        this.btn3Color = btn3Color;
    return this;
}
 
Example 13
Project: PicKing   File: GoogleCircleProgressView.java   View source code 5 votes vote down vote up
/**
 * Update the background color of the mBgCircle image view.
 */
public void setBackgroundColor(@ColorRes int colorRes) {
    if (getBackground() instanceof ShapeDrawable) {
        final Resources res = getResources();
        ((ShapeDrawable) getBackground()).getPaint().setColor(res.getColor(colorRes));
    }
}
 
Example 14
Project: boohee_v5.6   File: ResourcesCompat.java   View source code 5 votes vote down vote up
@ColorInt
public static int getColor(@NonNull Resources res, @ColorRes int id, @Nullable Theme theme) throws NotFoundException {
    if (VERSION.SDK_INT >= 23) {
        return ResourcesCompatApi23.getColor(res, id, theme);
    }
    return res.getColor(id);
}
 
Example 15
Project: Alerter   File: Alerter.java   View source code 5 votes vote down vote up
/**
 * Set the Progress bar color from a color resource
 *
 * @param color The color resource
 * @return This Alerter
 */
public Alerter setProgressColorRes(@ColorRes final int color) {
    if (getAlert() != null) {
        getAlert().setProgressColorRes(color);
    }

    return this;
}
 
Example 16
Project: LoadDataLayout   File: LoadDataLayout.java   View source code 5 votes vote down vote up
public LoadDataLayout setAllPageBackgroundColor(@ColorRes int colorId) {
    loadingView.setBackgroundColor(getColor(colorId));
    emptyView.setBackgroundColor(getColor(colorId));
    errorView.setBackgroundColor(getColor(colorId));
    noNetworkView.setBackgroundColor(getColor(colorId));
    return this;
}
 
Example 17
Project: TextEmoji   File: CombinedTabView.java   View source code 5 votes vote down vote up
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();
}
 
Example 18
Project: HeadlineNews   File: UIBottomBarItem.java   View source code 5 votes vote down vote up
private ColorStateList getColorStateListWithNomalColorAndSelctedColor(@ColorRes int colorNomal
        , @ColorRes int colorSelected) {
    int nomalColor = ResouceUtil.getColor(colorNomal);
    int selectedColor = ResouceUtil.getColor(colorSelected);
    ColorStateList colorStateList = new ColorStateList(new int[][]{{android.R.attr.state_selected}, {}},
            new int[]{selectedColor, nomalColor});
    return colorStateList;
}
 
Example 19
Project: Mix   File: AppCompatTextHelper.java   View source code 5 votes vote down vote up
private void setTextColor(@ColorRes int resId) {
    if (mTextColorId != resId) {
        resetTextColorTintResource(resId);

        if (resId != 0) {
            setSupportTextColorTint(resId);
        }
    }
}
 
Example 20
Project: GitHub   File: ConfigBean.java   View source code 5 votes vote down vote up
@Override
public ConfigBean seInputColor(@ColorRes int colorRes) {
    if (colorRes >0){
        this.inputTxtColor = colorRes;
    }
    return this;
}
 
Example 21
Project: Graywater   File: Palette.java   View source code 5 votes vote down vote up
public Palette(String name, @ColorRes int... colors) {
	this.name = name;

	for (int color : colors) {
		this.colors.add(color);
	}
}
 
Example 22
Project: MainActivityUIUtil   File: StatusbarUtil.java   View source code 5 votes vote down vote up
/**
 * 状态栏背景色为淡色时,为防止状态栏上白色字体看不清而采取的一系列适配措施.
 *
 * 适用于状态栏情况单一的activity,此方法中,不仅设置了背景色,还更改了状态栏文字颜色
 *
 * @param activity
 * @param colorLight UI图上给的状态栏背景色
 * @param colorDeep 在无法变更状态栏文字颜色的手机上,状态栏背景采用什么颜色.传入的是R.color.xxx
 */
public static void setBgColorLight(Activity activity, @ColorRes int colorLight, @ColorRes int colorDeep) {
    int color = colorLight;

    if(isXiaomi()){
        setMiuiStatusBarDarkMode(activity,true);
    }else if(isMeizu()){
        setMeizuStatusBarDarkIcon(activity,true);
    }else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        setBlackFontUpM(activity,true);
    }else {
        color = colorDeep;
    }
    setBgColor(activity, color);
}
 
Example 23
Project: ImmerseMode   File: TlSbNNbwFCwARImmerseMode.java   View source code 5 votes vote down vote up
@Override
public void setStatusColorRes(@ColorRes int colorRes) {
    Activity activity = mActivityRef.get();
    if (activity != null) {
        int color = ContextCompat.getColor(activity, colorRes);
        setStatusColor(color);
    }
}
 
Example 24
Project: GitHub   File: BuildBean.java   View source code 5 votes vote down vote up
@Override
public BuildBean setMsgColor(@ColorRes int colorRes) {
    if (colorRes > 0) {
        this.msgTxtColor = colorRes;
    }
    return this;
}
 
Example 25
Project: ImmerseMode   File: TpSbNNbwFCImmerseMode.java   View source code 5 votes vote down vote up
@Override
public void setStatusColorRes(@ColorRes int colorRes) {
    Activity activity = mActivityRef.get();
    if (activity != null) {
        setStatusColor(ContextCompat.getColor(activity, colorRes));
    }
}
 
Example 26
Project: SkinFramework   File: ComposedResources.java   View source code 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.M)
@Nullable
@Override
public ColorStateList getColorStateList(@ColorRes int id, @Nullable Theme theme) throws NotFoundException {
    int realId = getCorrespondResId(id);
    if (realId > 0) {
        return mSkinResources.getColorStateList(realId, theme);
    }
    return super.getColorStateList(id, theme);
}
 
Example 27
Project: Mix   File: BaseApplication.java   View source code 5 votes vote down vote up
@Override
public int replaceColorById(Context context, @ColorRes int colorId) {
    if (ThemeHelper.isDefaultTheme(context)) {
        return context.getResources().getColor(colorId);
    }
    String theme = getTheme(context);
    if (theme != null) {
        colorId = getThemeColorId(context, colorId, theme);
    }
    return context.getResources().getColor(colorId);
}
 
Example 28
Project: TextBuilder   File: TextBuilder.java   View source code 4 votes vote down vote up
@CheckResult public TextBuilder addColoredTextRes(@StringRes final int textRes, @ColorRes final int colorRes) {
  return addColoredText(context.getString(textRes), ContextCompat.getColor(context, colorRes));
}
 
Example 29
Project: Protein   File: ListFragment.java   View source code 4 votes vote down vote up
@Override
@ColorRes
public int toolbarBackground() {
    return R.color.protein_white;
}
 
Example 30
Project: MusicX-music-player   File: Config.java   View source code 4 votes vote down vote up
@Override
public Config toolbarColorRes(@ColorRes int colorRes) {
    return toolbarColor(ContextCompat.getColor(mContext, colorRes));
}
 
Example 31
Project: HeroVideo-master   File: CircleImageView.java   View source code 4 votes vote down vote up
public void setBorderColorResource(@ColorRes int borderColorRes)
{

    setBorderColor(getContext().getResources().getColor(borderColorRes));
}
 
Example 32
Project: Discover   File: CircleImageView.java   View source code 4 votes vote down vote up
/**
 * @deprecated Use {@link #setBorderColor(int)} instead
 */
@Deprecated
public void setBorderColorResource(@ColorRes int borderColorRes) {
    setBorderColor(getContext().getResources().getColor(borderColorRes));
}
 
Example 33
Project: markor   File: AppSettingsBase.java   View source code 4 votes vote down vote up
public int rcolor(@ColorRes int resColorId) {
    return ContextCompat.getColor(_context, resColorId);
}
 
Example 34
Project: Protein   File: ListContract.java   View source code 4 votes vote down vote up
@ColorRes
int toolbarBackground();
 
Example 35
Project: StatusView   File: StatusView.java   View source code 4 votes vote down vote up
public void setDialogLoadingViewBackgroundColor(@ColorRes int resId) {
    if (mDialogParentLayout != null) {
        mDialogLayout.setBackgroundColor(ContextCompat.getColor(getContext(), resId));
    }
}
 
Example 36
Project: Mix   File: ThemeUtils.java   View source code 4 votes vote down vote up
static
@ColorInt
int replaceColorById(Context context, @ColorRes int colorId) {
    return mSwitchColor == null ? Color.TRANSPARENT : mSwitchColor.replaceColorById(context, colorId);
}
 
Example 37
Project: LoadDataLayout   File: LoadDataLayout.java   View source code 4 votes vote down vote up
public Builder setAllPageBackgroundColor(@ColorRes int allPageBackgroundColor) {
    this.allPageBackgroundColor = allPageBackgroundColor;
    return builder;
}
 
Example 38
Project: disclosure-android-app   File: AppListItem.java   View source code 4 votes vote down vote up
private @ColorRes int getPermissionCountTextColor(AppReport appReport) {
  return appReport.wasAnalyzed() && appReport.permissionCount() > 0
      ? R.color.color_accent
      : R.color.color_text_secondary;
}
 
Example 39
Project: GitHub   File: TextBadgeItem.java   View source code 4 votes vote down vote up
/**
 * @param colorResource resource for text color
 * @return this, to allow builder pattern
 */
public TextBadgeItem setTextColorResource(@ColorRes int colorResource) {
    this.mTextColorResource = colorResource;
    setTextColor();
    return this;
}
 
Example 40
Project: GitHub   File: TextBadgeItem.java   View source code 4 votes vote down vote up
/**
 * @param colorResource resource for border color
 * @return this, to allow builder pattern
 */
public TextBadgeItem setBorderColorResource(@ColorRes int colorResource) {
    this.mBorderColorResource = colorResource;
    refreshDrawable();
    return this;
}