aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
blob: 8e75aaadcbac4475abf7eab0f9c2e449bfc56d9a (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package cgeo.geocaching.apps.cache.navi;

import java.util.ArrayList;
import java.util.Locale;
import java.util.UUID;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgWaypoint;

class RMapsApp extends AbstractNavigationApp implements NavigationApp {

	private static final String INTENT = "com.robert.maps.action.SHOW_POINTS";

	RMapsApp(final Resources res) {
		super(res.getString(R.string.cache_menu_rmaps), INTENT);
	}

	@Override
	public boolean invoke(cgGeo geo, Activity activity, Resources res,
			cgCache cache,
			final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
		if (cache == null && waypoint == null && latitude == null
				&& longitude == null) {
			return false;
		}

		try {
			if (isInstalled(activity)) {
				final ArrayList<String> locations = new ArrayList<String>();
				if (cache != null && cache.latitude != null
						&& cache.longitude != null) {
					locations.add(String.format((Locale) null, "%.6f",
							cache.latitude)
							+ ","
							+ String.format((Locale) null, "%.6f",
									cache.longitude)
							+ ";"
							+ cache.geocode
							+ ";" + cache.name);
				} else if (waypoint != null && waypoint.latitude != null
						&& waypoint.longitude != null) {
					locations.add(String.format((Locale) null, "%.6f",
							waypoint.latitude)
							+ ","
							+ String.format((Locale) null, "%.6f",
									waypoint.longitude)
							+ ";"
							+ waypoint.lookup
							+ ";" + waypoint.name);
				}

				final Intent intent = new Intent(
						"com.robert.maps.action.SHOW_POINTS");

				intent.putStringArrayListExtra("locations", locations);

				activity.startActivity(intent);

				return true;
			}
		} catch (Exception e) {
			// nothing
		}

		return false;
	}
}