本文整理汇总了Java中android.content.Context.getColor方法的典型用法代码示例。如果您正苦于以下问题:Java Context.getColor方法的具体用法?Java Context.getColor怎么用?Java Context.getColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Context
的用法示例。
在下文中一共展示了Context.getColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateStatus
import android.content.Context; //导入方法依赖的package包/类
private void updateStatus(FFMStatus status) {
if (status.getGroupBlacklist() != null) {
FFMSettings.putLocalGroupWhitelistValue(status.getGroupBlacklist().isEnabled() ? status.getGroupBlacklist().getCount() : -1);
}
if (status.getDiscussWhitelist() != null) {
FFMSettings.putLocalDiscussWhitelistValue(status.getDiscussWhitelist().isEnabled() ? status.getDiscussWhitelist().getCount() : -1);
}
if (status.isRunning()) {
updateStatus(status.getDevices());
} else {
Context context = getContext();
int color = context.getColor(R.color.serverProblem);
Drawable icon = context.getDrawable(R.drawable.ic_status_error_24dp);
updateStatus(context.getString(R.string.status_webqq_dead), color, icon);
}
}
示例2: getColor
import android.content.Context; //导入方法依赖的package包/类
public int getColor(int resId, Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
//noinspection deprecation
return context.getResources().getColor(resId);
} else {
return context.getColor(resId);
}
}
示例3: fixTitlebarColor
import android.content.Context; //导入方法依赖的package包/类
private void fixTitlebarColor(Toolbar toolbar, Context context) {
int textColor = 0;
if(SDK_INT <= 23) {
textColor = Color.parseColor("#ffffffff");
} else {
textColor = context.getColor(R.color.editTitlebarTextColor);
}
toolbar.setTitleTextColor(textColor);
TextView saveItem = (TextView) toolbar.findViewById(R.id.save_menu);
saveItem.setTextColor(textColor);
}
示例4: AlbumPictureController
import android.content.Context; //导入方法依赖的package包/类
public AlbumPictureController(Context context, final ImageSwitcher view, int size) {
this.view = view;
this.size = size;
this.context = context;
this.cache = new BitmapCache(context, BitmapCache.CACHE_ALBUM_VISUALIZER_IMAGE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
defaultColor = context.getColor(R.color.default_play_bg_color);
defaultTextColor = context.getColor(R.color.default_play_text_color);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
defaultColor = context.getResources().getColor(R.color.default_play_bg_color, null);
defaultTextColor = context.getResources().getColor(R.color.default_play_text_color, null);
} else {
defaultColor = context.getResources().getColor(R.color.default_play_bg_color);
defaultTextColor = context.getResources().getColor(R.color.default_play_text_color);
}
this.bitmapProducer = new BitmapProducer(context);
colors = new int[]{
defaultColor,
defaultTextColor,
defaultColor,
defaultTextColor
};
rotateAnim = ObjectAnimator.ofFloat(0, 360);
rotateAnim.setDuration(45 * 1000);
rotateAnim.setRepeatMode(ValueAnimator.RESTART);
rotateAnim.setRepeatCount(ValueAnimator.INFINITE);
rotateAnim.setInterpolator(new LinearInterpolator());
rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
view.getCurrentView().setRotation(value);
}
});
}
示例5: get10WhiteThemeColors
import android.content.Context; //导入方法依赖的package包/类
/**
* 0 状态栏背景色<br>
* 1 标题栏背景色<br>
* 2 控件首选色<br>
* 3 主背景色<br>
* 4 辅背景色<br>
* 5 主字体色<br>
* 6 辅字体色<br>
* 7 底部导航背景色<br>
* 8 标题栏主字体色<br>
* 9 标题栏辅字体色<br>
*/
public static int[] get10WhiteThemeColors(Context context) {
int[] colors = new int[10];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.theme_white_primary);
colors[1] = context.getColor(R.color.theme_white_primary_dark);
colors[2] = context.getColor(R.color.theme_white_accent);
colors[3] = context.getColor(R.color.theme_white_main_bg);
colors[4] = context.getColor(R.color.theme_white_vic_bg);
colors[5] = context.getColor(R.color.theme_white_main_text);
colors[6] = context.getColor(R.color.theme_white_vic_text);
colors[7] = context.getColor(R.color.theme_white_nav);
colors[8] = context.getColor(R.color.theme_white_toolbar_main_text);
colors[9] = context.getColor(R.color.theme_white_toolbar_vic_text);
} else {
colors[0] = context.getResources().getColor(R.color.theme_white_primary);
colors[1] = context.getResources().getColor(R.color.theme_white_primary_dark);
colors[2] = context.getResources().getColor(R.color.theme_white_accent);
colors[3] = context.getResources().getColor(R.color.theme_white_main_bg);
colors[4] = context.getResources().getColor(R.color.theme_white_vic_bg);
colors[5] = context.getResources().getColor(R.color.theme_white_main_text);
colors[6] = context.getResources().getColor(R.color.theme_white_vic_text);
colors[7] = context.getResources().getColor(R.color.theme_white_nav);
colors[8] = context.getResources().getColor(R.color.theme_white_toolbar_main_text);
colors[9] = context.getResources().getColor(R.color.theme_white_toolbar_vic_text);
}
AppPreference preference = new AppPreference(context);
colors[2] = preference.getAccentColor();
return colors;
}
示例6: get10DarkThemeColors
import android.content.Context; //导入方法依赖的package包/类
/**
* 0 状态栏背景色<br>
* 1 标题栏背景色<br>
* 2 控件首选色<br>
* 3 主背景色<br>
* 4 辅背景色<br>
* 5 主字体色<br>
* 6 辅字体色<br>
* 7 底部导航背景色<br>
* 8 标题栏主字体色<br>
* 9 标题栏辅字体色<br>
*/
public static int[] get10DarkThemeColors(Context context) {
int[] colors = new int[10];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.theme_dark_primary);
colors[1] = context.getColor(R.color.theme_dark_primary_dark);
colors[2] = context.getColor(R.color.theme_dark_accent);
colors[3] = context.getColor(R.color.theme_dark_main_bg);
colors[4] = context.getColor(R.color.theme_dark_vic_bg);
colors[5] = context.getColor(R.color.theme_dark_main_text);
colors[6] = context.getColor(R.color.theme_dark_vic_text);
colors[7] = context.getColor(R.color.theme_dark_nav);
colors[8] = context.getColor(R.color.theme_dark_toolbar_main_text);
colors[9] = context.getColor(R.color.theme_dark_toolbar_vic_text);
} else {
colors[0] = context.getResources().getColor(R.color.theme_dark_primary);
colors[1] = context.getResources().getColor(R.color.theme_dark_primary_dark);
colors[2] = context.getResources().getColor(R.color.theme_dark_accent);
colors[3] = context.getResources().getColor(R.color.theme_dark_main_bg);
colors[4] = context.getResources().getColor(R.color.theme_dark_vic_bg);
colors[5] = context.getResources().getColor(R.color.theme_dark_main_text);
colors[6] = context.getResources().getColor(R.color.theme_dark_vic_text);
colors[7] = context.getResources().getColor(R.color.theme_dark_nav);
colors[8] = context.getResources().getColor(R.color.theme_dark_toolbar_main_text);
colors[9] = context.getResources().getColor(R.color.theme_dark_toolbar_vic_text);
}
return colors;
}
示例7: get2WhiteThemeTextColor
import android.content.Context; //导入方法依赖的package包/类
/**
* 0 主字体颜色
* 1 辅字体颜色
*/
public static int[] get2WhiteThemeTextColor(Context context) {
int[] colors = new int[2];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.theme_white_main_text); //主字体色
colors[1] = context.getColor(R.color.theme_white_vic_text); // 辅字体色
} else {
colors[0] = context.getResources().getColor(R.color.theme_white_main_text);
colors[1] = context.getResources().getColor(R.color.theme_white_vic_text);
}
return colors;
}
示例8: get2DarkThemeTextColor
import android.content.Context; //导入方法依赖的package包/类
/**
* 0 主字体颜色
* 1 辅字体颜色
*/
public static int[] get2DarkThemeTextColor(Context context) {
int[] colors = new int[2];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.theme_dark_main_text); //主字体色
colors[1] = context.getColor(R.color.theme_dark_vic_text); // 辅字体色
} else {
colors[0] = context.getResources().getColor(R.color.theme_dark_main_text);
colors[1] = context.getResources().getColor(R.color.theme_dark_vic_text);
}
return colors;
}
示例9: get2ToolbarTextColors
import android.content.Context; //导入方法依赖的package包/类
public static int[] get2ToolbarTextColors(Context context) {
int[] colors = new int[2];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.white_d);
colors[1] = context.getColor(R.color.white_d_d);
} else {
colors[0] = context.getResources().getColor(R.color.white_d);
colors[1] = context.getResources().getColor(R.color.white_d_d);
}
return colors;
}
示例10: get2ColorWhiteThemeForPlayOptions
import android.content.Context; //导入方法依赖的package包/类
public static int[] get2ColorWhiteThemeForPlayOptions(Context context) {
int[] colors = new int[2];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.dark_l_l_l_l);
colors[1] = context.getColor(R.color.white_d_d_d);
} else {
colors[0] = context.getResources().getColor(R.color.dark_l_l_l_l);
colors[1] = context.getResources().getColor(R.color.white_d_d_d);
}
return colors;
}
示例11: get2ColorDarkThemeForPlayOptions
import android.content.Context; //导入方法依赖的package包/类
public static int[] get2ColorDarkThemeForPlayOptions(Context context) {
int[] colors = new int[2];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.white_d_d);
colors[1] = context.getColor(R.color.white_d_d_d);
} else {
colors[0] = context.getResources().getColor(R.color.white_d_d);
colors[1] = context.getResources().getColor(R.color.white_d_d_d);
}
return colors;
}
示例12: getColor
import android.content.Context; //导入方法依赖的package包/类
public static int getColor(Context context, int id){
if (android.os.Build.VERSION.SDK_INT >= 23) {
return context.getColor(id);
} else {
return context.getResources().getColor(id);
}
}
示例13: getColorWrapper
import android.content.Context; //导入方法依赖的package包/类
public static int getColorWrapper(Context context, int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return context.getColor(color);
} else {
//noinspection deprecation
return context.getResources().getColor(color);
}
}
示例14: getColor
import android.content.Context; //导入方法依赖的package包/类
public static int getColor(Context context, int id) {
if (Build.VERSION.SDK_INT >= 23) {
return context.getColor(id);
}
else {
return context.getColor(id);
}
}
示例15: getColor
import android.content.Context; //导入方法依赖的package包/类
private int getColor(Context context, int colorId) {
int paintColor;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
paintColor = context.getColor(colorId);
} else {
paintColor = context.getResources().getColor(colorId);
}
return paintColor;
}