diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 90d4d9741..fae97bb7b 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -113,6 +113,7 @@ public class SearchFragment extends BaseListFragment suggestionPublisher = PublishSubject.create(); private Disposable searchDisposable; @@ -160,7 +161,12 @@ public class SearchFragment extends BaseListFragment items = new ArrayList<>(); private final Context context; private OnSuggestionItemSelected listener; + private boolean showSugestinHistory = true; public interface OnSuggestionItemSelected { void onSuggestionItemSelected(SuggestionItem item); @@ -31,7 +32,16 @@ public class SuggestionListAdapter extends RecyclerView.Adapter items) { this.items.clear(); - this.items.addAll(items); + if (showSugestinHistory) { + this.items.addAll(items); + } else { + // remove history items if history is disabled + for (SuggestionItem item : items) { + if (!item.fromHistory) { + this.items.add(item); + } + } + } notifyDataSetChanged(); } @@ -39,6 +49,10 @@ public class SuggestionListAdapter extends RecyclerView.Adapter