-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[TIMOB-18053] Android: fixed default text color value changing #8661
Conversation
@@ -82,8 +83,9 @@ private void styleTextView(int position, TextView tv) { | |||
} | |||
if (rowProxy.hasProperty(TiC.PROPERTY_COLOR)) { | |||
final int color = TiConvert.toColor(rowProxy.getProperties(), TiC.PROPERTY_COLOR); | |||
if (defaultTextColor != color) { | |||
if (defaultTextColor != color && !setDefaultColor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static int defaultTextColor = 0;
...
if (!defaultTextColor) {
That should be sufficient, like my original example 👍
538774a
to
58c1997
Compare
@@ -41,7 +41,8 @@ | |||
{ | |||
private static final String TAG = "TiUINativePicker"; | |||
private boolean firstSelectedFired = false; | |||
private static int defaultTextColor = 0; | |||
private static int defaultTextColor = -1; | |||
private static boolean setDefaultColor = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the boolean isn't needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would throw a compile error: you can't use boolean operators on integer types in Java.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do this instead
if (defaultTextColor == 0) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean setdefaultTextColor
to 0 and using your snippet then it behaves weird initially as text is not visible. Also, this if block would get called x2 for every item with text color set to 0. Seems inefficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see a problem. We should be setting the defaultColor
regardless if PROPERTY_COLOR
is defined. Otherwise, the initial text wont be set to the default text color unless an item with PROPERTY_COLOR
is set first. And yes, good catch keep the Boolean 👍
See if this works?
private static int defaultTextColor;
private static boolean setDefaultTextColor = false;
...
private void styleTextView(int position, TextView tv) {
...
if (!setDefaultTextColor) {
defaultTextColor = tv.getCurrentTextColor();
setDefaultTextColor = true;
}
if (rowProxy.hasProperty(TiC.PROPERTY_COLOR)) {
final int color = TiConvert.toColor(rowProxy.getProperties(), TiC.PROPERTY_COLOR);
tv.setTextColor(color);
} else {
tv.setTextColor(defaultTextColor);
}
...
9e405e1
to
5930608
Compare
@@ -41,7 +41,8 @@ | |||
{ | |||
private static final String TAG = "TiUINativePicker"; | |||
private boolean firstSelectedFired = false; | |||
private static int defaultTextColor = 0; | |||
private static int defaultTextColor; | |||
private static boolean setDefaultTextColor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! But lets initialise this setDefaultTextColor = false
b08c787
to
8160c1a
Compare
CR: PASS |
CHANGED
TEST CASE
Comment and uncomment colors in each picker row.
EXPECTED
A picker row's text color should only be set if specified otherwise should be default color.
JIRA: https://jira.appcelerator.org/browse/TIMOB-18053