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

Commit a591d7a0 authored by Yi-Ling Chuang's avatar Yi-Ling Chuang
Browse files

Fix NPE when coming back to settings homepage.

When users navigate back to the homepage, if there is a slice being
displayed, slice callback will be triggered. It will then check if this
slice has any error hint, where NPE would occur if the slice turns out
to be null. Hence, add a null check before checking slice hint.

Fixes: 148158780
Test: rebuild and navigate back to the homepage.
Change-Id: I2b04dc0d64a223cc85f6af55b2ae2dbc5f3e1f40
parent b8fb854e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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);