Update updateEmptyView

Also consider the visiblity of list container, when list container
is invisible, we should show the empty view.

Bug: 62062415
Test: RunSettingsRoboTests
Change-Id: I065e70386242c425ef3cbfb2b703a5433dbe40c1
This commit is contained in:
jackqdyulei
2017-05-26 10:47:55 -07:00
parent de01ab40a5
commit 2b2abac714
2 changed files with 47 additions and 4 deletions

View File

@@ -312,12 +312,15 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
}
}
private void updateEmptyView() {
@VisibleForTesting
void updateEmptyView() {
if (mEmptyView == null) return;
if (getPreferenceScreen() != null) {
final View listContainer = getActivity().findViewById(android.R.id.list_container);
boolean show = (getPreferenceScreen().getPreferenceCount()
- (mHeader != null ? 1 : 0)
- (mFooterPreferenceMixin.hasFooter() ? 1 : 0)) <= 0;
- (mFooterPreferenceMixin.hasFooter() ? 1 : 0)) <= 0
|| (listContainer != null && listContainer.getVisibility() != View.VISIBLE);
mEmptyView.setVisibility(show ? View.VISIBLE : View.GONE);
} else {
mEmptyView.setVisibility(View.VISIBLE);