From e858691cfc05cfcc23fc79cde2344a20f5f27821 Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Thu, 1 Apr 2021 23:54:49 +0800 Subject: [PATCH] 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 --- .../settings/widget/HighlightablePreferenceGroupAdapter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/com/android/settings/widget/HighlightablePreferenceGroupAdapter.java b/src/com/android/settings/widget/HighlightablePreferenceGroupAdapter.java index b3ae6096b78..82b9e763a12 100644 --- a/src/com/android/settings/widget/HighlightablePreferenceGroupAdapter.java +++ b/src/com/android/settings/widget/HighlightablePreferenceGroupAdapter.java @@ -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);