[DO NOT MERGE] Pre-allocate height for contextual cards.
To prevent the UI jank causing by the async card loads, we pre-allocate some space for the card to fill in. After this change, only one card can be shown at a time. More details: - When the card number configuration is set to 0, don't trigger the card loader. - The height adjusting logic is as follows. When Settings is opened, pre-allocate a space first. After the RV finish laying out, reset the RV to wrap_content. So if the card has to be expanded(eg. wifi large mode or dismissal view), then it will adjust the height accordingly. While if a card previously shown becomes unavailable(dismissed or conditions not meet), we also reset the RV so the space can be gone. Bug: 163288869 Test: robotest Change-Id: I0dcb2dae8f0533e562ad06f664b7ae7a9afecd21
This commit is contained in:
@@ -71,25 +71,25 @@ public class ContextualCardLoaderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDisplayableCards_twoEligibleCards_shouldShowAll() {
|
||||
public void getDisplayableCards_twoEligibleCards_notExceedDefaultCardCount() {
|
||||
final List<ContextualCard> cards = getContextualCardList().stream().limit(2)
|
||||
.collect(Collectors.toList());
|
||||
doReturn(cards).when(mContextualCardLoader).filterEligibleCards(anyList());
|
||||
|
||||
final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
|
||||
|
||||
assertThat(result).hasSize(cards.size());
|
||||
assertThat(result).hasSize(Math.min(cards.size(), DEFAULT_CARD_COUNT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDisplayableCards_fourEligibleCards_shouldShowDefaultCardCount() {
|
||||
public void getDisplayableCards_fourEligibleCards_notExceedDefaultCardCount() {
|
||||
final List<ContextualCard> cards = getContextualCardList().stream().limit(4)
|
||||
.collect(Collectors.toList());
|
||||
doReturn(cards).when(mContextualCardLoader).filterEligibleCards(anyList());
|
||||
|
||||
final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
|
||||
|
||||
assertThat(result).hasSize(DEFAULT_CARD_COUNT);
|
||||
assertThat(result).hasSize(Math.min(cards.size(), DEFAULT_CARD_COUNT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,7 +139,7 @@ public class ContextualCardLoaderTest {
|
||||
|
||||
@Test
|
||||
public void getCardCount_noConfiguredCardCount_returnDefaultCardCount() {
|
||||
assertThat(mContextualCardLoader.getCardCount()).isEqualTo(DEFAULT_CARD_COUNT);
|
||||
assertThat(mContextualCardLoader.getCardCount(mContext)).isEqualTo(DEFAULT_CARD_COUNT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,7 +148,7 @@ public class ContextualCardLoaderTest {
|
||||
Settings.Global.putLong(mContext.getContentResolver(),
|
||||
ContextualCardLoader.CONTEXTUAL_CARD_COUNT, configCount);
|
||||
|
||||
assertThat(mContextualCardLoader.getCardCount()).isEqualTo(configCount);
|
||||
assertThat(mContextualCardLoader.getCardCount(mContext)).isEqualTo(configCount);
|
||||
}
|
||||
|
||||
private List<ContextualCard> getContextualCardList() {
|
||||
|
Reference in New Issue
Block a user