[DO NOT MERGE] Pre-allocate height for contextual cards. am: 228bc78bf9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/12343231 Change-Id: Iefb77041715dba0cc2a19210e1353f935e25a8a8
This commit is contained in:
@@ -50,7 +50,7 @@ import java.util.stream.Collectors;
|
||||
public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>> {
|
||||
|
||||
@VisibleForTesting
|
||||
static final int DEFAULT_CARD_COUNT = 3;
|
||||
static final int DEFAULT_CARD_COUNT = 1;
|
||||
@VisibleForTesting
|
||||
static final String CONTEXTUAL_CARD_COUNT = "contextual_card_count";
|
||||
static final int CARD_CONTENT_LOADER_ID = 1;
|
||||
@@ -131,7 +131,7 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
final List<ContextualCard> visibleCards = new ArrayList<>();
|
||||
final List<ContextualCard> hiddenCards = new ArrayList<>();
|
||||
|
||||
final int maxCardCount = getCardCount();
|
||||
final int maxCardCount = getCardCount(mContext);
|
||||
eligibleCards.forEach(card -> {
|
||||
if (card.getCategory() != STICKY_VALUE) {
|
||||
return;
|
||||
@@ -177,11 +177,10 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
return visibleCards;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getCardCount() {
|
||||
static int getCardCount(Context context) {
|
||||
// Return the card count if Settings.Global has KEY_CONTEXTUAL_CARD_COUNT key,
|
||||
// otherwise return the default one.
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
return Settings.Global.getInt(context.getContentResolver(),
|
||||
CONTEXTUAL_CARD_COUNT, DEFAULT_CARD_COUNT);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user