Skip to content

Commit 5c21552

Browse files
committed
[Fix] Fix getColorFromAttrRes() when attribute value is a color literal.
1 parent 229e746 commit 5c21552

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • library/src/main/java/me/zhanghai/android/fastscroll

library/src/main/java/me/zhanghai/android/fastscroll/Utils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class Utils {
3131
@ColorInt
3232
public static int getColorFromAttrRes(@AttrRes int attrRes, @NonNull Context context) {
3333
TypedArray a = context.obtainStyledAttributes(new int[] { attrRes });
34+
int type = a.getType(0);
35+
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
36+
return a.getColor(0, 0);
37+
}
3438
int resId;
3539
try {
3640
resId = a.getResourceId(0, 0);

0 commit comments

Comments
 (0)