diff options
author | Bananeweizen <Bananeweizen@gmx.de> | 2012-05-07 22:42:58 -0700 |
---|---|---|
committer | Bananeweizen <Bananeweizen@gmx.de> | 2012-05-07 22:42:58 -0700 |
commit | 02577998c34c26d07daeb5e35ba8364a92e12e9a (patch) | |
tree | 3aa9f8983bce8880c048bedbe19cf92242a3e1c3 /main/src | |
parent | 5120799c665d1023a8f81c205d59b9474eb83e88 (diff) | |
parent | 09172e3ec20079e8d44f4965146dd22ad1d1ca5f (diff) | |
download | cgeo-02577998c34c26d07daeb5e35ba8364a92e12e9a.zip cgeo-02577998c34c26d07daeb5e35ba8364a92e12e9a.tar.gz cgeo-02577998c34c26d07daeb5e35ba8364a92e12e9a.tar.bz2 |
Merge pull request #1514 from marco-jacob/issue#1511-loopGoogleMapsLimit
Fixes issue #1511 endless loop downloading static maps on demand
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/cgeo/geocaching/StaticMapsActivity.java | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/main/src/cgeo/geocaching/StaticMapsActivity.java b/main/src/cgeo/geocaching/StaticMapsActivity.java index ddda8a4..ec417dd 100644 --- a/main/src/cgeo/geocaching/StaticMapsActivity.java +++ b/main/src/cgeo/geocaching/StaticMapsActivity.java @@ -42,13 +42,16 @@ public class StaticMapsActivity extends AbstractActivity { try { if (CollectionUtils.isEmpty(maps)) { if (download) { - downloadStaticMaps(); - startActivity(StaticMapsActivity.this.getIntent()); - finish(); + final boolean succeeded = downloadStaticMaps(); + if (succeeded) { + startActivity(StaticMapsActivity.this.getIntent()); + } else { + showToast(res.getString(R.string.err_detail_google_maps_limit_reached)); + } } else { showToast(res.getString(R.string.err_detail_not_load_map_static)); - finish(); } + finish(); } else { showStaticMaps(); } @@ -188,19 +191,20 @@ public class StaticMapsActivity extends AbstractActivity { return super.onOptionsItemSelected(item); } - private void downloadStaticMaps() { + private boolean downloadStaticMaps() { final cgCache cache = app.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); if (waypoint_id == null) { showToast(res.getString(R.string.info_storing_static_maps)); StaticMapsProvider.storeCacheStaticMap(cache, this, true); - } else { - 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); - } else { - showToast(res.getString(R.string.err_detail_not_load_map_static)); - } + return StaticMapsProvider.doesExistStaticMapForCache(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); } + showToast(res.getString(R.string.err_detail_not_load_map_static)); + return false; } }
\ No newline at end of file |