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
--- 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