diff options
Diffstat (limited to 'main/src')
20 files changed, 73 insertions, 83 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 7bfab3b..103634e 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/SearchResult.java b/main/src/cgeo/geocaching/SearchResult.java index fba946a..edda547 100644 --- a/main/src/cgeo/geocaching/SearchResult.java +++ b/main/src/cgeo/geocaching/SearchResult.java @@ -140,7 +140,7 @@ public class SearchResult implements Parcelable { * @param cacheType * @return */ - public SearchResult filterSearchResults(final boolean excludeDisabled, final boolean excludeMine, final CacheType cacheType, final int listId) { + public SearchResult filterSearchResults(final boolean excludeDisabled, final boolean excludeMine, final CacheType cacheType) { SearchResult result = new SearchResult(this); result.geocodes.clear(); @@ -152,7 +152,6 @@ public class SearchResult implements Parcelable { (excludeMine && (cache.isOwn() || cache.isFound())) || (cacheType != CacheType.ALL && cacheType != cache.getType()); if (!excludeCache) { - cache.setListId(listId); result.addCache(cache); } } @@ -190,13 +189,12 @@ public class SearchResult implements Parcelable { } /** Add the cache geocodes to the search and store them in the CacheCache */ - public void addCaches(final Set<cgCache> caches, final int listId) { + public void addCaches(final Set<cgCache> caches) { if (CollectionUtils.isEmpty(caches)) { return; } for (final cgCache cache : caches) { - cache.setListId(listId); addCache(cache); } } diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index 69125d1..5b4e867 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)); } } @@ -413,7 +413,7 @@ public class cgBase { } } - private static SearchResult parseSearch(final cgSearchThread thread, final String url, final String pageContent, final boolean showCaptcha, final int listId) { + private static SearchResult parseSearch(final cgSearchThread thread, final String url, final String pageContent, final boolean showCaptcha) { if (StringUtils.isBlank(pageContent)) { Log.e(Settings.tag, "cgeoBase.parseSearch: No page given"); return null; @@ -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"); @@ -473,8 +473,7 @@ public class cgBase { final int rows_count = rows.length; for (int z = 1; z < rows_count; z++) { - cgCache cache = new cgCache(); - cache.setListId(listId); + final cgCache cache = new cgCache(); String row = rows[z]; // check for cache type presence @@ -623,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) { @@ -695,8 +694,8 @@ public class cgBase { return searchResult; } - public static SearchResult parseCache(final String page, final int listId, final CancellableHandler handler) { - final SearchResult searchResult = parseCacheFromText(page, listId, handler); + public static SearchResult parseCache(final String page, final CancellableHandler handler) { + final SearchResult searchResult = parseCacheFromText(page, handler); if (searchResult != null && !searchResult.getGeocodes().isEmpty()) { final cgCache cache = searchResult.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB); getExtraOnlineInfo(cache, page, handler); @@ -707,13 +706,12 @@ public class cgBase { return null; } // save full detailed caches - cache.setListId(StoredList.TEMPORARY_LIST_ID); cgeoapplication.getInstance().saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB)); } return searchResult; } - static SearchResult parseCacheFromText(final String page, final int listId, final CancellableHandler handler) { + static SearchResult parseCacheFromText(final String page, final CancellableHandler handler) { sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_details); if (StringUtils.isBlank(page)) { @@ -747,8 +745,6 @@ public class cgBase { cache.setFavorite(BaseUtils.matches(page, GCConstants.PATTERN_FAVORITE)); - cache.setListId(listId); - // cache geocode cache.setGeocode(BaseUtils.getMatch(page, GCConstants.PATTERN_GEOCODE, true, cache.getGeocode())); @@ -1636,7 +1632,7 @@ public class cgBase { params.put("tx", cacheType.guid); } - public static SearchResult searchByNextPage(cgSearchThread thread, final SearchResult search, int listId, boolean showCaptcha) { + public static SearchResult searchByNextPage(cgSearchThread thread, final SearchResult search, boolean showCaptcha) { if (search == null) { return search; } @@ -1681,7 +1677,7 @@ public class cgBase { return search; } - final SearchResult searchResult = parseSearch(thread, url, page, showCaptcha, listId); + final SearchResult searchResult = parseSearch(thread, url, page, showCaptcha); if (searchResult == null || CollectionUtils.isEmpty(searchResult.getGeocodes())) { Log.e(Settings.tag, "cgeoBase.searchByNextPage: No cache parsed"); return search; @@ -1712,10 +1708,10 @@ public class cgBase { // if we have no geocode, we can't dynamically select the handler, but must explicitly use GC if (geocode == null && guid != null) { - return GCConnector.getInstance().searchByGeocode(null, guid, app, listId, handler); + return GCConnector.getInstance().searchByGeocode(null, guid, app, handler); } - return ConnectorFactory.getConnector(geocode).searchByGeocode(geocode, guid, app, listId, handler); + return ConnectorFactory.getConnector(geocode).searchByGeocode(geocode, guid, app, handler); } public static SearchResult searchByStored(final Geopoint coords, final CacheType cacheType, final int list) { @@ -1732,7 +1728,7 @@ public class cgBase { * the parameters to add to the request URI * @return */ - private static SearchResult searchByAny(final cgSearchThread thread, final CacheType cacheType, final boolean my, final int listId, final boolean showCaptcha, final Parameters params) { + private static SearchResult searchByAny(final cgSearchThread thread, final CacheType cacheType, final boolean my, final boolean showCaptcha, final Parameters params) { insertCacheType(params, cacheType); final String uri = "http://www.geocaching.com/seek/nearest.aspx"; @@ -1744,35 +1740,35 @@ public class cgBase { return null; } - final SearchResult searchResult = parseSearch(thread, fullUri, page, showCaptcha, listId); + final SearchResult searchResult = parseSearch(thread, fullUri, page, showCaptcha); if (searchResult == null || CollectionUtils.isEmpty(searchResult.getGeocodes())) { Log.e(Settings.tag, "cgeoBase.searchByAny: No cache parsed"); return searchResult; } - final SearchResult search = searchResult.filterSearchResults(Settings.isExcludeDisabledCaches(), false, cacheType, listId); + final SearchResult search = searchResult.filterSearchResults(Settings.isExcludeDisabledCaches(), false, cacheType); getLoginStatus(page); return search; } - public static SearchResult searchByCoords(final cgSearchThread thread, final Geopoint coords, final CacheType cacheType, final int listId, final boolean showCaptcha) { + public static SearchResult searchByCoords(final cgSearchThread thread, final Geopoint coords, final CacheType cacheType, final boolean showCaptcha) { final Parameters params = new Parameters("lat", Double.toString(coords.getLatitude()), "lng", Double.toString(coords.getLongitude())); - return searchByAny(thread, cacheType, false, listId, showCaptcha, params); + return searchByAny(thread, cacheType, false, showCaptcha, params); } - public static SearchResult searchByKeyword(final cgSearchThread thread, final String keyword, final CacheType cacheType, final int listId, final boolean showCaptcha) { + public static SearchResult searchByKeyword(final cgSearchThread thread, final String keyword, final CacheType cacheType, final boolean showCaptcha) { if (StringUtils.isBlank(keyword)) { Log.e(Settings.tag, "cgeoBase.searchByKeyword: No keyword given"); return null; } final Parameters params = new Parameters("key", keyword); - return searchByAny(thread, cacheType, false, listId, showCaptcha, params); + return searchByAny(thread, cacheType, false, showCaptcha, params); } - public static SearchResult searchByUsername(final cgSearchThread thread, final String userName, final CacheType cacheType, final int listId, final boolean showCaptcha) { + public static SearchResult searchByUsername(final cgSearchThread thread, final String userName, final CacheType cacheType, final boolean showCaptcha) { if (StringUtils.isBlank(userName)) { Log.e(Settings.tag, "cgeoBase.searchByUsername: No user name given"); return null; @@ -1786,17 +1782,17 @@ public class cgBase { Log.i(Settings.tag, "cgBase.searchByUsername: Overriding users choice, downloading all caches."); } - return searchByAny(thread, cacheType, my, listId, showCaptcha, params); + return searchByAny(thread, cacheType, my, showCaptcha, params); } - public static SearchResult searchByOwner(final cgSearchThread thread, final String userName, final CacheType cacheType, final int listId, final boolean showCaptcha) { + public static SearchResult searchByOwner(final cgSearchThread thread, final String userName, final CacheType cacheType, final boolean showCaptcha) { if (StringUtils.isBlank(userName)) { Log.e(Settings.tag, "cgeoBase.searchByOwner: No user name given"); return null; } final Parameters params = new Parameters("u", userName); - return searchByAny(thread, cacheType, false, listId, showCaptcha, params); + return searchByAny(thread, cacheType, false, showCaptcha, params); } /** Request .png image for a tile. */ 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/cgCoord.java b/main/src/cgeo/geocaching/cgCoord.java index 0c5b5b5..236b8f5 100644 --- a/main/src/cgeo/geocaching/cgCoord.java +++ b/main/src/cgeo/geocaching/cgCoord.java @@ -44,7 +44,7 @@ public class cgCoord implements IBasicCache, IWaypoint { id = waypoint.getId(); disabled = false; found = false; - geocode = ""; + geocode = waypoint.getGeocode(); coords = waypoint.getCoords(); name = waypoint.getName(); coordType = "waypoint"; 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/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java index 120bc59..9defae4 100644 --- a/main/src/cgeo/geocaching/cgeocaches.java +++ b/main/src/cgeo/geocaching/cgeocaches.java @@ -1779,7 +1779,7 @@ public class cgeocaches extends AbstractListActivity { @Override public void run() { - search = cgBase.searchByNextPage(this, search, 0, Settings.isShowCaptcha()); + search = cgBase.searchByNextPage(this, search, Settings.isShowCaptcha()); handler.sendMessage(new Message()); } @@ -1806,7 +1806,7 @@ public class cgeocaches extends AbstractListActivity { @Override public void run() { - search = cgBase.searchByCoords(this, coords, cacheType, StoredList.TEMPORARY_LIST_ID, Settings.isShowCaptcha()); + search = cgBase.searchByCoords(this, coords, cacheType, Settings.isShowCaptcha()); handler.sendMessage(new Message()); } @@ -1833,7 +1833,7 @@ public class cgeocaches extends AbstractListActivity { @Override public void run() { - search = cgBase.searchByKeyword(this, keyword, cacheType, 0, Settings.isShowCaptcha()); + search = cgBase.searchByKeyword(this, keyword, cacheType, Settings.isShowCaptcha()); handler.sendMessage(new Message()); } } @@ -1859,7 +1859,7 @@ public class cgeocaches extends AbstractListActivity { @Override public void run() { - search = cgBase.searchByUsername(this, username, cacheType, 0, Settings.isShowCaptcha()); + search = cgBase.searchByUsername(this, username, cacheType, Settings.isShowCaptcha()); handler.sendMessage(new Message()); } } @@ -1891,7 +1891,7 @@ public class cgeocaches extends AbstractListActivity { params.put("cacheType", cacheType.id); } - search = cgBase.searchByOwner(this, username, cacheType, 0, Settings.isShowCaptcha()); + search = cgBase.searchByOwner(this, username, cacheType, Settings.isShowCaptcha()); handler.sendMessage(new Message()); } 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/AbstractConnector.java b/main/src/cgeo/geocaching/connector/AbstractConnector.java index ceaad5e..32babe7 100644 --- a/main/src/cgeo/geocaching/connector/AbstractConnector.java +++ b/main/src/cgeo/geocaching/connector/AbstractConnector.java @@ -50,7 +50,7 @@ public abstract class AbstractConnector implements IConnector { } @Override - public SearchResult searchByGeocode(String geocode, String guid, cgeoapplication app, int listId, CancellableHandler handler) { + public SearchResult searchByGeocode(String geocode, String guid, cgeoapplication app, CancellableHandler handler) { return null; } diff --git a/main/src/cgeo/geocaching/connector/GCConnector.java b/main/src/cgeo/geocaching/connector/GCConnector.java index 6b44f82..74dc7f5 100644 --- a/main/src/cgeo/geocaching/connector/GCConnector.java +++ b/main/src/cgeo/geocaching/connector/GCConnector.java @@ -84,7 +84,7 @@ public class GCConnector extends AbstractConnector { } @Override - public SearchResult searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final int listId, final CancellableHandler handler) { + public SearchResult searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final CancellableHandler handler) { if (app == null) { Log.e(Settings.tag, "cgeoBase.searchByGeocode: No application found"); @@ -123,14 +123,14 @@ public class GCConnector extends AbstractConnector { return search; } - final SearchResult searchResult = cgBase.parseCache(page, listId, handler); + final SearchResult searchResult = cgBase.parseCache(page, handler); if (searchResult == null || CollectionUtils.isEmpty(searchResult.getGeocodes())) { Log.e(Settings.tag, "cgeoBase.searchByGeocode: No cache parsed"); return searchResult; } - SearchResult search = searchResult.filterSearchResults(false, false, Settings.getCacheType(), listId); + SearchResult search = searchResult.filterSearchResults(false, false, Settings.getCacheType()); return search; } diff --git a/main/src/cgeo/geocaching/connector/IConnector.java b/main/src/cgeo/geocaching/connector/IConnector.java index bc772c9..1b84ecd 100644 --- a/main/src/cgeo/geocaching/connector/IConnector.java +++ b/main/src/cgeo/geocaching/connector/IConnector.java @@ -76,7 +76,7 @@ public interface IConnector { */ public boolean supportsCachesAround(); - public SearchResult searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final int listId, final CancellableHandler handler); + public SearchResult searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final CancellableHandler handler); /** * search caches by coordinate. must be implemented if {@link supportsCachesAround} returns <code>true</true> diff --git a/main/src/cgeo/geocaching/connector/gc/GCBase.java b/main/src/cgeo/geocaching/connector/gc/GCBase.java index 4580542..04f7e58 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCBase.java +++ b/main/src/cgeo/geocaching/connector/gc/GCBase.java @@ -3,7 +3,6 @@ package cgeo.geocaching.connector.gc; import cgeo.geocaching.GCConstants; import cgeo.geocaching.SearchResult; import cgeo.geocaching.Settings; -import cgeo.geocaching.StoredList; import cgeo.geocaching.cgBase; import cgeo.geocaching.cgCache; import cgeo.geocaching.enumerations.CacheType; @@ -79,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 { @@ -126,7 +125,7 @@ public class GCBase { } } - SearchResult search = cgBase.searchByCoords(null, viewport.getCenter(), Settings.getCacheType(), StoredList.TEMPORARY_LIST_ID, false); + SearchResult search = cgBase.searchByCoords(null, viewport.getCenter(), Settings.getCacheType(), false); if (search != null) { searchResult.addGeocodes(search.getGeocodes()); } 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/connector/opencaching/ApiOpenCachingConnector.java b/main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java index e72a1e3..8ed6acd 100644 --- a/main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java +++ b/main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java @@ -33,7 +33,7 @@ public class ApiOpenCachingConnector extends OpenCachingConnector { } @Override - public SearchResult searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final int listId, final CancellableHandler handler) { + public SearchResult searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final CancellableHandler handler) { final cgCache cache = OkapiClient.getCache(geocode); if (cache == null) { return null; @@ -41,7 +41,7 @@ public class ApiOpenCachingConnector extends OpenCachingConnector { final SearchResult searchResult = new SearchResult(); searchResult.addCache(cache); - final SearchResult search = searchResult.filterSearchResults(false, false, Settings.getCacheType(), listId); + final SearchResult search = searchResult.filterSearchResults(false, false, Settings.getCacheType()); return search; } } 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); } diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index fb70d13..0310dc3 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -442,7 +442,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto if (!CollectionUtils.isEmpty(dirtyCaches)) { for (String geocode : dirtyCaches) { - cgCache cache = app.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); + cgCache cache = app.loadCache(geocode, LoadFlags.LOAD_WAYPOINTS); // remove to update the cache caches.remove(cache); caches.add(cache); diff --git a/main/src/cgeo/geocaching/maps/CachesOverlay.java b/main/src/cgeo/geocaching/maps/CachesOverlay.java index 42c121a..0a952bc 100644 --- a/main/src/cgeo/geocaching/maps/CachesOverlay.java +++ b/main/src/cgeo/geocaching/maps/CachesOverlay.java @@ -214,6 +214,7 @@ public class CachesOverlay extends AbstractItemizedOverlay { popupIntent.putExtra("waypoint", coordinate.getId()); + CGeoMap.markCacheAsDirty(coordinate.getGeocode()); context.startActivity(popupIntent); } else { waitDialog.dismiss(); |
