use of im.actor.runtime.storage.ListEngineDisplayExt in project actor-platform by actorapp.
the class GlobalSearchSource method loadResults.
@Override
public void loadResults(String query, Consumer<List<SearchResult>> callback) {
ListEngine<SearchEntity> searchList = context().getSearchModule().getSearchList();
if (searchList instanceof ListEngineDisplayExt) {
((ListEngineDisplayExt<SearchEntity>) searchList).loadBackward(query, 20, (items, topSortKey, bottomSortKey) -> {
ArrayList<SearchResult> localResults = new ArrayList<>();
for (SearchEntity e : items) {
localResults.add(new SearchResult(e.getPeer(), e.getAvatar(), e.getTitle(), null));
}
callback.apply(new ArrayList<>(localResults));
if (query.length() > 3) {
loadGlobalResults(query, localResults, callback);
}
});
} else {
if (query.length() > 3) {
loadGlobalResults(query, new ArrayList<>(), callback);
} else {
callback.apply(new ArrayList<>());
}
}
}
Aggregations