[DO NOT MERGE] Fix the blank space on contextual card loading timeout

Root cause:
Sometimes loading contextual cards exceeds 1 second and a timeout
expires. In the past, we used the timeout in order not to update
homepage UI and to avoid screen scrolling. But we've introduced a
mechanism of card space pre-allocation to avoid flickering, so when the
timeout expires, the pre-allocated space will be always blank.

Solution:
Display a card on timeout if the one-card space is pre-allocated.

Fixes: 165886791
Test: robotest
Change-Id: I79b29c5fd6d9c4fe6b53dd4f5eab4cd3a606d76d
This commit is contained in:
Jason Chiu
2020-09-08 12:17:03 +08:00
parent de28bc7c7e
commit 4753adfb52
2 changed files with 38 additions and 4 deletions

View File

@@ -243,7 +243,7 @@ public class ContextualCardManager implements ContextualCardLoader.CardContentLo
final MetricsFeatureProvider metricsFeatureProvider =
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
//navigate back to the homepage, screen rotate or after card dismissal
// navigate back to the homepage, screen rotate or after card dismissal
if (!mIsFirstLaunch) {
onContextualCardUpdated(cardsToKeep.stream()
.collect(groupingBy(ContextualCard::getCardType)));
@@ -266,8 +266,17 @@ public class ContextualCardManager implements ContextualCardLoader.CardContentLo
SettingsEnums.ACTION_CONTEXTUAL_CARD_LOAD_TIMEOUT,
SettingsEnums.SETTINGS_HOMEPAGE,
null /* key */, (int) loadTime /* value */);
// display a card on timeout if the one-card space is pre-allocated
if (!cards.isEmpty() && ContextualCardLoader.getCardCount(mContext) == 1) {
onContextualCardUpdated(cards.stream()
.collect(groupingBy(ContextualCard::getCardType)));
metricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_CONTEXTUAL_CARD_SHOW,
ContextualCardLogUtils.buildCardListLog(cards));
}
}
//only log homepage display upon a fresh launch
// only log homepage display upon a fresh launch
final long totalTime = System.currentTimeMillis() - mStartTime;
metricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_CONTEXTUAL_HOME_SHOW, (int) totalTime);