aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorBananeweizen <Bananeweizen@gmx.de>2012-09-08 19:30:36 +0200
committerBananeweizen <Bananeweizen@gmx.de>2012-09-09 08:34:25 +0200
commit70bacd6a868db73d9a8cef23fe1885b5b147e991 (patch)
treed4168a54976a2a5ff8f5e5bf3562047b8b5aa511 /main
parent566e6913d713ad5ca8ca2b0d81106d18d51dc736 (diff)
downloadcgeo-70bacd6a868db73d9a8cef23fe1885b5b147e991.zip
cgeo-70bacd6a868db73d9a8cef23fe1885b5b147e991.tar.gz
cgeo-70bacd6a868db73d9a8cef23fe1885b5b147e991.tar.bz2
refactoring: move static maps check API to cache
Diffstat (limited to 'main')
-rw-r--r--main/src/cgeo/geocaching/StaticMapsActivity.java2
-rw-r--r--main/src/cgeo/geocaching/StaticMapsProvider.java15
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java8
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java2
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java2
-rw-r--r--main/src/cgeo/geocaching/cgCache.java4
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java6
-rw-r--r--main/src/cgeo/geocaching/cgeotrackable.java1
-rw-r--r--main/src/cgeo/geocaching/export/FieldnoteExport.java1
-rw-r--r--main/src/cgeo/geocaching/export/GpxExport.java1
10 files changed, 19 insertions, 23 deletions
diff --git a/main/src/cgeo/geocaching/StaticMapsActivity.java b/main/src/cgeo/geocaching/StaticMapsActivity.java
index 7ddc4e0..05a18f2 100644
--- a/main/src/cgeo/geocaching/StaticMapsActivity.java
+++ b/main/src/cgeo/geocaching/StaticMapsActivity.java
@@ -187,7 +187,7 @@ public class StaticMapsActivity extends AbstractActivity {
if (waypoint_id == null) {
showToast(res.getString(R.string.info_storing_static_maps));
StaticMapsProvider.storeCacheStaticMap(cache, this, true);
- return StaticMapsProvider.hasStaticMapForCache(geocode);
+ return cache.hasStaticMap();
}
final cgWaypoint waypoint = cache.getWaypointById(waypoint_id);
if (waypoint != null) {
diff --git a/main/src/cgeo/geocaching/StaticMapsProvider.java b/main/src/cgeo/geocaching/StaticMapsProvider.java
index ea99d54..89d8bcb 100644
--- a/main/src/cgeo/geocaching/StaticMapsProvider.java
+++ b/main/src/cgeo/geocaching/StaticMapsProvider.java
@@ -231,12 +231,19 @@ public class StaticMapsProvider {
}
/**
- * Check if at least one map file exists for the given geocode.
- *
- * @param geocode
+ * Check if at least one map file exists for the given cache.
+ *
+ * @param cache
* @return <code>true</code> if at least one mapfile exists; <code>false</code> otherwise
*/
- public static boolean hasStaticMapForCache(String geocode) {
+ public static boolean hasStaticMap(final cgCache cache) {
+ if (cache == null) {
+ return false;
+ }
+ final String geocode = cache.getGeocode();
+ if (StringUtils.isBlank(geocode)) {
+ return false;
+ }
for (int level = 1; level <= 5; level++) {
File mapFile = StaticMapsProvider.getMapFile(geocode, String.valueOf(level), false);
if (mapFile != null && mapFile.exists()) {
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
index dacb03f..7530422 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
@@ -29,14 +29,6 @@ abstract class AbstractStaticMapsApp extends AbstractApp implements CacheNavigat
return false;
}
- protected static boolean hasStaticMap(cgCache cache) {
- String geocode = cache.getGeocode();
- if (StringUtils.isNotEmpty(geocode) && cgeoapplication.getInstance().isOffline(geocode, null)) {
- return StaticMapsProvider.hasStaticMapForCache(geocode);
- }
- return false;
- }
-
protected static boolean hasStaticMap(cgWaypoint waypoint) {
String geocode = waypoint.getGeocode();
int id = waypoint.getId();
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java
index f093937..faf3c36 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java
@@ -14,7 +14,7 @@ class DownloadStaticMapsApp extends AbstractStaticMapsApp {
@Override
public boolean isEnabled(cgCache cache) {
- return !hasStaticMap(cache);
+ return !cache.hasStaticMap();
}
@Override
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
index 6be027f..eb01f23 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
@@ -14,7 +14,7 @@ class StaticMapApp extends AbstractStaticMapsApp {
@Override
public boolean isEnabled(cgCache cache) {
- return hasStaticMap(cache);
+ return cache.hasStaticMap();
}
@Override
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index d22999d..43adc61 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -1611,4 +1611,8 @@ public class cgCache implements ICache, IWaypoint {
}
return fullCache.getAttributes().contains(attribute.getAttributeName(yes));
}
+
+ public boolean hasStaticMap() {
+ return StaticMapsProvider.hasStaticMap(this);
+ }
} \ No newline at end of file
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index 0251bff..e4f1926 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -493,7 +493,6 @@ public class cgeocaches extends AbstractListActivity {
threadPure.start();
break;
case NEAREST:
- String action = "pending";
title = res.getString(R.string.caches_nearby);
setTitle(title);
showProgress(true);
@@ -504,7 +503,6 @@ public class cgeocaches extends AbstractListActivity {
thread.start();
break;
case COORDINATE:
- action = "planning";
title = coords.toString();
setTitle(title);
showProgress(true);
@@ -526,7 +524,6 @@ public class cgeocaches extends AbstractListActivity {
thread.start();
break;
case ADDRESS:
- action = "planning";
final String address = extras.getString(EXTRAS_ADDRESS);
if (StringUtils.isNotBlank(address)) {
title = address;
@@ -539,7 +536,6 @@ public class cgeocaches extends AbstractListActivity {
thread = new LoadByCoordsThread(coords);
thread.setRecaptchaHandler(new SearchHandler(this, res, thread));
- thread.start();
break;
case USERNAME:
title = username;
@@ -1385,7 +1381,7 @@ public class cgeocaches extends AbstractListActivity {
final List<cgCache> cachesWithStaticMaps = new ArrayList<cgCache>(selected.size());
for (cgCache cache : selected) {
- if (Settings.isStoreOfflineMaps() && StaticMapsProvider.hasStaticMapForCache(cache.getGeocode())) {
+ if (Settings.isStoreOfflineMaps() && cache.hasStaticMap()) {
cachesWithStaticMaps.add(cache);
continue;
}
diff --git a/main/src/cgeo/geocaching/cgeotrackable.java b/main/src/cgeo/geocaching/cgeotrackable.java
index fcba7fa..6eb7710 100644
--- a/main/src/cgeo/geocaching/cgeotrackable.java
+++ b/main/src/cgeo/geocaching/cgeotrackable.java
@@ -28,7 +28,6 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
-import android.widget.ScrollView;
import android.widget.TextView;
import java.net.URLEncoder;
diff --git a/main/src/cgeo/geocaching/export/FieldnoteExport.java b/main/src/cgeo/geocaching/export/FieldnoteExport.java
index 9e1b7ef..41ec44c 100644
--- a/main/src/cgeo/geocaching/export/FieldnoteExport.java
+++ b/main/src/cgeo/geocaching/export/FieldnoteExport.java
@@ -19,7 +19,6 @@ import android.app.AlertDialog;
import android.os.AsyncTask;
import android.os.Environment;
import android.view.View;
-import android.widget.Button;
import android.widget.CheckBox;
import java.io.File;
diff --git a/main/src/cgeo/geocaching/export/GpxExport.java b/main/src/cgeo/geocaching/export/GpxExport.java
index 593a342..73287da 100644
--- a/main/src/cgeo/geocaching/export/GpxExport.java
+++ b/main/src/cgeo/geocaching/export/GpxExport.java
@@ -25,7 +25,6 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.view.View;
-import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;