|
|
@ -210,8 +210,8 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable { |
|
|
|
subscriber.onComplete(); |
|
|
|
subscriber.onComplete(); |
|
|
|
} |
|
|
|
} |
|
|
|
}).subscribeOn(FILTER_SCHEDULER) |
|
|
|
}).subscribeOn(FILTER_SCHEDULER) |
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
.subscribe(); |
|
|
|
.subscribe(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void combineResults(final @Nullable List<HistoryItem> bookmarkList, |
|
|
|
private void combineResults(final @Nullable List<HistoryItem> bookmarkList, |
|
|
@ -256,13 +256,13 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable { |
|
|
|
subscriber.onComplete(); |
|
|
|
subscriber.onComplete(); |
|
|
|
} |
|
|
|
} |
|
|
|
}).subscribeOn(FILTER_SCHEDULER) |
|
|
|
}).subscribeOn(FILTER_SCHEDULER) |
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
.subscribe(new SingleOnSubscribe<List<HistoryItem>>() { |
|
|
|
.subscribe(new SingleOnSubscribe<List<HistoryItem>>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onItem(@Nullable List<HistoryItem> item) { |
|
|
|
public void onItem(@Nullable List<HistoryItem> item) { |
|
|
|
publishResults(item); |
|
|
|
publishResults(item); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
@NonNull |
|
|
@ -277,7 +277,7 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (mAllBookmarks.get(n).getTitle().toLowerCase(Locale.getDefault()) |
|
|
|
if (mAllBookmarks.get(n).getTitle().toLowerCase(Locale.getDefault()) |
|
|
|
.startsWith(query)) { |
|
|
|
.startsWith(query)) { |
|
|
|
bookmarks.add(mAllBookmarks.get(n)); |
|
|
|
bookmarks.add(mAllBookmarks.get(n)); |
|
|
|
counter++; |
|
|
|
counter++; |
|
|
|
} else if (mAllBookmarks.get(n).getUrl().contains(query)) { |
|
|
|
} else if (mAllBookmarks.get(n).getUrl().contains(query)) { |
|
|
@ -294,9 +294,9 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable { |
|
|
|
@NonNull |
|
|
|
@NonNull |
|
|
|
private Single<List<HistoryItem>> getSuggestionsForQuery(@NonNull final String query) { |
|
|
|
private Single<List<HistoryItem>> getSuggestionsForQuery(@NonNull final String query) { |
|
|
|
if (mSuggestionChoice == PreferenceManager.Suggestion.SUGGESTION_GOOGLE) { |
|
|
|
if (mSuggestionChoice == PreferenceManager.Suggestion.SUGGESTION_GOOGLE) { |
|
|
|
return SuggestionsManager.getObservable(query, mContext, SuggestionsManager.Source.GOOGLE); |
|
|
|
return SuggestionsManager.createGoogleQueryObservable(query, mContext); |
|
|
|
} else if (mSuggestionChoice == PreferenceManager.Suggestion.SUGGESTION_DUCK) { |
|
|
|
} else if (mSuggestionChoice == PreferenceManager.Suggestion.SUGGESTION_DUCK) { |
|
|
|
return SuggestionsManager.getObservable(query, mContext, SuggestionsManager.Source.DUCK); |
|
|
|
return SuggestionsManager.createDuckQueryObservable(query, mContext); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return Single.empty(); |
|
|
|
return Single.empty(); |
|
|
|
} |
|
|
|
} |
|
|
@ -325,35 +325,35 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable { |
|
|
|
|
|
|
|
|
|
|
|
if (mSuggestionsAdapter.shouldRequestNetwork() && !SuggestionsManager.isRequestInProgress()) { |
|
|
|
if (mSuggestionsAdapter.shouldRequestNetwork() && !SuggestionsManager.isRequestInProgress()) { |
|
|
|
mSuggestionsAdapter.getSuggestionsForQuery(query) |
|
|
|
mSuggestionsAdapter.getSuggestionsForQuery(query) |
|
|
|
.subscribeOn(Schedulers.worker()) |
|
|
|
.subscribeOn(Schedulers.worker()) |
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
|
|
|
|
.subscribe(new SingleOnSubscribe<List<HistoryItem>>() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onItem(@Nullable List<HistoryItem> item) { |
|
|
|
|
|
|
|
mSuggestionsAdapter.combineResults(null, null, item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mSuggestionsAdapter.getBookmarksForQuery(query) |
|
|
|
|
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
|
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
.subscribe(new SingleOnSubscribe<List<HistoryItem>>() { |
|
|
|
.subscribe(new SingleOnSubscribe<List<HistoryItem>>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onItem(@Nullable List<HistoryItem> item) { |
|
|
|
public void onItem(@Nullable List<HistoryItem> item) { |
|
|
|
mSuggestionsAdapter.combineResults(item, null, null); |
|
|
|
mSuggestionsAdapter.combineResults(null, null, item); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mSuggestionsAdapter.getBookmarksForQuery(query) |
|
|
|
|
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
|
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
|
|
|
|
.subscribe(new SingleOnSubscribe<List<HistoryItem>>() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onItem(@Nullable List<HistoryItem> item) { |
|
|
|
|
|
|
|
mSuggestionsAdapter.combineResults(item, null, null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
HistoryModel.findHistoryItemsContaining(query) |
|
|
|
HistoryModel.findHistoryItemsContaining(query) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
.subscribe(new SingleOnSubscribe<List<HistoryItem>>() { |
|
|
|
.subscribe(new SingleOnSubscribe<List<HistoryItem>>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onItem(@Nullable List<HistoryItem> item) { |
|
|
|
public void onItem(@Nullable List<HistoryItem> item) { |
|
|
|
mSuggestionsAdapter.combineResults(null, item, null); |
|
|
|
mSuggestionsAdapter.combineResults(null, item, null); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
results.count = 1; |
|
|
|
results.count = 1; |
|
|
|
return results; |
|
|
|
return results; |
|
|
|
} |
|
|
|
} |
|
|
|