Brais Gabin
01/22/2020, 5:02 PMnotifyDataSetChanged
or a setText
performed outside the main thread. The problem is that the app is huge and those errors are race exceptions so they are not easy to reproduce. For that reason I’ll need some “tool” that checks that all the interactions done with view is done in the main thread. Any idea?trevjones
01/22/2020, 5:07 PMif (Looper.myLooper() != Looper.getMainLooper()) {
throw new IllegalStateException("Expected to be called on the main thread but was " + Thread.currentThread().getName());
}
I like to wrap that logic up in a function and call it from all over the points that you suspect are being accessed illegally. requireMainThread
Brais Gabin
01/22/2020, 5:30 PMtrevjones
01/22/2020, 5:31 PMtrevjones
01/22/2020, 5:46 PMandroid.view.ViewRootImpl#runOrPost(View source, int changeType)
which gets hit from
notifySubtreeAccessibilityStateChanged(View child, View source, int changeType)
so only a specific set of changes checks it seems.trevjones
01/22/2020, 5:47 PMtrevjones
01/22/2020, 5:48 PMBrais Gabin
01/22/2020, 6:36 PMBrais Gabin
01/22/2020, 6:36 PM