/** * Set theme color id (primaryColor and accentColor). * 设置主题颜色 * @param primaryColorId ColorRes 主题颜色ID * @return RefreshLayout */ RefreshLayout setPrimaryColorsId(@ColorRes int... primaryColorId);
private void resetTextColorTintResource(@ColorRes int resId/*text resource id*/) { mTextColorId = resId; if (mTextColorTintInfo != null) { mTextColorTintInfo.mHasTintList = false; mTextColorTintInfo.mTintList = null; } }
private void resetTextLinkColorTintResource(@ColorRes int resId/*text resource id*/) { mTextLinkColorId = resId; if (mTextLinkColorTintInfo != null) { mTextLinkColorTintInfo.mHasTintList = false; mTextLinkColorTintInfo.mTintList = null; } }
/** * Sets the given color resource as background for the content */ void setBackgroundResource(@ColorRes int colorResource);
private static String hexStringColor(Resources resources, @ColorRes int colorResId) { return String.format("#%06X", (0xFFFFFF & resources.getColor(colorResId))); }
static int getColor(@NonNull Context context, @ColorRes int color){ return ContextCompat.getColor(context, color); } }
@SuppressWarnings("deprecation") public static int getColor(@NonNull Context context, @ColorRes int colorId) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getColor(colorId); } return context.getResources().getColor(colorId); }
public int getColor(@ColorRes int id) { return mContext.getResources().getColor(id); }
@ColorInt private int color(@ColorRes int res) { return ContextCompat.getColor(this, res); } }
public static HeaderDesign fromColorResAndUrl(@ColorRes int colorRes, String imageUrl) { HeaderDesign headerDesign = new HeaderDesign(); headerDesign.colorRes = colorRes; headerDesign.imageUrl = imageUrl; return headerDesign; }
public static HeaderDesign fromColorResAndDrawable(@ColorRes int colorRes, Drawable drawable) { HeaderDesign headerDesign = new HeaderDesign(); headerDesign.colorRes = colorRes; headerDesign.drawable = drawable; return headerDesign; }
@Override public void setTextColorById(@ColorRes int colorId) { if (mTextHelper != null) { mTextHelper.setTextColorById(colorId); } }
public static Drawable tintDrawable(Context context, @DrawableRes int resId, @ColorRes int colorId) { if (resId <= 0 || colorId <= 0) return null; Drawable drawable = context.getResources().getDrawable(resId); return tintDrawableByColorId(context, drawable, colorId); }
public static @ColorInt int getColorById(Context context, @ColorRes int colorId) { return replaceColorById(context, colorId); }
@Override public void setTextColorById(@ColorRes int colorId) { if (mTextHelper != null) { mTextHelper.setTextColorById(colorId); } }
static @ColorInt int replaceColorById(Context context, @ColorRes int colorId) { return mSwitchColor == null ? Color.TRANSPARENT : mSwitchColor.replaceColorById(context, colorId); }
/** * Set the colors for the SwipeRefreshLayout states * * @param colRes */ public void setRefreshingColorResources(@ColorRes int... colRes) { mPtrLayout.setColorSchemeResources(colRes); }
@Override public void setTextColorById(@ColorRes int colorId) { if (mTextHelper != null) { mTextHelper.setTextColorById(colorId); } }
@Override public void setTextColorById(@ColorRes int colorId) { if (mTextHelper != null) { mTextHelper.setTextColorById(colorId); } }
private @ColorRes int getThemeColor(Context context, int color, String theme) { switch (color) { case 0xd20000: return context.getResources().getIdentifier(theme, "color", getPackageName()); } return -1; }