aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/loaders/KeywordGeocacheListLoader.java
blob: 45b264fcf017e3557a7f8e527ef1ebd6e3998983 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package cgeo.geocaching.loaders;

import cgeo.geocaching.SearchResult;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.capability.ISearchByKeyword;

import org.eclipse.jdt.annotation.NonNull;
import rx.functions.Func1;

import android.content.Context;

public class KeywordGeocacheListLoader extends AbstractSearchLoader {

    private final @NonNull String keyword;

    public KeywordGeocacheListLoader(Context context, final @NonNull String keyword) {
        super(context);
        this.keyword = keyword;
    }

    @Override
    public SearchResult runSearch() {
        return SearchResult.parallelCombineActive(ConnectorFactory.getSearchByKeywordConnectors(),
                new Func1<ISearchByKeyword, SearchResult>() {
                    @Override
                    public SearchResult call(final ISearchByKeyword connector) {
                        return connector.searchByKeyword(keyword, KeywordGeocacheListLoader.this);
                    }
                });
    }

}