aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/loaders/CoordsGeocacheListLoader.java
blob: ca2461cc27b11cf4cf451962639bd04dc6f4eb72 (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.Settings;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.capability.ISearchByCenter;
import cgeo.geocaching.connector.gc.GCParser;
import cgeo.geocaching.geopoint.Geopoint;

import android.content.Context;

public class CoordsGeocacheListLoader extends AbstractSearchLoader {
    private final Geopoint coords;

    public CoordsGeocacheListLoader(Context context, Geopoint coords) {
        super(context);
        this.coords = coords;
    }

    @Override
    public SearchResult runSearch() {
        SearchResult search = GCParser.searchByCoords(coords, Settings.getCacheType(), Settings.isShowCaptcha(), this);

        for (ISearchByCenter centerConn : ConnectorFactory.getSearchByCenterConnectors()) {
            if (centerConn.isActivated()) {
                SearchResult temp = centerConn.searchByCenter(coords);
                if (temp != null) {
                    search.addGeocodes(temp.getGeocodes());
                }
            }
        }

        return search;
    }

}