-
-
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
[TC-4078]: make ListSection methods run on UI thread as required #5658
Conversation
@@ -135,9 +139,10 @@ public void setAdapter(TiBaseAdapter a) { | |||
|
|||
@Kroll.method @Kroll.setProperty | |||
public void setHeaderView(TiViewProxy headerView) { | |||
this.headerView = headerView; |
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.
This is a bug. Here the headerView
property can be set in any arbitrary thread, and only notifyDataChange
ensured the UI thread prior to calling adapter.notifyDataSetChanged
. This fix makes sure that that the property change and adapter.notifyDataSetChanged are both called in the same code block on the UI thread, as required by Android. Fixed this for headerView
, headerTitle
, footerView
, footerTitle
.
Appcelerator team - this PR fixes occasional app crashes, please review and accept. Thanks. |
Code reviewed. Looks good |
if (TiApplication.isUIThread()) { | ||
handleSetHeaderView(headerView); | ||
} else { | ||
TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_HEADER_VIEW, headerView)); |
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.
should be TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_HEADER_VIEW), headerView);
Functionally tested. Looks good after a couple minor fixes mentioned above. |
Thanks for catching that.... Fixed. |
[TC-4078]: make ListSection methods run on UI thread as required
Prior to this fix I was seeing an occasional error message in my app: java.lang.IllegalStateException: "The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(-1, class android.widget.ListView) with Adapter(class android.widget.HeaderViewListAdapter)]
See line notes for the bugs fixed