File tree 2 files changed +14
-9
lines changed
lib/java/com/google/android/material
2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -334,8 +334,7 @@ private void initializeLiftOnScrollWithColor(MaterialShapeDrawable background) {
334
334
liftBackground .setAlpha (lifted ? 255 : 0 );
335
335
background .setAlpha (lifted ? 0 : 255 );
336
336
337
- ColorStateList colorSurface =
338
- MaterialColors .getColorStateListOrNull (getContext (), R .attr .colorSurface );
337
+ Integer colorSurface = MaterialColors .getColorOrNull (getContext (), R .attr .colorSurface );
339
338
340
339
liftOnScrollColorUpdateListener =
341
340
valueAnimator -> {
@@ -351,8 +350,7 @@ private void initializeLiftOnScrollWithColor(MaterialShapeDrawable background) {
351
350
liftBackground .getResolvedTintColor ());
352
351
if (statusBarForeground != null
353
352
&& statusBarForegroundOriginalColor != null
354
- && colorSurface != null
355
- && statusBarForegroundOriginalColor == colorSurface .getDefaultColor ()) {
353
+ && statusBarForegroundOriginalColor .equals (colorSurface )) {
356
354
DrawableCompat .setTint (statusBarForeground , mixedColor );
357
355
}
358
356
Original file line number Diff line number Diff line change @@ -114,12 +114,19 @@ public static int getColor(
114
114
@ ColorInt
115
115
public static int getColor (
116
116
@ NonNull Context context , @ AttrRes int colorAttributeResId , @ ColorInt int defaultValue ) {
117
+ Integer color = getColorOrNull (context , colorAttributeResId );
118
+ return color != null ? color : defaultValue ;
119
+ }
120
+
121
+ /**
122
+ * Returns the color int for the provided theme color attribute, or null if the attribute is not
123
+ * set in the current theme.
124
+ */
125
+ @ Nullable
126
+ @ ColorInt
127
+ public static Integer getColorOrNull (@ NonNull Context context , @ AttrRes int colorAttributeResId ) {
117
128
TypedValue typedValue = MaterialAttributes .resolve (context , colorAttributeResId );
118
- if (typedValue != null ) {
119
- return resolveColor (context , typedValue );
120
- } else {
121
- return defaultValue ;
122
- }
129
+ return typedValue != null ? resolveColor (context , typedValue ) : null ;
123
130
}
124
131
125
132
/**
You can’t perform that action at this time.
0 commit comments