-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
MvxRecyclerViewAdapter: Support worker threads #2477
Conversation
@softlion can you maybe review this PR? 🙂 |
@@ -241,7 +243,15 @@ protected virtual void SetItemsSource(IEnumerable value) | |||
|
|||
protected virtual void OnItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) | |||
{ | |||
NotifyDataSetChanged(e); | |||
if (Looper.MainLooper == Looper.MyLooper()) |
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.
Isn't there a Mvx method that checks the thread and runs it on main if necessary?
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.
There is MvxAndroidMainThreadDispatcher
. However this class can't inherit from MvxMainThreadDispatchingObject
. So this is a good solution.
This comment was marked as abuse.
This comment was marked as abuse.
@@ -241,7 +243,15 @@ protected virtual void SetItemsSource(IEnumerable value) | |||
|
|||
protected virtual void OnItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) | |||
{ | |||
NotifyDataSetChanged(e); | |||
if (Looper.MainLooper == Looper.MyLooper()) |
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.
There is MvxAndroidMainThreadDispatcher
. However this class can't inherit from MvxMainThreadDispatchingObject
. So this is a good solution.
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Code improvement
When a user tries to update a bound ItemsSource collection from a worker thread, MvxRecyclerViewAdapter just 💥💥.
🆕 What is the new behavior (if this is a feature change)?
MvxRecyclerViewAdapter handles collection changes from worker threads.
💥 Does this PR introduce a breaking change?
No.
🐛 Recommendations for testing
Run TestProjects/Android-Support.
ExampleRecyclerViewModel
updates a collection from background.📝 Links to relevant issues/docs
Closes #2144
🤔 Checklist before submitting