Merge "Fix NPE when coming back to settings homepage." into rvc-dev am: 21338186d5 am: f3aa88ccf2

Change-Id: I1e6b3b26aa19fffc081123ff6eb000a3475866c7
This commit is contained in:
Automerger Merge Worker
2020-03-11 11:50:59 +00:00

View File

@@ -120,6 +120,11 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
swipeBackground.setVisibility(View.GONE); swipeBackground.setVisibility(View.GONE);
} }
sliceLiveData.observe(mLifecycleOwner, slice -> { sliceLiveData.observe(mLifecycleOwner, slice -> {
if (slice == null) {
// The logic handling this case is in OnErrorListener. Adding this check is to
// prevent from NPE when it calls .hasHint().
return;
}
if (slice.hasHint(HINT_ERROR)) { if (slice.hasHint(HINT_ERROR)) {
Log.w(TAG, "Slice has HINT_ERROR, skipping rendering. uri=" + slice.getUri()); Log.w(TAG, "Slice has HINT_ERROR, skipping rendering. uri=" + slice.getUri());
mSliceLiveDataMap.get(slice.getUri()).removeObservers(mLifecycleOwner); mSliceLiveDataMap.get(slice.getUri()).removeObservers(mLifecycleOwner);