aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/StaticMapsActivity.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-05-30 07:30:36 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-05-30 07:30:36 +0200
commit1cc60d0d381939573b719a3091637c2cef5a6df8 (patch)
tree8f74fa85cbccdbf08fe224a66ae7eeb46426370f /main/src/cgeo/geocaching/StaticMapsActivity.java
parente8b6712d85938c49a82554ca27946456c8410c5d (diff)
downloadcgeo-1cc60d0d381939573b719a3091637c2cef5a6df8.zip
cgeo-1cc60d0d381939573b719a3091637c2cef5a6df8.tar.gz
cgeo-1cc60d0d381939573b719a3091637c2cef5a6df8.tar.bz2
refactoring: clean up leaked interface of static maps provider
Diffstat (limited to 'main/src/cgeo/geocaching/StaticMapsActivity.java')
-rw-r--r--main/src/cgeo/geocaching/StaticMapsActivity.java34
1 files changed, 10 insertions, 24 deletions
diff --git a/main/src/cgeo/geocaching/StaticMapsActivity.java b/main/src/cgeo/geocaching/StaticMapsActivity.java
index a95f4d2..7ddc4e0 100644
--- a/main/src/cgeo/geocaching/StaticMapsActivity.java
+++ b/main/src/cgeo/geocaching/StaticMapsActivity.java
@@ -135,42 +135,28 @@ public class StaticMapsActivity extends AbstractActivity {
factory = new BitmapFactory();
}
- for (int level = 1; level <= 5; level++) {
- try {
- if (waypoint_id != null) {
- final Bitmap image = BitmapFactory.decodeFile(StaticMapsProvider.getMapFile(geocode, "wp" + waypoint_id + "_" + level, false).getPath());
- if (image != null) {
- maps.add(image);
- }
- } else {
- final Bitmap image = BitmapFactory.decodeFile(StaticMapsProvider.getMapFile(geocode, "" + level, false).getPath());
- if (image != null) {
- maps.add(image);
- }
- }
- } catch (Exception e) {
- Log.e("StaticMapsActivity.LoadMapsThread.run.1: " + e.toString());
- }
- }
-
- if (maps.isEmpty()) {
+ // try downloading 2 times
+ for (int trials = 0; trials < 2; trials++) {
for (int level = 1; level <= 5; level++) {
try {
if (waypoint_id != null) {
- final Bitmap image = BitmapFactory.decodeFile(StaticMapsProvider.getMapFile(geocode, "wp" + waypoint_id + "_" + level, false).getPath());
+ final Bitmap image = StaticMapsProvider.getWaypointMap(geocode, waypoint_id, level);
if (image != null) {
maps.add(image);
}
} else {
- final Bitmap image = BitmapFactory.decodeFile(StaticMapsProvider.getMapFile(geocode, "" + level, false).getPath());
+ final Bitmap image = StaticMapsProvider.getCacheMap(geocode, level);
if (image != null) {
maps.add(image);
}
}
} catch (Exception e) {
- Log.e("StaticMapsActivity.LoadMapsThread.run.2: " + e.toString());
+ Log.e("StaticMapsActivity.LoadMapsThread.run: " + e.toString());
}
}
+ if (!maps.isEmpty()) {
+ break;
+ }
}
loadMapsHandler.sendMessage(Message.obtain());
@@ -201,13 +187,13 @@ 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.doesExistStaticMapForCache(geocode);
+ return StaticMapsProvider.hasStaticMapForCache(geocode);
}
final cgWaypoint waypoint = cache.getWaypointById(waypoint_id);
if (waypoint != null) {
showToast(res.getString(R.string.info_storing_static_maps));
StaticMapsProvider.storeWaypointStaticMap(cache, this, waypoint, true);
- return StaticMapsProvider.doesExistStaticMapForWaypoint(geocode, waypoint_id);
+ return StaticMapsProvider.hasStaticMapForWaypoint(geocode, waypoint_id);
}
showToast(res.getString(R.string.err_detail_not_load_map_static));
return false;