Bug 1288127 - load() History/Bookmarks during onResume() to ensure data is loaded r?sebastian
HomePager has a complex story behind it. For normal ViewPager usage however (i.e. for the
ASDetailActivity) we want to just load data when the fragment is shown.
MozReview-Commit-ID: DUuHKbYdpXj
--- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
@@ -36,16 +36,17 @@ import android.widget.ImageView;
import android.widget.TextView;
import org.json.JSONException;
import org.json.JSONObject;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoProfile;
import org.mozilla.gecko.R;
import org.mozilla.gecko.RemoteClientsDialogFragment;
+import org.mozilla.gecko.activitystream.ActivityStream;
import org.mozilla.gecko.fxa.FirefoxAccounts;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.SyncStatusListener;
import org.mozilla.gecko.home.CombinedHistoryPanel.OnPanelLevelChangeListener.PanelLevel;
import org.mozilla.gecko.restrictions.Restrictions;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.db.BrowserDB;
@@ -273,16 +274,35 @@ public class CombinedHistoryPanel extend
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mCursorLoaderCallbacks = new CursorLoaderCallbacks();
}
@Override
+ public void onResume() {
+ super.onResume();
+
+ // This is hacky, but the simplest way of reusing this panel for AS. HomePager and its
+ // HomeFragments have a complicated initialisation story (the Fragments seem to be kept
+ // alive throughout runtime, and are told to load/unload themselves - i.e. to enable/disable
+ // their loaders - when the HomePager appears/disappears).
+ // For AS we're reusing this panel in a separate activity, we really don't want to have
+ // to worry about the complex initialisation.
+ // There doesn't seem to be a good way of calling load() within the ASDetailActivity,
+ // since it can only be called once the fragment is being made visible. onResume
+ // seems to be the most logical location independent of other concerns, it seems to be cleanest
+ // to therefore just make this AS specific code within the panel.
+ if (ActivityStream.isEnabled(getContext())) {
+ load();
+ }
+ }
+
+ @Override
protected void load() {
getLoaderManager().initLoader(LOADER_ID_HISTORY, null, mCursorLoaderCallbacks);
if (!mBookmarksMode) {
getLoaderManager().initLoader(LOADER_ID_REMOTE, null, mCursorLoaderCallbacks);
}
}
private static class RemoteTabsCursorLoader extends SimpleCursorLoader {