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
fix(android): Fixed bug where setting SearchBar "hintText" after window open crashes as of 7.0.0 #10848
Conversation
…fter creation causes crash as of 7.0.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.
LGTM
@@ -347,7 +347,10 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP | |||
} else if (key.equals(TiC.PROPERTY_COLOR)) { | |||
tv.setTextColor(TiConvert.toColor((String) newValue)); | |||
} else if (key.equals(TiC.PROPERTY_HINT_TEXT)) { | |||
int type = proxy.getProperties().getInt(TiC.PROPERTY_HINT_TYPE); | |||
int type = UIModule.HINT_TYPE_STATIC; | |||
if (proxy.getProperties() != null) { |
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.
assign to a temp var to avoid grabbing it via getter twice?
Also, we should consider using a null object pattern here to avoid the null check altogether. If a KrollProxy has a null properties
field, can't we return an empty KrollDict and get the same behavior typically? (i.e. returns null for everything, returns default values if passed in)
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.
I was going to change this to use proxy.getProperty(TiC.PROPERTY_HINT_TYPE)
instead which will return null
if the properties dictionary is null
, but I can see this PR is already merged. That said, I think the current code is fine anyways.
@@ -921,7 +924,11 @@ public void setAttributedStringHint(AttributedStringProxy attrString) | |||
{ | |||
Spannable spannableText = AttributedStringProxy.toSpannable(attrString, TiApplication.getAppCurrentActivity()); | |||
if (spannableText != null) { | |||
int type = getProxy().getProperties().getInt(TiC.PROPERTY_HINT_TYPE); | |||
int type = UIModule.HINT_TYPE_STATIC; | |||
KrollProxy proxy = getProxy(); |
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.
another potential place we could return a null object variant? i.e. if a TiUIView's proxy is null, return a special NullProxy instance that has empty properties?
} catch (err) { | ||
finish(err); | ||
} | ||
}, 100); |
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.
Shouldn't need to add any specific delay in milliseconds here, I wouldn't think. You could put 1 and it should basically allow the UI thread to dispatch before we fire. (also note that technically the delay arg is optional, and under the hood it enforces a minimum delay anyways - so maybe just omit the delay)
FR passed. Searchbar did not crash and works as expected. |
|
JIRA:
https://jira.appcelerator.org/browse/TIMOB-25832
Test:
SearchBar
reads "Hint Text".