Bug 1308946 - Part 1 - Ensure that empty views not matching the current panel level are hidden. r=liuche draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Tue, 11 Oct 2016 21:00:36 +0200
changeset 423855 d540c128df51ae0315f9ee05c3fb87cfcf44877a
parent 423853 81de12d6c4c0f06353bb65620ba3d330e91b2966
child 533541 22ac6cb2d5f4fab5bccc5a33da5a64309281b389
push id32007
push usermozilla@buttercookie.de
push dateTue, 11 Oct 2016 19:17:18 +0000
reviewersliuche
bugs1308946
milestone52.0a1
Bug 1308946 - Part 1 - Ensure that empty views not matching the current panel level are hidden. r=liuche Setting an empty view's visibility only for the view corresponding to the current PanelLevel was intended to make sure the empty view doesn't get hidden because of an unrelated status update - e.g. to prevent the history empty view hiding itself because the recent tabs count changes. This approach however doesn't work for switching between panel levels (the user moving into and out of the sync/recent tabs folders) - in that case we always need to turn off the empty view of the previous panel level, which is not possible with the above approach. So instead, we revert to always updating the visibility of the empty views, but at the same time initialise the desired state of current PanelLevel's empty view with its current visibility instead of simply defaulting to false. MozReview-Commit-ID: 6Xsnuo29srk
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
@@ -479,40 +479,42 @@ public class CombinedHistoryPanel extend
                         Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.BUTTON, telemetryExtra);
                     }
                     break;
             }
         }
     }
 
     private void updateEmptyView(PanelLevel level) {
-        boolean showEmptyHistoryView = false;
-        boolean showEmptyClientsView = false;
-        boolean showEmptyRecentTabsView = false;
+        boolean showEmptyHistoryView = (mPanelLevel == PARENT && mHistoryEmptyView.isShown());
+        boolean showEmptyClientsView = (mPanelLevel == CHILD_SYNC && mClientsEmptyView.isShown());
+        boolean showEmptyRecentTabsView = (mPanelLevel == CHILD_RECENT_TABS && mRecentTabsEmptyView.isShown());
+
         if (mPanelLevel == level) {
             switch (mPanelLevel) {
                 case PARENT:
                     showEmptyHistoryView = mHistoryAdapter.getItemCount() == mHistoryAdapter.getNumVisibleSmartFolders();
-                    mHistoryEmptyView.setVisibility(showEmptyHistoryView ? View.VISIBLE : View.GONE);
                     break;
 
                 case CHILD_SYNC:
                     showEmptyClientsView = mClientsAdapter.getItemCount() == 1;
-                    mClientsEmptyView.setVisibility(showEmptyClientsView ? View.VISIBLE : View.GONE);
                     break;
 
                 case CHILD_RECENT_TABS:
                     showEmptyRecentTabsView = mRecentTabsAdapter.getClosedTabsCount() == 0;
-                    mRecentTabsEmptyView.setVisibility(showEmptyRecentTabsView ? View.VISIBLE : View.GONE);
                     break;
             }
         }
 
         final boolean showEmptyView = showEmptyClientsView || showEmptyHistoryView || showEmptyRecentTabsView;
         mRecyclerView.setOverScrollMode(showEmptyView ? View.OVER_SCROLL_NEVER : View.OVER_SCROLL_IF_CONTENT_SCROLLS);
+
+        mHistoryEmptyView.setVisibility(showEmptyHistoryView ? View.VISIBLE : View.GONE);
+        mClientsEmptyView.setVisibility(showEmptyClientsView ? View.VISIBLE : View.GONE);
+        mRecentTabsEmptyView.setVisibility(showEmptyRecentTabsView ? View.VISIBLE : View.GONE);
     }
 
     /**
      * Make Span that is clickable, and underlined
      * between the string markers <code>FORMAT_S1</code> and
      * <code>FORMAT_S2</code>.
      *
      * @param text String to format