Search in sources :

Example 1 with SearchResult

use of net.technicpack.platform.io.SearchResult in project LauncherV3 by TechnicPack.

the class SearchResultPackSource method getPublicPacks.

@Override
public // Get PlatformPackInfo objects for every result from the given search terms.
Collection<PackInfo> getPublicPacks() {
    resultPriorities.clear();
    // Get results from server
    SearchResultsData results = null;
    try {
        results = platformApi.getSearchResults(searchTerms);
    } catch (RestfulAPIException ex) {
        return Collections.emptySet();
    }
    ArrayList<PackInfo> resultPacks = new ArrayList<PackInfo>(results.getResults().length);
    int priority = 100;
    for (SearchResult result : results.getResults()) {
        resultPacks.add(new SearchResultPackInfo(result));
        resultPriorities.put(result.getSlug(), priority--);
    }
    return resultPacks;
}
Also used : RestfulAPIException(net.technicpack.rest.RestfulAPIException) PackInfo(net.technicpack.rest.io.PackInfo) SearchResult(net.technicpack.platform.io.SearchResult) SearchResultsData(net.technicpack.platform.io.SearchResultsData)

Aggregations

SearchResult (net.technicpack.platform.io.SearchResult)1 SearchResultsData (net.technicpack.platform.io.SearchResultsData)1 RestfulAPIException (net.technicpack.rest.RestfulAPIException)1 PackInfo (net.technicpack.rest.io.PackInfo)1