aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/loaders/KeywordGeocacheListLoader.java
blob: c8132e7872184032d881d8d2c53d0c51320382f6 (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
33
34
35
36
package cgeo.geocaching.loaders;

import cgeo.geocaching.SearchResult;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.capability.ISearchByKeyword;
import cgeo.geocaching.connector.gc.GCParser;
import cgeo.geocaching.settings.Settings;

import android.content.Context;

public class KeywordGeocacheListLoader extends AbstractSearchLoader {

    private final String keyword;

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

    @Override
    public SearchResult runSearch() {
        SearchResult searchResult = new SearchResult();
        if (Settings.isGCConnectorActive()) {
            searchResult = GCParser.searchByKeyword(keyword, Settings.getCacheType(), Settings.isShowCaptcha(), this);
        }

        for (ISearchByKeyword connector : ConnectorFactory.getSearchByKeywordConnectors()) {
            if (connector.isActivated()) {
                searchResult.addSearchResult(connector.searchByName(keyword));
            }
        }

        return searchResult;
    }

}