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

--HG--
extra : rebase_source : d540c128df51ae0315f9ee05c3fb87cfcf44877a
This commit is contained in:
Jan Henning 2016-10-11 21:00:36 +02:00
Родитель e56a644db8
Коммит be957a257a
1 изменённых файлов: 8 добавлений и 6 удалений

Просмотреть файл

@ -484,30 +484,32 @@ public class CombinedHistoryPanel extends HomeFragment implements RemoteClientsD
}
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);
}
/**