diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-08-07 07:32:17 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-08-07 07:32:17 +0200 |
| commit | dd9004cabdb87e40f40b69204a60c5a5f7fd6499 (patch) | |
| tree | 61014be721f4cad4c66d358ebcca26ad3de380f3 /main/src | |
| parent | 781da9d195bfedfa7bce5977b3f5642d0405333a (diff) | |
| download | cgeo-dd9004cabdb87e40f40b69204a60c5a5f7fd6499.zip cgeo-dd9004cabdb87e40f40b69204a60c5a5f7fd6499.tar.gz cgeo-dd9004cabdb87e40f40b69204a60c5a5f7fd6499.tar.bz2 | |
refactoring: findbugs cleanups
Diffstat (limited to 'main/src')
7 files changed, 21 insertions, 23 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 45a1dd2..f43de4e 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -243,7 +243,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc return; } } else if (uriHost.contains("coord.info")) { - if (uriPath != null && uriPath.startsWith("/gc")) { + if (StringUtils.startsWith(uriPath, "/gc")) { geocode = uriPath.substring(1).toUpperCase(Locale.US); } else { showToast(res.getString(R.string.err_detail_open)); @@ -251,7 +251,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc return; } } else if (uriHost.contains("opencaching.de")) { - if (uriPath != null && uriPath.startsWith("/oc")) { + if (StringUtils.startsWith(uriPath, "/oc")) { geocode = uriPath.substring(1).toUpperCase(Locale.US); } else { geocode = uri.getQueryParameter("wp"); diff --git a/main/src/cgeo/geocaching/TrackableActivity.java b/main/src/cgeo/geocaching/TrackableActivity.java index d1f323c..35ffdc6 100644 --- a/main/src/cgeo/geocaching/TrackableActivity.java +++ b/main/src/cgeo/geocaching/TrackableActivity.java @@ -154,7 +154,7 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi } } else if (uriHost.contains("coord.info")) { final String uriPath = uri.getPath().toLowerCase(Locale.US); - if (uriPath != null && uriPath.startsWith("/tb")) { + if (StringUtils.startsWith(uriPath, "/tb")) { geocode = uriPath.substring(1).toUpperCase(Locale.US); guid = null; id = null; diff --git a/main/src/cgeo/geocaching/connector/gc/GCMap.java b/main/src/cgeo/geocaching/connector/gc/GCMap.java index 6a602a7..a213742 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCMap.java +++ b/main/src/cgeo/geocaching/connector/gc/GCMap.java @@ -209,10 +209,10 @@ public class GCMap { cache.setReliableLatLon(false); cache.setGeocode(id); cache.setName(nameCache.get(id)); - cache.setCoords(tile.getCoord(xy), tile.getZoomlevel()); + cache.setCoords(tile.getCoord(xy), tile.getZoomLevel()); if (strategy.flags.contains(StrategyFlag.PARSE_TILES) && bitmap != null) { for (UTFGridPosition singlePos : singlePositions.get(id)) { - if (IconDecoder.parseMapPNG(cache, bitmap, singlePos, tile.getZoomlevel())) { + if (IconDecoder.parseMapPNG(cache, bitmap, singlePos, tile.getZoomLevel())) { break; // cache parsed } } @@ -295,7 +295,7 @@ public class GCMap { final Set<Tile> tiles = Tile.getTilesForViewport(viewport); if (Settings.isDebug()) { - searchResult.setUrl(new StringBuilder().append(tiles.iterator().next().getZoomlevel()).append(Formatter.SEPARATOR).append(searchResult.getUrl()).toString()); + searchResult.setUrl(new StringBuilder().append(tiles.iterator().next().getZoomLevel()).append(Formatter.SEPARATOR).append(searchResult.getUrl()).toString()); } for (Tile tile : tiles) { @@ -304,7 +304,7 @@ public class GCMap { final Parameters params = new Parameters( "x", String.valueOf(tile.getX()), "y", String.valueOf(tile.getY()), - "z", String.valueOf(tile.getZoomlevel()), + "z", String.valueOf(tile.getZoomLevel()), "ep", "1", "app", "cgeo"); if (tokens != null) { @@ -320,7 +320,7 @@ public class GCMap { } else if (Settings.getCacheType() == CacheType.MYSTERY) { params.put("ect", "9,5,3,6,453,13,1304,137,11,4,2,1858"); } - if (tile.getZoomlevel() != 14) { + if (tile.getZoomLevel() != 14) { params.put("_", String.valueOf(System.currentTimeMillis())); } // TODO: other types t.b.d @@ -358,7 +358,7 @@ public class GCMap { } // Check for vanished found caches - if (tiles.iterator().next().getZoomlevel() >= Tile.ZOOMLEVEL_MIN_PERSONALIZED) { + if (tiles.iterator().next().getZoomLevel() >= Tile.ZOOMLEVEL_MIN_PERSONALIZED) { searchResult.addFilteredGeocodes(cgData.getCachedMissingFromSearch(searchResult, tiles, GCConnector.getInstance(), Tile.ZOOMLEVEL_MIN_PERSONALIZED - 1)); } } diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index 7dc048a..d07de78 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -529,9 +529,7 @@ public abstract class GCParser { if (result != null) { // replace linebreak and paragraph tags final String hint = GCConstants.PATTERN_LINEBREAK.matcher(result).replaceAll("\n"); - if (hint != null) { - cache.setHint(StringUtils.replace(hint, "</p>", "").trim()); - } + cache.setHint(StringUtils.replace(hint, "</p>", "").trim()); } cache.checkFields(); @@ -1717,7 +1715,7 @@ public abstract class GCParser { try { final Integer ctl = Integer.valueOf(trackableMatcher.group(3)); final Integer id = Integer.valueOf(trackableMatcher.group(5)); - if (trackCode != null && name != null && ctl != null && id != null) { + if (trackCode != null && ctl != null && id != null) { final TrackableLog entry = new TrackableLog(trackCode, name, id, ctl); Log.i("Trackable in inventory (#" + entry.ctl + "/" + entry.id + "): " + entry.trackCode + " - " + entry.name); diff --git a/main/src/cgeo/geocaching/connector/gc/Tile.java b/main/src/cgeo/geocaching/connector/gc/Tile.java index 3177f2c..4ed53c9 100644 --- a/main/src/cgeo/geocaching/connector/gc/Tile.java +++ b/main/src/cgeo/geocaching/connector/gc/Tile.java @@ -50,7 +50,7 @@ public class Tile { private final int tileX; private final int tileY; - private final int zoomlevel; + private final int zoomLevel; private final Viewport viewPort; public Tile(Geopoint origin, int zoomlevel) { @@ -59,7 +59,7 @@ public class Tile { private Tile(int tileX, int tileY, int zoomlevel) { - this.zoomlevel = clippedZoomlevel(zoomlevel); + this.zoomLevel = clippedZoomlevel(zoomlevel); this.tileX = tileX; this.tileY = tileY; @@ -67,8 +67,8 @@ public class Tile { viewPort = new Viewport(getCoord(new UTFGridPosition(0, 0)), getCoord(new UTFGridPosition(63, 63))); } - public int getZoomlevel() { - return zoomlevel; + public int getZoomLevel() { + return zoomLevel; } private static int clippedZoomlevel(int zoomlevel) { @@ -120,14 +120,14 @@ public class Tile { double pixX = tileX * TILE_SIZE + pos.x * 4; double pixY = tileY * TILE_SIZE + pos.y * 4; - double lonDeg = ((360.0 * pixX) / NUMBER_OF_PIXELS[this.zoomlevel]) - 180.0; - double latRad = Math.atan(Math.sinh(Math.PI * (1 - 2 * pixY / NUMBER_OF_PIXELS[this.zoomlevel]))); + double lonDeg = ((360.0 * pixX) / NUMBER_OF_PIXELS[this.zoomLevel]) - 180.0; + double latRad = Math.atan(Math.sinh(Math.PI * (1 - 2 * pixY / NUMBER_OF_PIXELS[this.zoomLevel]))); return new Geopoint(Math.toDegrees(latRad), lonDeg); } @Override public String toString() { - return String.format(Locale.US, "(%d/%d), zoom=%d", tileX, tileY, zoomlevel); + return String.format(Locale.US, "(%d/%d), zoom=%d", tileX, tileY, zoomLevel); } /** @@ -225,7 +225,7 @@ public class Tile { } return (this.tileX == ((Tile) o).tileX) && (this.tileY == ((Tile) o).tileY) - && (this.zoomlevel == ((Tile) o).zoomlevel); + && (this.zoomLevel == ((Tile) o).zoomLevel); } @Override diff --git a/main/src/cgeo/geocaching/export/FieldnoteExport.java b/main/src/cgeo/geocaching/export/FieldnoteExport.java index d5e6ff6..9bf4037 100644 --- a/main/src/cgeo/geocaching/export/FieldnoteExport.java +++ b/main/src/cgeo/geocaching/export/FieldnoteExport.java @@ -134,7 +134,7 @@ class FieldnoteExport extends AbstractExport { for (final Geocache cache : caches) { if (cache.isLogOffline()) { final LogEntry log = cgData.loadLogOffline(cache.getGeocode()); - if (!onlyNew || onlyNew && log.date > Settings.getFieldnoteExportDate()) { + if (!onlyNew || log.date > Settings.getFieldnoteExportDate()) { appendFieldNote(fieldNoteBuffer, cache, log); } } diff --git a/main/src/cgeo/geocaching/ui/EditNoteDialog.java b/main/src/cgeo/geocaching/ui/EditNoteDialog.java index 50cf57a..5feb181 100644 --- a/main/src/cgeo/geocaching/ui/EditNoteDialog.java +++ b/main/src/cgeo/geocaching/ui/EditNoteDialog.java @@ -41,7 +41,7 @@ public class EditNoteDialog extends DialogFragment { String initialNote = getArguments().getString(ARGUMENT_INITIAL_NOTE); if (initialNote != null) { mEditText.setText(initialNote); - initialNote = null; + getArguments().remove(ARGUMENT_INITIAL_NOTE); } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); |
