Merge "Fix NPE when coming back to settings homepage." into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-11 11:40:02 +00:00
committed by Android (Google) Code Review

View File

@@ -120,6 +120,11 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
swipeBackground.setVisibility(View.GONE);
}
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)) {
Log.w(TAG, "Slice has HINT_ERROR, skipping rendering. uri=" + slice.getUri());
mSliceLiveDataMap.get(slice.getUri()).removeObservers(mLifecycleOwner);