blob: ffcac8e0b8fb6078633e2777461472392aee2c87 (
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
|
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.ILogable;
import cgeo.geocaching.R;
import cgeo.geocaching.StaticMapsActivity;
import cgeo.geocaching.StaticMapsProvider;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.activity.ActivityMixin;
import org.apache.commons.lang3.StringUtils;
import android.app.Activity;
import android.content.Intent;
abstract class AbstractStaticMapsApp extends AbstractNavigationApp {
public AbstractStaticMapsApp(String name) {
super(name, null);
}
@Override
public boolean isInstalled() {
return true;
}
protected static boolean hasStaticMap(cgCache cache) {
if (cache != null) {
String geocode = cache.getGeocode();
if (StringUtils.isNotEmpty(geocode) && cgeoapplication.getInstance().isOffline(geocode, null)) {
return StaticMapsProvider.doesExistStaticMapForCache(geocode);
}
}
return false;
}
protected static boolean hasStaticMap(cgWaypoint waypoint) {
if (waypoint != null) {
String geocode = waypoint.getGeocode();
int id = waypoint.getId();
if (StringUtils.isNotEmpty(geocode) && cgeoapplication.getInstance().isOffline(geocode, null)) {
return StaticMapsProvider.doesExistStaticMapForWaypoint(geocode, id);
}
}
return false;
}
protected static boolean invoke(final Activity activity, final cgCache cache, final cgWaypoint waypoint, final boolean download) {
final ILogable logable = cache != null && cache.getListId() != 0 ? cache : waypoint;
final String geocode = logable.getGeocode().toUpperCase();
if (geocode == null) {
ActivityMixin.showToast(activity, getString(R.string.err_detail_no_map_static));
return true;
}
final Intent intent = new Intent(activity, StaticMapsActivity.class);
intent.putExtra("geocode", geocode);
if (download) {
intent.putExtra("download", true);
}
if (waypoint != null) {
intent.putExtra("waypoint", waypoint.getId());
}
activity.startActivity(intent);
return true;
}
}
|