Do not trigger card loader reloading upon screen rotation.
Use the cached loaded results when it is not the first launch. Fixes: 123941365 Test: robotests Change-Id: Ib6de1142b12196e997a8c19122617e9215d23655
This commit is contained in:
@@ -108,7 +108,8 @@ public class ContextualCardManager implements ContextualCardLoader.CardContentLo
|
|||||||
final CardContentLoaderCallbacks cardContentLoaderCallbacks =
|
final CardContentLoaderCallbacks cardContentLoaderCallbacks =
|
||||||
new CardContentLoaderCallbacks(mContext);
|
new CardContentLoaderCallbacks(mContext);
|
||||||
cardContentLoaderCallbacks.setListener(this);
|
cardContentLoaderCallbacks.setListener(this);
|
||||||
LoaderManager.getInstance(fragment).restartLoader(CARD_CONTENT_LOADER_ID, null /* bundle */,
|
// Use the cached data when navigating back to the first page and upon screen rotation.
|
||||||
|
LoaderManager.getInstance(fragment).initLoader(CARD_CONTENT_LOADER_ID, null /* bundle */,
|
||||||
cardContentLoaderCallbacks);
|
cardContentLoaderCallbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +193,7 @@ public class ContextualCardManager implements ContextualCardLoader.CardContentLo
|
|||||||
Log.d(TAG, "Total loading time = " + loadTime);
|
Log.d(TAG, "Total loading time = " + loadTime);
|
||||||
final List<ContextualCard> cardsToKeep = getCardsToKeep(cards);
|
final List<ContextualCard> cardsToKeep = getCardsToKeep(cards);
|
||||||
|
|
||||||
//navigate back to the homepage or after card dismissal
|
//navigate back to the homepage, screen rotate or after card dismissal
|
||||||
if (!mIsFirstLaunch) {
|
if (!mIsFirstLaunch) {
|
||||||
onContextualCardUpdated(cardsToKeep.stream()
|
onContextualCardUpdated(cardsToKeep.stream()
|
||||||
.collect(groupingBy(ContextualCard::getCardType)));
|
.collect(groupingBy(ContextualCard::getCardType)));
|
||||||
|
Reference in New Issue
Block a user