blob: b2a2cad083494c84511572a2d5b20030dd628a12 (
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.apps.cache;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.R;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.utils.TextUtils;
import org.apache.commons.lang3.StringUtils;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import java.util.regex.Pattern;
public class WhereYouGoApp extends AbstractGeneralApp {
private static final Pattern PATTERN_CARTRIDGE = Pattern.compile("(" + Pattern.quote("http://www.wherigo.com/cartridge/details.aspx?") + ".*?)" + Pattern.quote("\""));
public WhereYouGoApp() {
super(getString(R.string.cache_menu_whereyougo), R.id.cache_app_whereyougo, "menion.android.whereyougo");
}
@Override
public boolean isEnabled(Geocache cache) {
return cache.getType() == CacheType.WHERIGO && StringUtils.isNotEmpty(getWhereIGoUrl(cache));
}
@Override
public void navigate(Activity activity, Geocache cache) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getWhereIGoUrl(cache))));
}
protected static String getWhereIGoUrl(Geocache cache) {
return TextUtils.getMatch(cache.getDescription(), PATTERN_CARTRIDGE, null);
}
}
|