Show appropriate empty state if not printers are found.

One can search for printers in the print service settings
and we need to show appropriate empty state if none is found.

bug:11009053

Change-Id: If3ed6aa3a5e2eb4d7f7bae37f885e4b8eb0909b4
This commit is contained in:
Svetoslav
2013-09-30 16:22:29 -07:00
parent 768dc8f729
commit 9a2ace9587
3 changed files with 25 additions and 4 deletions

View File

@@ -95,6 +95,7 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
@Override
public void onChanged() {
invalidateOptionsMenuIfNeeded();
updateEmptyView();
}
@Override
@@ -227,14 +228,15 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
ViewGroup contentRoot = (ViewGroup) listView.getParent();
View emptyView = listView.getEmptyView();
if (!mToggleSwitch.isChecked()) {
if (emptyView != null
&& emptyView.getId() != R.id.empty_printers_list_service_disabled) {
if (emptyView != null && emptyView.getId() != R.id.empty_print_state) {
contentRoot.removeView(emptyView);
emptyView = null;
}
if (emptyView == null) {
emptyView = getActivity().getLayoutInflater().inflate(
R.layout.empty_print_state, contentRoot, false);
ImageView iconView = (ImageView) emptyView.findViewById(R.id.icon);
iconView.setContentDescription(getString(R.string.print_service_disabled));
TextView textView = (TextView) emptyView.findViewById(R.id.message);
textView.setText(R.string.print_service_disabled);
contentRoot.addView(emptyView);
@@ -252,6 +254,21 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
contentRoot.addView(emptyView);
listView.setEmptyView(emptyView);
}
} else if (mPrintersAdapter.getCount() <= 0) {
if (emptyView != null && emptyView.getId() != R.id.empty_print_state) {
contentRoot.removeView(emptyView);
emptyView = null;
}
if (emptyView == null) {
emptyView = getActivity().getLayoutInflater().inflate(
R.layout.empty_print_state, contentRoot, false);
ImageView iconView = (ImageView) emptyView.findViewById(R.id.icon);
iconView.setContentDescription(getString(R.string.print_no_printers_found));
TextView textView = (TextView) emptyView.findViewById(R.id.message);
textView.setText(R.string.print_no_printers_found);
contentRoot.addView(emptyView);
listView.setEmptyView(emptyView);
}
}
}