Bug 1395792 - Destroy loaders on reload. r=mcomella
authorChenxia Liu <liuche@mozilla.com>
Mon, 18 Sep 2017 20:17:25 -0700
changeset 431586 ed817e1a17ba8a2f66c955a6b5bf252d7e8e8985
parent 431585 b5b59c79c04d99502da95c90b39ea32186ef2432
child 431587 072a236f67fe85171955a001ef3ee12fb830365f
push id7785
push userryanvm@gmail.com
push dateThu, 21 Sep 2017 13:39:55 +0000
treeherdermozilla-beta@06d4034a8a03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1395792
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1395792 - Destroy loaders on reload. r=mcomella MozReview-Commit-ID: GccHdTISpky
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/ActivityStreamPanel.java
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/ActivityStreamPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/ActivityStreamPanel.java
@@ -110,16 +110,21 @@ public class ActivityStreamPanel extends
     public void unload() {
         adapter.swapHighlights(Collections.<Highlight>emptyList());
 
         adapter.swapTopSitesCursor(null);
     }
 
     public void reload(LoaderManager lm) {
         adapter.clearAndInit();
+
+        // Destroy loaders so they don't restart loading when returning.
+        lm.destroyLoader(LOADER_ID_HIGHLIGHTS);
+        lm.destroyLoader(LOADER_ID_POCKET);
+
         load(lm);
     }
 
     @Override
     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
         super.onSizeChanged(w, h, oldw, oldh);
 
         // This code does two things:
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
@@ -1,15 +1,16 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.activitystream.homepanel;
 
+import android.content.Context;
 import android.content.SharedPreferences;
 import android.database.Cursor;
 import android.support.annotation.NonNull;
 import android.support.v7.widget.RecyclerView;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -176,22 +177,27 @@ public class StreamRecyclerAdapter exten
             final Highlight highlight = (Highlight) recyclerViewModel.get(position);
             ((WebpageItemRow) holder).bind(highlight, position, tilesSize);
         } else if (type == RowItemType.TOP_PANEL.getViewType()) {
             ((TopPanelRow) holder).bind(topSitesCursor, tilesSize);
         } else if (type == RowItemType.TOP_STORIES_ITEM.getViewType()) {
             final TopStory story = (TopStory) recyclerViewModel.get(position);
             ((WebpageItemRow) holder).bind(story, position, tilesSize);
         } else if (type == RowItemType.HIGHLIGHTS_TITLE.getViewType()) {
-            final SharedPreferences sharedPreferences = GeckoSharedPrefs.forProfile(holder.itemView.getContext());
-            final boolean bookmarksEnabled = sharedPreferences.getBoolean(ActivityStreamPanel.PREF_BOOKMARKS_ENABLED, true);
-            final boolean visitedEnabled = sharedPreferences.getBoolean(ActivityStreamPanel.PREF_VISITED_ENABLED, true);
+            final Context context = holder.itemView.getContext();
+            final SharedPreferences sharedPreferences = GeckoSharedPrefs.forProfile(context);
+            final boolean bookmarksEnabled = sharedPreferences.getBoolean(ActivityStreamPanel.PREF_BOOKMARKS_ENABLED,
+                    context.getResources().getBoolean(R.bool.pref_activitystream_recentbookmarks_enabled_default));
+            final boolean visitedEnabled = sharedPreferences.getBoolean(ActivityStreamPanel.PREF_VISITED_ENABLED,
+                    context.getResources().getBoolean(R.bool.pref_activitystream_visited_enabled_default));
             ((StreamTitleRow) holder).setVisible(bookmarksEnabled || visitedEnabled);
         } else if (type == RowItemType.TOP_STORIES_TITLE.getViewType()) {
-            final boolean pocketEnabled = GeckoSharedPrefs.forProfile(holder.itemView.getContext()).getBoolean(ActivityStreamPanel.PREF_POCKET_ENABLED, true);
+            final Context context = holder.itemView.getContext();
+            final boolean pocketEnabled = GeckoSharedPrefs.forProfile(context).getBoolean(ActivityStreamPanel.PREF_POCKET_ENABLED,
+                    context.getResources().getBoolean(R.bool.pref_activitystream_pocket_enabled_default));
             ((StreamTitleRow) holder).setVisible(pocketEnabled);
         }
     }
 
     @Override
     public void onItemClicked(RecyclerView recyclerView, int position, View v) {
         if (!onItemClickIsValidRowItem(position)) {
             return;