Add check for empty direct categories

This commit is contained in:
misaochan 2018-03-18 18:51:17 +10:00
parent efa7820fe4
commit 819ec795bd

View file

@ -89,6 +89,7 @@ public class CategorizationFragment extends CommonsDaggerSupportFragment {
private HashMap<String, ArrayList<String>> categoriesCache;
private List<CategoryItem> selectedCategories = new ArrayList<>();
private TitleTextWatcher textWatcher = new TitleTextWatcher();
private boolean hasDirectCategories = false;
private final CategoriesAdapterFactory adapterFactory = new CategoriesAdapterFactory(item -> {
if (item.isSelected()) {
@ -275,11 +276,13 @@ public class CategorizationFragment extends CommonsDaggerSupportFragment {
private Observable<CategoryItem> directCategories() {
String directCategory = directPrefs.getString("Category", "");
List<String> categoryList = new ArrayList<>();
Timber.d("Direct category found: " + directCategory);
List<String> categoryList = new ArrayList<>();
if (!directCategory.equals("")) {
hasDirectCategories = true;
categoryList.add(directCategory);
}
return Observable.fromIterable(categoryList).map(name -> new CategoryItem(name, false));
}