Bug Fix: fix NullPointerException while scrolling message apps am: 018e3d97d0 am: dd622014fe

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15605141

Change-Id: I0e1de4f04140c3dde12f13604e05cd21e9598492
This commit is contained in:
Joanne Chung
2021-08-18 15:01:38 +00:00
committed by Automerger Merge Worker

View File

@@ -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.");