Bug 1261527 - Handle Configuration changes. r=sebastian
authorChenxia Liu <liuche@mozilla.com>
Mon, 25 Apr 2016 13:56:12 -0700
changeset 362657 5b048886e0c9ad7938cd2a6da6dd4b95bb4a9bec
parent 362656 0003c0e701e62018604dd7566e6cb5a08515541b
child 362658 af4e12a26b8231acc482d4ca32dffb63b04d7cda
push id17008
push userbgrinstead@mozilla.com
push dateMon, 02 May 2016 21:59:43 +0000
reviewerssebastian
bugs1261527
milestone49.0a1
Bug 1261527 - Handle Configuration changes. r=sebastian MozReview-Commit-ID: H6shTUlXkZv
mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.home;
 
 import android.app.AlertDialog;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
-import android.content.res.Configuration;
 import android.database.Cursor;
 import android.os.Bundle;
 import android.support.v4.app.LoaderManager;
 import android.support.v4.content.Loader;
 import android.support.v7.widget.DefaultItemAnimator;
 import android.text.SpannableStringBuilder;
 import android.text.TextPaint;
 import android.text.method.LinkMovementMethod;
@@ -62,17 +61,17 @@ public class CombinedHistoryPanel extend
     // Number of smart folders for determining practical empty state.
     public static final int NUM_SMART_FOLDERS = 1;
 
     private CombinedHistoryRecyclerView mRecyclerView;
     private CombinedHistoryAdapter mHistoryAdapter;
     private ClientsAdapter mClientsAdapter;
     private CursorLoaderCallbacks mCursorLoaderCallbacks;
 
-    private OnPanelLevelChangeListener.PanelLevel mPanelLevel = OnPanelLevelChangeListener.PanelLevel.PARENT;
+    private OnPanelLevelChangeListener.PanelLevel mPanelLevel;
     private Button mPanelFooterButton;
 
     // Reference to the View to display when there are no results.
     private View mEmptyView;
 
     public interface OnPanelLevelChangeListener {
         enum PanelLevel {
         PARENT, CHILD
@@ -106,38 +105,37 @@ public class CombinedHistoryPanel extend
         mRecyclerView = (CombinedHistoryRecyclerView) view.findViewById(R.id.combined_recycler_view);
         setUpRecyclerView();
 
         mPanelFooterButton = (Button) view.findViewById(R.id.clear_history_button);
         mPanelFooterButton.setOnClickListener(new OnFooterButtonClickListener());
     }
 
     private void setUpRecyclerView() {
-        mRecyclerView.setAdapter(mHistoryAdapter);
+        if (mPanelLevel == null) {
+            mPanelLevel = OnPanelLevelChangeListener.PanelLevel.PARENT;
+        }
+
+        mRecyclerView.setAdapter(mPanelLevel == OnPanelLevelChangeListener.PanelLevel.PARENT ? mHistoryAdapter : mClientsAdapter);
 
         mRecyclerView.setItemAnimator(new DefaultItemAnimator());
         mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext()));
         mRecyclerView.setOnHistoryClickedListener(mUrlOpenListener);
         mRecyclerView.setOnPanelLevelChangeListener(new OnLevelChangeListener());
         mRecyclerView.setHiddenClientsDialogBuilder(new HiddenClientsHelper());
         registerForContextMenu(mRecyclerView);
     }
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
         mCursorLoaderCallbacks = new CursorLoaderCallbacks();
     }
 
     @Override
-    public void onConfigurationChanged(Configuration newConfig) {
-        super.onConfigurationChanged(newConfig);
-    }
-
-    @Override
     protected void load() {
         getLoaderManager().initLoader(LOADER_ID_HISTORY, null, mCursorLoaderCallbacks);
         getLoaderManager().initLoader(LOADER_ID_REMOTE, null, mCursorLoaderCallbacks);
     }
 
     private static class RemoteTabsCursorLoader extends SimpleCursorLoader {
         private final GeckoProfile mProfile;