diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2012-01-08 12:52:41 +0100 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2012-01-08 12:52:41 +0100 |
commit | 867f3024ce13da0963306fd86242cd915a7858f8 (patch) | |
tree | 10df1798856d83c74bbf268812fb68ab191d7eef /main/src | |
parent | ffee09f7c5e4867184fff6e4fef8f9c19a47f370 (diff) | |
download | cgeo-867f3024ce13da0963306fd86242cd915a7858f8.zip cgeo-867f3024ce13da0963306fd86242cd915a7858f8.tar.gz cgeo-867f3024ce13da0963306fd86242cd915a7858f8.tar.bz2 |
refactoring: clean up code around static maps
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/cgeo/geocaching/CacheCache.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 8 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/StaticMapsActivity.java (renamed from main/src/cgeo/geocaching/cgeosmaps.java) | 20 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/StaticMapsProvider.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/VisitCacheActivity.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgCache.java | 10 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 7 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeoapplication.java | 6 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeowaypoint.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/files/GPXImporter.java | 2 |
12 files changed, 35 insertions, 38 deletions
diff --git a/main/src/cgeo/geocaching/CacheCache.java b/main/src/cgeo/geocaching/CacheCache.java index 3b27186..ea8d749 100644 --- a/main/src/cgeo/geocaching/CacheCache.java +++ b/main/src/cgeo/geocaching/CacheCache.java @@ -1,6 +1,6 @@ package cgeo.geocaching; -import cgeo.geocaching.cgData.StorageLocations; +import cgeo.geocaching.cgData.StorageLocation; import java.util.ArrayList; import java.util.HashMap; @@ -57,7 +57,7 @@ public class CacheCache { cachesCache.remove(cache.getGeocode()); } - cache.addStorageLocation(StorageLocations.CACHE); + cache.addStorageLocation(StorageLocation.CACHE); cachesCache.put(cache.getGeocode(), cache); } diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 339219e..3b55bc9 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -1,6 +1,6 @@ package cgeo.geocaching; -import cgeo.geocaching.cgData.StorageLocations; +import cgeo.geocaching.cgData.StorageLocation; import cgeo.geocaching.activity.AbstractActivity; import cgeo.geocaching.activity.Progress; import cgeo.geocaching.apps.cache.GeneralAppsFactory; @@ -1657,7 +1657,7 @@ public class CacheDetailActivity extends AbstractActivity { @Override public void run() { - app.removeCacheFromCache(cache.getGeocode()); + cgeoapplication.removeCacheFromCache(cache.getGeocode()); search = cgBase.searchByGeocode(cache.getGeocode(), null, 0, true, handler); handler.sendEmptyMessage(0); @@ -1850,10 +1850,10 @@ public class CacheDetailActivity extends AbstractActivity { final TextView internalsText = (TextView) view.findViewById(R.id.debug_text); String sl = "Storage location: "; - if (cache.getStorageLocation().contains(StorageLocations.CACHE)) { + if (cache.getStorageLocation().contains(StorageLocation.CACHE)) { sl += "Cache "; } - if (cache.getStorageLocation().contains(StorageLocations.DATABASE)) { + if (cache.getStorageLocation().contains(StorageLocation.DATABASE)) { sl += "Database (" + cache.getListId() + ")"; } diff --git a/main/src/cgeo/geocaching/cgeosmaps.java b/main/src/cgeo/geocaching/StaticMapsActivity.java index 965542f..b33d17d 100644 --- a/main/src/cgeo/geocaching/cgeosmaps.java +++ b/main/src/cgeo/geocaching/StaticMapsActivity.java @@ -18,15 +18,15 @@ import android.widget.LinearLayout; import java.util.ArrayList; import java.util.List; -public class cgeosmaps extends AbstractActivity { +public class StaticMapsActivity extends AbstractActivity { - private List<Bitmap> maps = new ArrayList<Bitmap>(); + private final List<Bitmap> maps = new ArrayList<Bitmap>(); private String geocode = null; private LayoutInflater inflater = null; private ProgressDialog waitDialog = null; private LinearLayout smapsView = null; private BitmapFactory factory = null; - private Handler loadMapsHandler = new Handler() { + private final Handler loadMapsHandler = new Handler() { @Override public void handleMessage(Message msg) { @@ -66,7 +66,7 @@ public class cgeosmaps extends AbstractActivity { if (waitDialog != null) { waitDialog.dismiss(); } - Log.e(Settings.tag, "cgeosmaps.loadMapsHandler: " + e.toString()); + Log.e(Settings.tag, "StaticMapsActivity.loadMapsHandler: " + e.toString()); } } }; @@ -80,7 +80,7 @@ public class cgeosmaps extends AbstractActivity { setTitle(res.getString(R.string.map_static_title)); // get parameters - Bundle extras = getIntent().getExtras(); + final Bundle extras = getIntent().getExtras(); // try to get data from extras if (extras != null) { @@ -96,7 +96,7 @@ public class cgeosmaps extends AbstractActivity { waitDialog = ProgressDialog.show(this, null, res.getString(R.string.map_static_loading), true); waitDialog.setCancelable(true); - (new loadMaps()).start(); + (new LoadMapsThread()).start(); } @Override @@ -105,7 +105,7 @@ public class cgeosmaps extends AbstractActivity { } - private class loadMaps extends Thread { + private class LoadMapsThread extends Thread { @Override public void run() { @@ -121,7 +121,7 @@ public class cgeosmaps extends AbstractActivity { maps.add(image); } } catch (Exception e) { - Log.e(Settings.tag, "cgeosmaps.loadMaps.run.1: " + e.toString()); + Log.e(Settings.tag, "StaticMapsActivity.LoadMapsThread.run.1: " + e.toString()); } } @@ -133,14 +133,14 @@ public class cgeosmaps extends AbstractActivity { maps.add(image); } } catch (Exception e) { - Log.e(Settings.tag, "cgeosmaps.loadMaps.run.2: " + e.toString()); + Log.e(Settings.tag, "StaticMapsActivity.LoadMapsThread.run.2: " + e.toString()); } } } loadMapsHandler.sendMessage(new Message()); } catch (Exception e) { - Log.e(Settings.tag, "cgeosmaps.loadMaps.run: " + e.toString()); + Log.e(Settings.tag, "StaticMapsActivity.LoadMapsThread.run: " + e.toString()); } } } diff --git a/main/src/cgeo/geocaching/StaticMapsProvider.java b/main/src/cgeo/geocaching/StaticMapsProvider.java index d37905b..3176c9f 100644 --- a/main/src/cgeo/geocaching/StaticMapsProvider.java +++ b/main/src/cgeo/geocaching/StaticMapsProvider.java @@ -90,7 +90,7 @@ public class StaticMapsProvider { private static void downloadMaps(final cgCache cache, final String latlonMap, final int edge, final String waypoints) { - Thread staticMapsThread = new Thread("getting static map") { + final Thread staticMapsThread = new Thread("getting static map") { @Override public void run() { downloadMapsInThread(cache, latlonMap, edge, waypoints); diff --git a/main/src/cgeo/geocaching/VisitCacheActivity.java b/main/src/cgeo/geocaching/VisitCacheActivity.java index 18ada72..d0e8a5e 100644 --- a/main/src/cgeo/geocaching/VisitCacheActivity.java +++ b/main/src/cgeo/geocaching/VisitCacheActivity.java @@ -710,9 +710,9 @@ public class VisitCacheActivity extends AbstractActivity implements DateDialog.D } if (cache != null) { - app.putCacheInCache(cache); + cgeoapplication.putCacheInCache(cache); } else { - app.removeCacheFromCache(geocode); + cgeoapplication.removeCacheFromCache(geocode); } } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java index 9c7064b..6a29895 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java @@ -5,7 +5,7 @@ import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgWaypoint; -import cgeo.geocaching.cgeosmaps; +import cgeo.geocaching.StaticMapsActivity; import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.geopoint.Geopoint; @@ -34,7 +34,7 @@ class StaticMapApp extends AbstractNavigationApp { } if (cache.getGeocode() != null) { - final Intent intent = new Intent(activity, cgeosmaps.class); + final Intent intent = new Intent(activity, StaticMapsActivity.class); intent.putExtra("geocode", cache.getGeocode().toUpperCase()); activity.startActivity(intent); return true; diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index 273b36b..69a35fe 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -2696,7 +2696,7 @@ public class cgBase { } app.markStored(cache.getGeocode(), listId); - app.removeCacheFromCache(cache.getGeocode()); + cgeoapplication.removeCacheFromCache(cache.getGeocode()); if (handler != null) { handler.sendMessage(new Message()); @@ -2709,7 +2709,7 @@ public class cgBase { public static void dropCache(final cgeoapplication app, final cgCache cache, final Handler handler) { try { app.markDropped(cache.getGeocode()); - app.removeCacheFromCache(cache.getGeocode()); + cgeoapplication.removeCacheFromCache(cache.getGeocode()); handler.sendMessage(new Message()); } catch (Exception e) { diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index b61ae23..220f2fa 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -1,6 +1,6 @@ package cgeo.geocaching; -import cgeo.geocaching.cgData.StorageLocations; +import cgeo.geocaching.cgData.StorageLocation; import cgeo.geocaching.activity.IAbstractActivity; import cgeo.geocaching.connector.ConnectorFactory; import cgeo.geocaching.connector.GCConnector; @@ -92,7 +92,7 @@ public class cgCache implements ICache { private boolean statusCheckedView = false; private String directionImg = ""; private String nameForSorting; - private final EnumSet<StorageLocations> storageLocation = EnumSet.of(StorageLocations.HEAP); + private final EnumSet<StorageLocation> storageLocation = EnumSet.of(StorageLocation.HEAP); private static final Pattern NUMBER_PATTERN = Pattern.compile("\\d+"); @@ -1058,7 +1058,7 @@ public class cgCache implements ICache { /** * @return the storageLocation */ - public EnumSet<StorageLocations> getStorageLocation() { + public EnumSet<StorageLocation> getStorageLocation() { return storageLocation; } @@ -1066,7 +1066,7 @@ public class cgCache implements ICache { * @param storageLocation * the storageLocation to set */ - public void addStorageLocation(StorageLocations sl) { + public void addStorageLocation(StorageLocation sl) { this.storageLocation.add(sl); } @@ -1121,7 +1121,7 @@ public class cgCache implements ICache { if (waypoint.isUserDefined()) { waypoints.remove(index); cgeoapplication.getInstance().deleteWaypoint(waypoint.getId()); - cgeoapplication.getInstance().removeCacheFromCache(geocode); + cgeoapplication.removeCacheFromCache(geocode); return true; } return false; diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index 0363d33..f6039c1 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -40,8 +40,7 @@ import java.util.regex.Pattern; public class cgData { - // TODO: remove plural - public enum StorageLocations { + public enum StorageLocation { HEAP, CACHE, DATABASE, @@ -1254,7 +1253,7 @@ public class cgData { // remember this cache in the caches cache. it is highly likely that we will need it in a few moments and // this way we also remove any stale instance from the caches cache - cgeoapplication.getInstance().putCacheInCache(cache); + cgeoapplication.putCacheInCache(cache); ContentValues values = new ContentValues(); @@ -1990,7 +1989,7 @@ public class cgData { if (loadFlags.contains(LoadFlag.LOADOFFLINELOG)) { cache.setLogOffline(hasLogOffline(cache.getGeocode())); } - cache.addStorageLocation(StorageLocations.DATABASE); + cache.addStorageLocation(StorageLocation.DATABASE); caches.add(cache); } while (cursor.moveToNext()); diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java index 3bfe69a..021bfca 100644 --- a/main/src/cgeo/geocaching/cgeoapplication.java +++ b/main/src/cgeo/geocaching/cgeoapplication.java @@ -286,13 +286,11 @@ public class cgeoapplication extends Application { return trackable; } - @SuppressWarnings("static-method") - public void removeCacheFromCache(final String geocode) { + public static void removeCacheFromCache(final String geocode) { CacheCache.getInstance().removeCacheFromCache(geocode); } - @SuppressWarnings("static-method") - public void putCacheInCache(final cgCache cache) { + public static void putCacheInCache(final cgCache cache) { CacheCache.getInstance().putCacheInCache(cache); } diff --git a/main/src/cgeo/geocaching/cgeowaypoint.java b/main/src/cgeo/geocaching/cgeowaypoint.java index 4abdfd3..218c61b 100644 --- a/main/src/cgeo/geocaching/cgeowaypoint.java +++ b/main/src/cgeo/geocaching/cgeowaypoint.java @@ -297,7 +297,7 @@ public class cgeowaypoint extends AbstractActivity { public void onClick(View arg0) { if (app.deleteWaypoint(id)) { - app.removeCacheFromCache(geocode); + cgeoapplication.removeCacheFromCache(geocode); finish(); return; diff --git a/main/src/cgeo/geocaching/files/GPXImporter.java b/main/src/cgeo/geocaching/files/GPXImporter.java index d855d69..9ced045 100644 --- a/main/src/cgeo/geocaching/files/GPXImporter.java +++ b/main/src/cgeo/geocaching/files/GPXImporter.java @@ -150,7 +150,7 @@ public class GPXImporter { int storedCaches = 0; for (cgCache cache : caches) { // remove from cache because a cache might be re-imported - app.removeCacheFromCache(cache.getGeocode()); + cgeoapplication.removeCacheFromCache(cache.getGeocode()); app.addCacheToSearch(search, cache); if (progressHandler.isCancelled()) { |