use of com.odysee.app.tasks.localdata.FetchRecentUrlHistoryTask in project odysee-android by OdyseeTeam.
the class MainActivity method loadDefaultSuggestionsForBlankUrl.
private void loadDefaultSuggestionsForBlankUrl() {
if (recentUrlHistory != null && recentUrlHistory.size() > 0) {
urlSuggestionListAdapter.addUrlSuggestions(recentUrlHistory);
}
FetchRecentUrlHistoryTask task = new FetchRecentUrlHistoryTask(DatabaseHelper.getInstance(), new FetchRecentUrlHistoryTask.FetchRecentUrlHistoryHandler() {
@Override
public void onSuccess(List<UrlSuggestion> recentHistory) {
List<UrlSuggestion> suggestions = new ArrayList<>(recentHistory);
List<UrlSuggestion> lbrySuggestions = buildLbryUrlSuggestions();
if (suggestions.size() < 10) {
for (int i = suggestions.size(), j = 0; i < 10 && j < lbrySuggestions.size(); i++, j++) {
suggestions.add(lbrySuggestions.get(j));
}
} else if (suggestions.size() == 0) {
suggestions.addAll(lbrySuggestions);
}
for (UrlSuggestion suggestion : suggestions) {
suggestion.setUseTextAsDescription(true);
}
recentUrlHistory = new ArrayList<>(suggestions);
urlSuggestionListAdapter.clear();
urlSuggestionListAdapter.addUrlSuggestions(recentUrlHistory);
List<String> urls = urlSuggestionListAdapter.getItemUrls();
resolveUrlSuggestions(urls);
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations