Fix NPE crash in TextToSpeechSettings

Recyclerview's getItemAnimator() is nullable so we need a null check.

Bug: 245383855
Test: Manual

Change-Id: Iebad430e81a32b7fa8ebe0543abf3f122befb7e5
This commit is contained in:
Shen Lin
2022-09-07 10:21:12 +08:00
parent b2a466d92f
commit fa6a8e9767

View File

@@ -228,7 +228,9 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment
// them to resize, which results in the recyclerview smoothly animating them at inopportune // 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 // times. Disable the animation so widgets snap to their positions rather than sliding
// around while the user is interacting with it. // 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) { if (mTts == null || mCurrentDefaultLocale == null) {
return; return;