Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 018e3d97 authored by Joanne Chung's avatar Joanne Chung
Browse files

Bug Fix: fix NullPointerException while scrolling message apps

The issue will occur when the view is removed from the hierarchy by
the time the translation response returns. Do a null check to make
sure the view still exists.

Bug: 196933332
Test: atest CtsTranslationTestCases
Tese: manual. not see the crash when scrolling the apps.

Change-Id: Ifee933a802385750d431800ef50f6f2c306ccc0f
parent 1b5d7b4c
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -356,7 +356,11 @@ public class UiTranslationController {
            }
            for (int i = 0; i < translatedResult.size(); i++) {
                final AutofillId autofillId = new AutofillId(translatedResult.keyAt(i));
                final View view = mViews.get(autofillId).get();
                final WeakReference<View> viewRef = mViews.get(autofillId);
                if (viewRef == null) {
                    continue;
                }
                final View view = viewRef.get();
                if (view == null) {
                    Log.w(TAG, "onTranslationCompleted: the view for autofill id " + autofillId
                            + " may be gone.");
@@ -416,7 +420,11 @@ public class UiTranslationController {
                    Log.w(TAG, "No AutofillId is set in ViewTranslationResponse");
                    continue;
                }
                final View view = mViews.get(autofillId).get();
                final WeakReference<View> viewRef = mViews.get(autofillId);
                if (viewRef == null) {
                    continue;
                }
                final View view = viewRef.get();
                if (view == null) {
                    Log.w(TAG, "onTranslationCompleted: the view for autofill id " + autofillId
                            + " may be gone.");