Search in sources :

Example 1 with ListEngineDisplayExt

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<>());
        }
    }
}
Also used : ListEngineDisplayExt(im.actor.runtime.storage.ListEngineDisplayExt) PeerSearchEntity(im.actor.core.entity.PeerSearchEntity) SearchEntity(im.actor.core.entity.SearchEntity) ArrayList(java.util.ArrayList) SearchResult(im.actor.core.entity.SearchResult)

Aggregations

PeerSearchEntity (im.actor.core.entity.PeerSearchEntity)1 SearchEntity (im.actor.core.entity.SearchEntity)1 SearchResult (im.actor.core.entity.SearchResult)1 ListEngineDisplayExt (im.actor.runtime.storage.ListEngineDisplayExt)1 ArrayList (java.util.ArrayList)1