Reload data if slice binding returns null at rendering time.
We are not able to guarantee the binding results in the pre-check and real binding would always be the same sinc slice may decide what it would be based on some conditions. Hence, we should reload data and refresh UI when it comes to null to prevent from blank suggestion. Bug: 120221527 Test: visual Change-Id: I79790edfe7fc3af7b9c3b3a7df6a7ffa7d405d50
This commit is contained in:
@@ -41,6 +41,7 @@ import androidx.slice.widget.SliceLiveData;
|
||||
import androidx.slice.widget.SliceView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.homepage.contextualcards.CardContentProvider;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCard;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCardRenderer;
|
||||
@@ -94,6 +95,8 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer,
|
||||
public void bindView(RecyclerView.ViewHolder holder, ContextualCard card) {
|
||||
final SliceViewHolder cardHolder = (SliceViewHolder) holder;
|
||||
final Uri uri = card.getSliceUri();
|
||||
//TODO(b/120629936): Take this out once blank card issue is fixed.
|
||||
Log.d(TAG, "bindView - uri = " + uri);
|
||||
|
||||
if (!ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
|
||||
Log.w(TAG, "Invalid uri, skipping slice: " + uri);
|
||||
@@ -116,6 +119,11 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer,
|
||||
sliceLiveData.observe(mLifecycleOwner, slice -> {
|
||||
if (slice == null) {
|
||||
Log.w(TAG, "Slice is null");
|
||||
mContext.getContentResolver().notifyChange(CardContentProvider.URI, null);
|
||||
return;
|
||||
} else {
|
||||
//TODO(b/120629936): Take this out once blank card issue is fixed.
|
||||
Log.d(TAG, "Slice callback - uri = " + slice.getUri());
|
||||
}
|
||||
cardHolder.sliceView.setSlice(slice);
|
||||
});
|
||||
|
Reference in New Issue
Block a user