aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2011-11-21 21:09:53 +0100
committerBananeweizen <bananeweizen@gmx.de>2011-11-21 21:09:53 +0100
commitae0adeb6b2e476dbad032b6daa2b692d0570bea8 (patch)
tree12ff3415ce7b1dd952a778a7016c3e255e1c9de4
parentbdc075c4c1f520a6b75198623b99016f74def117 (diff)
downloadcgeo-ae0adeb6b2e476dbad032b6daa2b692d0570bea8.zip
cgeo-ae0adeb6b2e476dbad032b6daa2b692d0570bea8.tar.gz
cgeo-ae0adeb6b2e476dbad032b6daa2b692d0570bea8.tar.bz2
refactoring: more FindBugs issues
-rw-r--r--main/src/cgeo/geocaching/cgData.java35
-rw-r--r--main/src/cgeo/geocaching/cgeoapplication.java8
-rw-r--r--main/src/cgeo/geocaching/cgeoinit.java2
-rw-r--r--main/src/cgeo/geocaching/maps/OtherCachersOverlayItem.java2
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleOtherCachersOverlayItem.java2
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOtherCachersOverlayItem.java2
6 files changed, 12 insertions, 39 deletions
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java
index cb8f10c..87c6a97 100644
--- a/main/src/cgeo/geocaching/cgData.java
+++ b/main/src/cgeo/geocaching/cgData.java
@@ -1809,9 +1809,8 @@ public class cgData {
* @return the loaded cache
*/
- public cgCache loadCache(final String geocode, final String guid, final int loadFlags) {
+ public cgCache loadCache(final String geocode, final int loadFlags) {
Object[] geocodes = new Object[1];
- Object[] guids = new Object[1];
if (StringUtils.isNotBlank(geocode)) {
geocodes[0] = geocode;
@@ -1819,13 +1818,7 @@ public class cgData {
geocodes = null;
}
- if (StringUtils.isNotBlank(guid)) {
- guids[0] = guid;
- } else {
- guids = null;
- }
-
- List<cgCache> caches = loadCaches(geocodes, null, null, null, null, null, loadFlags);
+ List<cgCache> caches = loadCaches(geocodes, null, null, null, null, loadFlags);
if (CollectionUtils.isNotEmpty(caches)) {
return caches.get(0);
}
@@ -1833,13 +1826,10 @@ public class cgData {
return null;
}
- public List<cgCache> loadCaches(final Object[] geocodes, final Object[] guids, final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final int loadFlags) {
+ public List<cgCache> loadCaches(final Object[] geocodes, final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final int loadFlags) {
init();
// Using more than one of the parametersets results in overly comlex wheres
- if (((geocodes != null && geocodes.length > 0) && (guids != null && guids.length > 0))) {
- throw new IllegalArgumentException("Please use only one parameter");
- }
- if (((geocodes != null && geocodes.length > 0) || (guids != null && guids.length > 0))
+ if ((geocodes != null && geocodes.length > 0)
&& centerLat != null
&& centerLon != null
&& spanLat != null
@@ -1868,23 +1858,6 @@ public class cgData {
where.append("geocode in (");
where.append(all);
where.append(')');
- } else if (guids != null && guids.length > 0) {
- StringBuilder all = new StringBuilder();
- for (Object one : guids) {
- if (all.length() > 0) {
- all.append(", ");
- }
- all.append('"');
- all.append((String) one);
- all.append('"');
- }
-
- if (where.length() > 0) {
- where.append(" and ");
- }
- where.append("guid in (");
- where.append(all);
- where.append(')');
} else {
return caches;
}
diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java
index f0af0e9..03f7a91 100644
--- a/main/src/cgeo/geocaching/cgeoapplication.java
+++ b/main/src/cgeo/geocaching/cgeoapplication.java
@@ -349,7 +349,7 @@ public class cgeoapplication extends Application {
return cachesCache.get(geocode);
}
- final cgCache cache = getStorage().loadCache(geocode, null, loadFlags);
+ final cgCache cache = getStorage().loadCache(geocode, loadFlags);
if (cache != null && cache.getDetailed() && loadFlags == cgCache.LOADALL) {
putCacheInCache(cache);
@@ -460,7 +460,7 @@ public class cgeoapplication extends Application {
if (search == null) {
List<cgCache> cachesOut = new ArrayList<cgCache>();
- final List<cgCache> cachesPre = storage.loadCaches(null, null, centerLat, centerLon, spanLat, spanLon, loadFlags);
+ final List<cgCache> cachesPre = storage.loadCaches(null, centerLat, centerLon, spanLat, spanLon, loadFlags);
if (cachesPre != null) {
cachesOut.addAll(cachesPre);
}
@@ -473,7 +473,7 @@ public class cgeoapplication extends Application {
final List<String> geocodeList = search.getGeocodes();
// The list of geocodes is sufficient. more parameters generate an overly complex select.
- final List<cgCache> cachesPre = getStorage().loadCaches(geocodeList.toArray(), null, null, null, null, null, loadFlags);
+ final List<cgCache> cachesPre = getStorage().loadCaches(geocodeList.toArray(), null, null, null, null, loadFlags);
if (cachesPre != null) {
cachesOut.addAll(cachesPre);
}
@@ -613,7 +613,7 @@ public class cgeoapplication extends Application {
private boolean storeWithMerge(final cgCache cache, final boolean override) {
if (!override) {
- final cgCache oldCache = storage.loadCache(cache.getGeocode(), cache.getGuid(), cgCache.LOADALL);
+ final cgCache oldCache = storage.loadCache(cache.getGeocode(), cgCache.LOADALL);
cache.gatherMissingFrom(oldCache);
}
return storage.saveCache(cache);
diff --git a/main/src/cgeo/geocaching/cgeoinit.java b/main/src/cgeo/geocaching/cgeoinit.java
index 7b1731e..0850525 100644
--- a/main/src/cgeo/geocaching/cgeoinit.java
+++ b/main/src/cgeo/geocaching/cgeoinit.java
@@ -38,7 +38,7 @@ import java.util.concurrent.atomic.AtomicReference;
public class cgeoinit extends AbstractActivity {
- private final int SELECT_MAPFILE_REQUEST = 1;
+ private final static int SELECT_MAPFILE_REQUEST = 1;
private ProgressDialog loginDialog = null;
private ProgressDialog webDialog = null;
diff --git a/main/src/cgeo/geocaching/maps/OtherCachersOverlayItem.java b/main/src/cgeo/geocaching/maps/OtherCachersOverlayItem.java
index 16e2677..d71bbcf 100644
--- a/main/src/cgeo/geocaching/maps/OtherCachersOverlayItem.java
+++ b/main/src/cgeo/geocaching/maps/OtherCachersOverlayItem.java
@@ -15,7 +15,7 @@ public class OtherCachersOverlayItem {
user = userIn;
}
- public Drawable getMarker(int state) {
+ public Drawable getMarker() {
Drawable marker = null;
if (user != null && user.getDate() != null && user.getDate().getTime() >= (System.currentTimeMillis() - (20 * 60 * 1000))) {
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleOtherCachersOverlayItem.java b/main/src/cgeo/geocaching/maps/google/GoogleOtherCachersOverlayItem.java
index 9d9580c..0adc9ae 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleOtherCachersOverlayItem.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleOtherCachersOverlayItem.java
@@ -20,7 +20,7 @@ public class GoogleOtherCachersOverlayItem extends OverlayItem implements OtherC
@Override
public Drawable getMarker(int state) {
- final Drawable marker = item.getMarker(state);
+ final Drawable marker = item.getMarker();
setMarker(marker);
return marker;
}
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOtherCachersOverlayItem.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOtherCachersOverlayItem.java
index e9c1d0b..7795968 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOtherCachersOverlayItem.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOtherCachersOverlayItem.java
@@ -20,7 +20,7 @@ public class MapsforgeOtherCachersOverlayItem extends OverlayItem implements Oth
@Override
public Drawable getMarker(int state) {
- Drawable marker = item.getMarker(state);
+ Drawable marker = item.getMarker();
setMarker(marker);
return marker;
}