aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
blob: 270135eb7c3b351d90b41606d8dd3efafc63dd62 (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
37
38
39
40
41
42
43
44
45
46
47
48
package cgeo.geocaching.apps.cache.navi;

import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.AbstractLocusApp;
import cgeo.geocaching.geopoint.Geopoint;

import android.app.Activity;

import java.util.ArrayList;

class LocusApp extends AbstractLocusApp implements NavigationApp {

    /**
     * Show a single cache with waypoints or a single waypoint in Locus.
     * This method constructs a list of cache and waypoints only.
     *
     * @see AbstractLocusApp#showInLocus
     * @author koem
     */
    @Override
    public boolean invoke(Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) {

        final ArrayList<Object> points = new ArrayList<Object>();

        // add cache if present
        if (cache != null && cache.getCoords() != null) {
            points.add(cache);
        }

        // add waypoint if present
        if (waypoint != null && waypoint.getCoords() != null) {
            points.add(waypoint);
        }

        return showInLocus(points, true, false, activity);
    }

    @Override
    public boolean isEnabled(cgWaypoint waypoint) {
        return waypoint != null;
    }

    @Override
    public boolean isEnabled(Geopoint geopoint) {
        return geopoint != null;
    }
}