Skip to content

Commit 8527354

Browse files
andvalsolSolera
and
Solera
authored
fix(android): improve color resource handling in Common.java (#913)
The changes handle the fetching of color resources more accurately in our Common.java file. The old method was simplified to one line, but this didn't consider raw color values. Now, the code correctly handles both cases: when the type value is resolved to a color resource ID, and when it's resolved to a raw color value. Co-authored-by: Solera <[email protected]>
1 parent 8d9ba88 commit 8527354

File tree

1 file changed

+8
-2
lines changed
  • android/src/main/java/com/reactcommunity/rndatetimepicker

1 file changed

+8
-2
lines changed

android/src/main/java/com/reactcommunity/rndatetimepicker/Common.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,14 @@ public static int getDefaultDialogButtonTextColor(@NonNull Context activity) {
6363
TypedValue typedValue = new TypedValue();
6464
Resources.Theme theme = activity.getTheme();
6565
theme.resolveAttribute(android.R.attr.textColorPrimary, typedValue, true);
66-
@ColorRes int colorRes = (typedValue.resourceId != 0) ? typedValue.resourceId : typedValue.data;
67-
@ColorInt int colorId = ContextCompat.getColor(activity, colorRes);
66+
@ColorInt int colorId;
67+
if (typedValue.resourceId != 0) {
68+
// Resolved to a color resource ID
69+
colorId = ContextCompat.getColor(activity, typedValue.resourceId);
70+
} else {
71+
// Resolved to a raw color value
72+
colorId = typedValue.data;
73+
}
6874
return colorId;
6975
}
7076

0 commit comments

Comments
 (0)