Add null check before setting the visibility of swipe background
Some contextual cards does not allow card dismissal, so they won't have swipe background declared in the layout file. Add null check to prevent from NPE. Fixes: 132209310 Test: robotests & launch Settings Change-Id: I31f897f445c4901d007c8187fe69aea416b915d1
This commit is contained in:
@@ -112,8 +112,10 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
|
||||
|
||||
final View swipeBackground = holder.itemView.findViewById(R.id.dismissal_swipe_background);
|
||||
sliceLiveData.removeObservers(mLifecycleOwner);
|
||||
// set the background to Gone in case the holder is reused.
|
||||
swipeBackground.setVisibility(View.GONE);
|
||||
// set the background to GONE in case the holder is reused.
|
||||
if (swipeBackground != null) {
|
||||
swipeBackground.setVisibility(View.GONE);
|
||||
}
|
||||
sliceLiveData.observe(mLifecycleOwner, slice -> {
|
||||
if (slice == null) {
|
||||
Log.w(TAG, "Slice is null");
|
||||
@@ -140,8 +142,9 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
|
||||
default:
|
||||
mFullCardHelper.bindView(holder, card, slice);
|
||||
}
|
||||
|
||||
swipeBackground.setVisibility(View.VISIBLE);
|
||||
if (swipeBackground != null) {
|
||||
swipeBackground.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
switch (holder.getItemViewType()) {
|
||||
|
Reference in New Issue
Block a user