diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/src/cgeo/geocaching/CacheCache.java | 6 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 10 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgCache.java | 8 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgGeo.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeoinit.java | 8 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeowaypoint.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeowaypointadd.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCBase.java | 30 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/connector/gc/Tile.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/files/FileList.java | 2 |
11 files changed, 35 insertions, 39 deletions
diff --git a/main/src/cgeo/geocaching/CacheCache.java b/main/src/cgeo/geocaching/CacheCache.java index 75fcfde..a2b5324 100644 --- a/main/src/cgeo/geocaching/CacheCache.java +++ b/main/src/cgeo/geocaching/CacheCache.java @@ -76,11 +76,7 @@ public class CacheCache { @Override public String toString() { - String result = ""; - for (String geocode : cachesCache.keySet()) { - result += geocode + " "; - } - return result; + return StringUtils.join(cachesCache.keySet(), ' '); } } diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index a341333..f78c65a 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -1228,7 +1228,7 @@ public class CacheDetailActivity extends AbstractActivity { boolean strikethru = attributeName.endsWith("_no"); // cut off _yes / _no if (attributeName.endsWith("_no") || attributeName.endsWith("_yes")) { - attributeName = attributeName.substring(0, attributeName.lastIndexOf("_")); + attributeName = attributeName.substring(0, attributeName.lastIndexOf('_')); } // check if another attribute icon fits in this row attributeRow.measure(0, 0); diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index aa8159a..77d0d78 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -204,7 +204,7 @@ public class cgBase { final Matcher matcherViewstates = GCConstants.PATTERN_VIEWSTATES.matcher(page); while (matcherViewstates.find()) { String sno = matcherViewstates.group(1); // number of viewstate - if ("".equals(sno)) { + if (sno.length() == 0) { no = 0; } else { @@ -232,7 +232,7 @@ public class cgBase { for (int i = 1; i < viewstates.length; i++) { params.put("__VIEWSTATE" + i, viewstates[i]); } - params.put("__VIEWSTATEFIELDCOUNT", viewstates.length + ""); + params.put("__VIEWSTATEFIELDCOUNT", String.valueOf(viewstates.length)); } } @@ -438,7 +438,7 @@ public class cgBase { final String recaptchaJs = cgBase.getResponseData(request("http://www.google.com/recaptcha/api/challenge", params, true)); if (StringUtils.isNotBlank(recaptchaJs)) { - recaptchaChallenge = BaseUtils.getMatch(recaptchaJs, GCConstants.PATTERN_SEARCH_RECAPTCHACHALLENGE, true, 1, recaptchaChallenge, true); + recaptchaChallenge = BaseUtils.getMatch(recaptchaJs, GCConstants.PATTERN_SEARCH_RECAPTCHACHALLENGE, true, 1, null, true); } } if (thread != null && StringUtils.isNotBlank(recaptchaChallenge)) { @@ -460,7 +460,7 @@ public class cgBase { page = page.substring(startPos); // cut on <table - startPos = page.indexOf(">"); + startPos = page.indexOf('>'); int endPos = page.indexOf("ctl00_ContentBody_UnitTxt"); if (startPos == -1 || endPos == -1) { Log.e(Settings.tag, "cgeoBase.parseSearch: ID \"ctl00_ContentBody_UnitTxt\" not found on page"); @@ -622,7 +622,7 @@ public class cgBase { for (int i = 1; i < searchResult.viewstates.length; i++) { params.put("__VIEWSTATE" + i, searchResult.viewstates[i]); } - params.put("__VIEWSTATEFIELDCOUNT", "" + searchResult.viewstates.length); + params.put("__VIEWSTATEFIELDCOUNT", String.valueOf(searchResult.viewstates.length)); } } for (String cid : cids) { diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index f1f231a..9be3a86 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -267,10 +267,10 @@ public class cgCache implements ICache { if (logCounts.size() == 0) { logCounts = other.logCounts; } - if (userModifiedCoords == false) { + if (!userModifiedCoords) { userModifiedCoords = other.userModifiedCoords; } - if (reliableLatLon == false) { + if (!reliableLatLon) { reliableLatLon = other.reliableLatLon; } if (zoomlevel == -1) { @@ -318,8 +318,8 @@ public class cgCache implements ICache { listId == other.listId && owner.equalsIgnoreCase(other.owner) && ownerReal.equalsIgnoreCase(other.ownerReal) && - (description != null ? description.equalsIgnoreCase(other.description) : description == other.description) && - (personalNote != null ? personalNote.equalsIgnoreCase(other.personalNote) : personalNote == other.personalNote) && + (description != null ? description.equalsIgnoreCase(other.description) : null == other.description) && + (personalNote != null ? personalNote.equalsIgnoreCase(other.personalNote) : null == other.personalNote) && shortdesc.equalsIgnoreCase(other.shortdesc) && latlon.equalsIgnoreCase(other.latlon) && location.equalsIgnoreCase(other.location) && diff --git a/main/src/cgeo/geocaching/cgGeo.java b/main/src/cgeo/geocaching/cgGeo.java index f9d6356..dcad1ba 100644 --- a/main/src/cgeo/geocaching/cgGeo.java +++ b/main/src/cgeo/geocaching/cgGeo.java @@ -67,7 +67,7 @@ public class cgGeo { } } - private abstract class AbstractLocationListener implements LocationListener { + private static abstract class AbstractLocationListener implements LocationListener { private final String locationProvider; protected AbstractLocationListener(String provider) { diff --git a/main/src/cgeo/geocaching/cgeoinit.java b/main/src/cgeo/geocaching/cgeoinit.java index ee48aec..1a694bd 100644 --- a/main/src/cgeo/geocaching/cgeoinit.java +++ b/main/src/cgeo/geocaching/cgeoinit.java @@ -41,8 +41,8 @@ import android.widget.Spinner; import android.widget.TextView; import java.io.File; +import java.util.Collection; import java.util.List; -import java.util.SortedMap; import java.util.concurrent.atomic.AtomicReference; public class cgeoinit extends AbstractActivity { @@ -92,7 +92,7 @@ public class cgeoinit extends AbstractActivity { } if (msg.what > 0) { - helpDialog(res.getString(R.string.init_sendToCgeo), res.getString(R.string.init_sendToCgeo_register_ok).replace("####", "" + msg.what)); + helpDialog(res.getString(R.string.init_sendToCgeo), res.getString(R.string.init_sendToCgeo_register_ok).replace("####", String.valueOf(msg.what))); } else { helpDialog(res.getString(R.string.init_sendToCgeo), res.getString(R.string.init_sendToCgeo_register_fail)); } @@ -546,9 +546,9 @@ public class cgeoinit extends AbstractActivity { webAuth.setOnClickListener(new webAuth()); // Map source settings - SortedMap<Integer, String> mapSources = MapProviderFactory.getMapSources(); + Collection<String> mapSourceValues = MapProviderFactory.getMapSources().values(); Spinner mapSourceSelector = (Spinner) findViewById(R.id.mapsource); - ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, mapSources.values().toArray(new String[] {})); + ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, mapSourceValues.toArray(new String[mapSourceValues.size()])); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mapSourceSelector.setAdapter(adapter); int mapsource = Settings.getMapSource(); diff --git a/main/src/cgeo/geocaching/cgeowaypoint.java b/main/src/cgeo/geocaching/cgeowaypoint.java index aac3005..8b0e3ff 100644 --- a/main/src/cgeo/geocaching/cgeowaypoint.java +++ b/main/src/cgeo/geocaching/cgeowaypoint.java @@ -299,7 +299,7 @@ public class cgeowaypoint extends AbstractActivity { } } - private class update implements UpdateLocationCallback { + private static class update implements UpdateLocationCallback { @Override public void updateLocation(cgGeo geo) { diff --git a/main/src/cgeo/geocaching/cgeowaypointadd.java b/main/src/cgeo/geocaching/cgeowaypointadd.java index 04d51a9..fa1d619 100644 --- a/main/src/cgeo/geocaching/cgeowaypointadd.java +++ b/main/src/cgeo/geocaching/cgeowaypointadd.java @@ -207,7 +207,7 @@ public class cgeowaypointadd extends AbstractActivity { Spinner waypointTypeSelector = (Spinner) findViewById(R.id.type); wpTypes = new ArrayList<WaypointType>(WaypointType.ALL_TYPES_EXCEPT_OWN.keySet()); - ArrayAdapter<WaypointType> wpAdapter = new ArrayAdapter<WaypointType>(this, android.R.layout.simple_spinner_item, wpTypes.toArray(new WaypointType[] {})); + ArrayAdapter<WaypointType> wpAdapter = new ArrayAdapter<WaypointType>(this, android.R.layout.simple_spinner_item, wpTypes.toArray(new WaypointType[wpTypes.size()])); wpAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); waypointTypeSelector.setAdapter(wpAdapter); diff --git a/main/src/cgeo/geocaching/connector/gc/GCBase.java b/main/src/cgeo/geocaching/connector/gc/GCBase.java index 7ddcbeb..04f7e58 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCBase.java +++ b/main/src/cgeo/geocaching/connector/gc/GCBase.java @@ -78,40 +78,40 @@ public class GCBase { List<Tile> tiles = getTilesForViewport(viewport); for (Tile tile : tiles) { - String url = - "?x=" + tile.getX() + // x tile - "&y=" + tile.getY() + // y tile - "&z=" + tile.getZoomlevel(); // zoom level + StringBuilder url = new StringBuilder(); + url.append("?x=").append(tile.getX()) // x tile + .append("&y=").append(tile.getY()) // y tile + .append("&z=").append(tile.getZoomlevel()); // zoom level if (tokens != null) { - url += "&k=" + tokens[0]; // user session - url += "&st=" + tokens[1]; // session token + url.append("&k=").append(tokens[0]); // user session + url.append("&st=").append(tokens[1]); // session token } - url += "&ep=1"; + url.append("&ep=1"); if (Settings.isExcludeMyCaches()) { - url += "&hf=1"; // hide found - url += "&hh=1"; // hide hidden + url.append("&hf=1").append("&hh=1"); // hide found, hide hidden } if (Settings.getCacheType() == CacheType.TRADITIONAL) { - url += "&ect=9,5,3,6,453,13,1304,137,11,4,8,1858"; // 2 = tradi 3 = multi 8 = mystery + url.append("&ect=9,5,3,6,453,13,1304,137,11,4,8,1858"); // 2 = tradi 3 = multi 8 = mystery } if (Settings.getCacheType() == CacheType.MULTI) { - url += "&ect=9,5,2,6,453,13,1304,137,11,4,8,1858"; + url.append("&ect=9,5,2,6,453,13,1304,137,11,4,8,1858"); } if (Settings.getCacheType() == CacheType.MYSTERY) { - url += "&ect=9,5,3,6,453,13,1304,137,11,4,2,1858"; + url.append("&ect=9,5,3,6,453,13,1304,137,11,4,2,1858"); } if (tile.getZoomlevel() != 14) { - url += "&_=" + String.valueOf(System.currentTimeMillis()); + url.append("&_=").append(String.valueOf(System.currentTimeMillis())); } // other types t.b.d + final String urlString = url.toString(); // The PNG must be request before ! Else the following request would return with 204 - No Content - Bitmap bitmap = cgBase.requestMapTile(GCConstants.URL_MAP_TILE + url, referer); + Bitmap bitmap = cgBase.requestMapTile(GCConstants.URL_MAP_TILE + urlString, referer); assert bitmap.getWidth() == Tile.TILE_SIZE : "Bitmap has wrong width"; assert bitmap.getHeight() == Tile.TILE_SIZE : "Bitmap has wrong height"; - String data = cgBase.requestMapInfo(GCConstants.URL_MAP_INFO + url, referer); + String data = cgBase.requestMapInfo(GCConstants.URL_MAP_INFO + urlString, referer); if (StringUtils.isEmpty(data)) { Log.e(Settings.tag, "GCBase.searchByViewport: No data from server for tile (" + tile.getX() + "/" + tile.getY() + ")"); } else { diff --git a/main/src/cgeo/geocaching/connector/gc/Tile.java b/main/src/cgeo/geocaching/connector/gc/Tile.java index e62debb..7c78373 100644 --- a/main/src/cgeo/geocaching/connector/gc/Tile.java +++ b/main/src/cgeo/geocaching/connector/gc/Tile.java @@ -104,6 +104,6 @@ public class Tile { @Override public String toString() { - return String.format("(%d/%d), zoom=%d", tileX, tileY, zoomlevel).toString(); + return String.format("(%d/%d), zoom=%d", tileX, tileY, zoomlevel); } } diff --git a/main/src/cgeo/geocaching/files/FileList.java b/main/src/cgeo/geocaching/files/FileList.java index 5a788c0..0c959b2 100644 --- a/main/src/cgeo/geocaching/files/FileList.java +++ b/main/src/cgeo/geocaching/files/FileList.java @@ -52,7 +52,7 @@ public abstract class FileList<T extends ArrayAdapter<File>> extends AbstractLis for (File f : getBaseFolders()) { String fName = f.getPath(); if (sb.length() > 0) { - sb.append("\n"); + sb.append('\n'); } sb.append(fName); } |