Attempt to fix IllegalArgumentException from RecyclerView

From the log, the crash happens while RecyclerView is doing
animation stuff. In Settings case, we didn't use any animation
in the list, so the simplest solution is to disable the ItemAnimator
completely.

Test: Check if origin listview behavior is affected.
There's no crash after user comes back from subpage.
Fix: 184214085

Change-Id: If0988cb8e036ce5af1b8d2aa0d4ab77effd476e2
This commit is contained in:
Tsung-Mao Fang
2021-04-01 23:54:49 +08:00
parent 123422c99c
commit e858691cfc

View File

@@ -149,6 +149,8 @@ public class HighlightablePreferenceGroupAdapter extends PreferenceGroupAdapter
root.postDelayed(() -> {
mHighlightRequested = true;
// Remove the animator to avoid a RecyclerView crash.
recyclerView.setItemAnimator(null);
recyclerView.smoothScrollToPosition(position);
mHighlightPosition = position;
notifyItemChanged(position);