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-25687] Android: Picker change listener doesn't work the first time #9763
Conversation
…he onItemSelected guard.
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.
CR: Pass
@ypbnv, |
@jquick-axway Just tested it. It works fine with multiple columns. But I found something else I have missed. I will update once I have it figured out. |
Clean some unnecessary code.
@jquick-axway I updated the code. If you could go through the recent changes that would be great. |
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.
Just a few minor change requests.
The rest looks good to me.
public void onItemSelected(AdapterView<?> parent, View view, int position, long itemId) | ||
{ | ||
if (!firstSelectedFired) { | ||
final OnItemSelectedListener onItemSelectedListener = new OnItemSelectedListener() { |
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.
Can you make this listener member variable private
please?
// swallow the first selected event that gets fired after the adapter gets set, so as to avoid | ||
// firing our change event in that case. | ||
firstSelectedFired = true; | ||
return; | ||
} | ||
fireSelectionChange(0, position); | ||
}*/ |
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.
Since you've removed the firstSelectedFired
member variable, we might as well as delete this commented out code block too.
if (p instanceof View) { | ||
((View) p).invalidate(); | ||
// Invalidate the parent view after the item is selected (TIMOB-13540). | ||
if (Build.VERSION.SDK_INT >= TiC.API_LEVEL_HONEYCOMB) { |
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.
Can you remove the HONEYCOMB version check please? Since API Level 16 is the min version we support now, we should always run the below parent invalidate code.
Remove comments left from older code. Remove outdated platform version check.
@jquick-axway Updated the PR. Also the docs change was made for the previous take on the problem. But it is still relevant because:
Should we keep them that way or maybe reword/revert the docs change? |
@ypbnv , Can you please fix the lint issues https://jenkins.appcelerator.org/job/titanium-sdk/job/titanium_mobile/job/PR-9763/11/console |
FR Passed. The Studio Ver: 5.0.0.201712081732 |
@ypbnv Backport please |
Generated by 🚫 dangerJS |
JIRA: https://jira.appcelerator.org/browse/TIMOB-25687
Description:
Set a default
preselectedRows
pair for NativePicker in order to trigger first time onItemSelect guard.This would match the default selected item when a index is not set.
That is necessary to not lose the first onItemSelected call in case the adapter is filled for the first time from thread different from the UI one.
Test case:
app.js
An Alloy test case can be found in the JIRA ticket.