Remove mIsHalfWidth field from ContextualCard
mIsHalfWidth in ContextualCard is too generic to identify its responsibility, it is used to hold the value of is_support_half from database and used to decide the card width. Also, it limits the relationship of CardType-to-Renderer not to be extended to one-to-many. To deal with this, we replaced mIsHalfWidth with mViewType to implement one-to-many relationship of CardType-to-Renderer, and removed all related logic of mIsHalfWidth. Bug: 121303357 Test: robotests, visual Change-Id: I03e14392272194424f317d11bf9d0d794a6133f4
This commit is contained in:
@@ -33,6 +33,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
import androidx.loader.content.Loader;
|
||||
|
||||
import com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
@@ -236,8 +237,10 @@ public class ContextualCardManager implements ContextualCardLoader.CardContentLo
|
||||
final ContextualCard current = result.get(index);
|
||||
if (current.getCategory() == SUGGESTION_VALUE
|
||||
&& previous.getCategory() == SUGGESTION_VALUE) {
|
||||
result.set(index - 1, previous.mutate().setIsHalfWidth(true).build());
|
||||
result.set(index, current.mutate().setIsHalfWidth(true).build());
|
||||
result.set(index - 1, previous.mutate().setViewType(
|
||||
SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH).build());
|
||||
result.set(index, current.mutate().setViewType(
|
||||
SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH).build());
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user