OSDN Git Service

Do not trigger card loader reloading upon screen rotation.
authorYi-Ling Chuang <emilychuang@google.com>
Wed, 20 Feb 2019 12:00:26 +0000 (20:00 +0800)
committerYi-Ling Chuang <emilychuang@google.com>
Sat, 23 Feb 2019 03:35:28 +0000 (11:35 +0800)
Use the cached loaded results when it is not the first launch.

Fixes: 123941365
Test: robotests
Change-Id: Ib6de1142b12196e997a8c19122617e9215d23655

src/com/android/settings/homepage/contextualcards/ContextualCardManager.java

index 344c248..3b8aacd 100644 (file)
@@ -108,7 +108,8 @@ public class ContextualCardManager implements ContextualCardLoader.CardContentLo
         final CardContentLoaderCallbacks cardContentLoaderCallbacks =
                 new CardContentLoaderCallbacks(mContext);
         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);
     }
 
@@ -192,7 +193,7 @@ public class ContextualCardManager implements ContextualCardLoader.CardContentLo
         Log.d(TAG, "Total loading time = " + loadTime);
         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) {
             onContextualCardUpdated(cardsToKeep.stream()
                     .collect(groupingBy(ContextualCard::getCardType)));