mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Fix empty-filter search. Fix repeated suggestions issue. Show "no results found" when appropriate
This commit is contained in:
parent
ef1fc0c9d9
commit
3793516d57
1 changed files with 13 additions and 9 deletions
|
|
@ -194,15 +194,11 @@ public class CategorizationFragment extends Fragment {
|
|||
.concatWith(
|
||||
searchAll(filter)
|
||||
.mergeWith(searchCategories(filter))
|
||||
.filter(categoryItem -> !selectedCategories.contains(categoryItem))
|
||||
.switchIfEmpty(
|
||||
gpsCategories()
|
||||
.concatWith(titleCategories())
|
||||
.concatWith(recentCategories())
|
||||
.filter(categoryItem -> !selectedCategories.contains(categoryItem))
|
||||
)
|
||||
.concatWith( TextUtils.isEmpty(filter)
|
||||
? defaultCategories() : Observable.empty())
|
||||
)
|
||||
.filter(categoryItem -> !containsYear(categoryItem.getName()))
|
||||
.distinct()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
s -> categoriesAdapter.add(s),
|
||||
|
|
@ -211,11 +207,13 @@ public class CategorizationFragment extends Fragment {
|
|||
categoriesAdapter.notifyDataSetChanged();
|
||||
categoriesSearchInProgress.setVisibility(View.GONE);
|
||||
|
||||
if (categoriesAdapter.getItemCount() == 0) {
|
||||
if (categoriesAdapter.getItemCount() == selectedCategories.size()) {
|
||||
// There are no suggestions
|
||||
if (TextUtils.isEmpty(filter)) {
|
||||
// If we found no recent cats, show the skip message!
|
||||
// Allow to send image with no categories
|
||||
categoriesSkip.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
// Inform the user that the searched term matches no category
|
||||
categoriesNotFoundView.setText(getString(R.string.categories_not_found, filter));
|
||||
categoriesNotFoundView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
|
@ -232,6 +230,12 @@ public class CategorizationFragment extends Fragment {
|
|||
return output;
|
||||
}
|
||||
|
||||
private Observable<CategoryItem> defaultCategories() {
|
||||
return gpsCategories()
|
||||
.concatWith(titleCategories())
|
||||
.concatWith(recentCategories());
|
||||
}
|
||||
|
||||
private Observable<CategoryItem> gpsCategories() {
|
||||
return Observable.fromIterable(
|
||||
MwVolleyApi.GpsCatExists.getGpsCatExists()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue