XOutdatedUtils 工具类的getColor在5.0系统下运行出错
GitHubAFeng opened this issue · 1 comments
GitHubAFeng commented
XOutdatedUtils 工具类的getColor在5.0系统下运行出错,更改为如下就可以了:
public static int getColor(@ColorRes int id) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
return ContextCompat.getColor(XFrame.getContext(), id);
else
return XFrame.getResources().getColor(id);
}
youth5201314 commented
感谢你提出的问题,我发现我多次一举了,ContextCompat已经处理过了
ContextCompat.getColor的源码:
public static final int getColor(Context context, int id) {
final int version = Build.VERSION.SDK_INT;
if (version >= 23) {
return ContextCompatApi23.getColor(context, id);
} else {
return context.getResources().getColor(id);
}
}