From 70b8bd92c9d69b6964c42ce62b02f93b9ad5884a Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Fri, 4 Nov 2022 15:33:55 +0800 Subject: [PATCH] Fix NPE crash in TextToSpeechSettings Recyclerview's getItemAnimator() is nullable so we need a null check. Bug: 254330134 Test: Manual Change-Id: Iba5b0d68740c430fd1143d38ccf344afef486784 Merged-In: fa6a8e9767dbf253d1803928185c0e0e19d76d5a --- src/com/android/settings/tts/TextToSpeechSettings.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java index 30e99677301..6db5710c364 100644 --- a/src/com/android/settings/tts/TextToSpeechSettings.java +++ b/src/com/android/settings/tts/TextToSpeechSettings.java @@ -228,7 +228,9 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment // them to resize, which results in the recyclerview smoothly animating them at inopportune // times. Disable the animation so widgets snap to their positions rather than sliding // around while the user is interacting with it. - getListView().getItemAnimator().setMoveDuration(0); + if (getListView().getItemAnimator() != null) { + getListView().getItemAnimator().setMoveDuration(0); + } if (mTts == null || mCurrentDefaultLocale == null) { return;