Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update AppCompatProgressBarHelper getColorStateList by ThemeUtil getT… #37

Closed
wants to merge 2 commits into from

Conversation

Caij
Copy link

@Caij Caij commented Sep 12, 2017

…hemeColorStateList

#36

@@ -56,11 +56,15 @@ void loadFromAttribute(AttributeSet attrs, int defStyleAttr) {
TypedArray array = mView.getContext().obtainStyledAttributes(attrs, ATTR, defStyleAttr, 0);
if (array.hasValue(0)) {
mProgressTintResId = array.getResourceId(0, 0);
setSupportProgressTint(array.getColorStateList(0));
if (mProgressTintResId != 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经判断了hasValue,mProgressTintResId理应不会为0

@@ -141,10 +145,10 @@ private Drawable getTintTarget(int layerId, boolean shouldFallback) {
@Override
public void tint() {
if (mProgressTintResId != 0) {
setSupportProgressTint(mView.getResources().getColorStateList(mProgressTintResId));
setSupportProgressTint(ThemeUtils.getThemeColorStateList(mView.getContext(), mProgressTintResId));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在setSupportIndeterminateTint函数中有对mProgressTintResId的颜色值进行转换,目前只取getDefaultColor作为染色值

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setSupportIndeterminateTint 中是通过ThemeUtils.getColor()替换color int 的值, 最终体现在replaceColor(Context context, @ColorInt int color)这个方法里面, 而我更希望更多的通过color id替换color的值,也就是replaceColorById(Context context, @ColorRes int colorId)。因为我总感觉替换replaceColor的方法不可靠, replaceColorById更加可靠, 万一有两个color id, 但是两个color id的颜色值都一样,这样的情况下就会出问题。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clear, 已采纳:4d4ae58

@xyczero xyczero closed this Nov 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants