mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43: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(
|
.concatWith(
|
||||||
searchAll(filter)
|
searchAll(filter)
|
||||||
.mergeWith(searchCategories(filter))
|
.mergeWith(searchCategories(filter))
|
||||||
.filter(categoryItem -> !selectedCategories.contains(categoryItem))
|
.concatWith( TextUtils.isEmpty(filter)
|
||||||
.switchIfEmpty(
|
? defaultCategories() : Observable.empty())
|
||||||
gpsCategories()
|
|
||||||
.concatWith(titleCategories())
|
|
||||||
.concatWith(recentCategories())
|
|
||||||
.filter(categoryItem -> !selectedCategories.contains(categoryItem))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.filter(categoryItem -> !containsYear(categoryItem.getName()))
|
.filter(categoryItem -> !containsYear(categoryItem.getName()))
|
||||||
|
.distinct()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
s -> categoriesAdapter.add(s),
|
s -> categoriesAdapter.add(s),
|
||||||
|
|
@ -211,11 +207,13 @@ public class CategorizationFragment extends Fragment {
|
||||||
categoriesAdapter.notifyDataSetChanged();
|
categoriesAdapter.notifyDataSetChanged();
|
||||||
categoriesSearchInProgress.setVisibility(View.GONE);
|
categoriesSearchInProgress.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (categoriesAdapter.getItemCount() == 0) {
|
if (categoriesAdapter.getItemCount() == selectedCategories.size()) {
|
||||||
|
// There are no suggestions
|
||||||
if (TextUtils.isEmpty(filter)) {
|
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);
|
categoriesSkip.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
// Inform the user that the searched term matches no category
|
||||||
categoriesNotFoundView.setText(getString(R.string.categories_not_found, filter));
|
categoriesNotFoundView.setText(getString(R.string.categories_not_found, filter));
|
||||||
categoriesNotFoundView.setVisibility(View.VISIBLE);
|
categoriesNotFoundView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
@ -232,6 +230,12 @@ public class CategorizationFragment extends Fragment {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Observable<CategoryItem> defaultCategories() {
|
||||||
|
return gpsCategories()
|
||||||
|
.concatWith(titleCategories())
|
||||||
|
.concatWith(recentCategories());
|
||||||
|
}
|
||||||
|
|
||||||
private Observable<CategoryItem> gpsCategories() {
|
private Observable<CategoryItem> gpsCategories() {
|
||||||
return Observable.fromIterable(
|
return Observable.fromIterable(
|
||||||
MwVolleyApi.GpsCatExists.getGpsCatExists()
|
MwVolleyApi.GpsCatExists.getGpsCatExists()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue