diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2011-08-31 21:30:09 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2011-08-31 21:30:09 +0200 |
| commit | c503f6b40d195595a73729bd0a6a0f9680d70656 (patch) | |
| tree | 701a86017d0ae011e7e700d008f070aad96b8c4b /src | |
| parent | 384a3bf7c0102f4fd9f593d089c7d41d79331aca (diff) | |
| download | cgeo-c503f6b40d195595a73729bd0a6a0f9680d70656.zip cgeo-c503f6b40d195595a73729bd0a6a0f9680d70656.tar.gz cgeo-c503f6b40d195595a73729bd0a6a0f9680d70656.tar.bz2 | |
code cleanup: protect abstract class constructors, rewrite long constant
literals, optimize string concatenation, move loop variables, remove
return value parentheses, remove duplicate semicolons, fulfill equals
contract
If you get merge conflicts afterwards, you may overwrite any changes of
this commit.
Diffstat (limited to 'src')
26 files changed, 138 insertions, 153 deletions
diff --git a/src/cgeo/geocaching/LogTemplateProvider.java b/src/cgeo/geocaching/LogTemplateProvider.java index 210f863..08931a7 100644 --- a/src/cgeo/geocaching/LogTemplateProvider.java +++ b/src/cgeo/geocaching/LogTemplateProvider.java @@ -16,7 +16,7 @@ public class LogTemplateProvider { private String template;
private int resourceId;
- public LogTemplate(String template, int resourceId) {
+ protected LogTemplate(String template, int resourceId) {
this.template = template;
this.resourceId = resourceId;
}
diff --git a/src/cgeo/geocaching/StaticMapsProvider.java b/src/cgeo/geocaching/StaticMapsProvider.java index b649f7b..927a99c 100644 --- a/src/cgeo/geocaching/StaticMapsProvider.java +++ b/src/cgeo/geocaching/StaticMapsProvider.java @@ -28,7 +28,7 @@ public class StaticMapsProvider { private static void downloadMapsInThread(final cgCache cache, String latlonMap, int edge, String waypoints) { createStorageDirectory(cache); - + downloadMap(cache, 20, "satellite", 1, latlonMap, edge, waypoints); downloadMap(cache, 18, "satellite", 2, latlonMap, edge, waypoints); downloadMap(cache, 16, "roadmap", 3, latlonMap, edge, waypoints); @@ -54,7 +54,7 @@ public class StaticMapsProvider { private static void downloadMap(cgCache cache, int zoom, String mapType, int level, String latlonMap, int edge, String waypoints) { String mapUrl = "http://maps.google.com/maps/api/staticmap?center=" + latlonMap; String markerUrl = getMarkerUrl(cache); - + String url = mapUrl + "&zoom=" + zoom + "&size=" + edge + "x" + edge + "&maptype=" + mapType + "&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints + "&sensor=false"; final String fileName = getStaticMapsDirectory(cache) + "/map_" + level; @@ -125,7 +125,7 @@ public class StaticMapsProvider { || cache.longitude == null || cache.geocode == null || cache.geocode.length() == 0) { return; } - + final String latlonMap = String.format((Locale) null, "%.6f", cache.latitude) + "," + String.format((Locale) null, "%.6f", cache.longitude); final Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); final int maxWidth = display.getWidth() - 25; @@ -144,11 +144,13 @@ public class StaticMapsProvider { continue; } - waypoints.append("&markers=icon%3A" + MARKERS_URL + "marker_waypoint_"); + waypoints.append("&markers=icon%3A"); + waypoints.append(MARKERS_URL); + waypoints.append("marker_waypoint_"); waypoints.append(waypoint.type); waypoints.append(".png%7C"); waypoints.append(String.format((Locale) null, "%.6f", waypoint.latitude)); - waypoints.append(","); + waypoints.append(','); waypoints.append(String.format((Locale) null, "%.6f", waypoint.longitude)); } } @@ -156,7 +158,7 @@ public class StaticMapsProvider { // download map images in separate background thread for higher performance downloadMaps(cache, latlonMap, edge, waypoints.toString()); } - + private static void downloadMaps(final cgCache cache, final String latlonMap, final int edge, final String waypoints) { Thread staticMapsThread = new Thread("getting static map") {@Override diff --git a/src/cgeo/geocaching/activity/AbstractActivity.java b/src/cgeo/geocaching/activity/AbstractActivity.java index 825cc9b..96e3e6b 100644 --- a/src/cgeo/geocaching/activity/AbstractActivity.java +++ b/src/cgeo/geocaching/activity/AbstractActivity.java @@ -21,11 +21,11 @@ public abstract class AbstractActivity extends Activity implements IAbstractActi protected cgBase base = null; protected SharedPreferences prefs = null; - public AbstractActivity() { + protected AbstractActivity() { this(null); } - public AbstractActivity(final String helpTopic) { + protected AbstractActivity(final String helpTopic) { this.helpTopic = helpTopic; } @@ -76,7 +76,7 @@ public abstract class AbstractActivity extends Activity implements IAbstractActi final public cgSettings getSettings() { return settings; } - + public void addVisitMenu(Menu menu, cgCache cache) { ActivityMixin.addVisitMenu(this, menu, cache); } diff --git a/src/cgeo/geocaching/activity/AbstractListActivity.java b/src/cgeo/geocaching/activity/AbstractListActivity.java index 9cb3284..873a717 100644 --- a/src/cgeo/geocaching/activity/AbstractListActivity.java +++ b/src/cgeo/geocaching/activity/AbstractListActivity.java @@ -22,11 +22,11 @@ public abstract class AbstractListActivity extends ListActivity implements protected cgBase base = null; protected SharedPreferences prefs = null; - public AbstractListActivity() { + protected AbstractListActivity() { this(null); } - public AbstractListActivity(final String helpTopic) { + protected AbstractListActivity(final String helpTopic) { this.helpTopic = helpTopic; } @@ -73,7 +73,7 @@ public abstract class AbstractListActivity extends ListActivity implements final public void setTitle(final String title) { ActivityMixin.setTitle(this, title); } - + final public cgSettings getSettings() { return settings; } diff --git a/src/cgeo/geocaching/apps/AbstractApp.java b/src/cgeo/geocaching/apps/AbstractApp.java index ba8333c..007a4f6 100644 --- a/src/cgeo/geocaching/apps/AbstractApp.java +++ b/src/cgeo/geocaching/apps/AbstractApp.java @@ -54,7 +54,7 @@ public abstract class AbstractApp implements App { final List<ResolveInfo> list = packageManager.queryIntentActivities( intent, PackageManager.MATCH_DEFAULT_ONLY); - return (list.size() > 0); + return list.size() > 0; } @Override diff --git a/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java b/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java index 54d7709..5fd8542 100644 --- a/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java +++ b/src/cgeo/geocaching/apps/cache/AbstractGeneralApp.java @@ -7,7 +7,7 @@ import cgeo.geocaching.apps.AbstractApp; abstract class AbstractGeneralApp extends AbstractApp implements GeneralApp { - AbstractGeneralApp(String name, String packageName) { + protected AbstractGeneralApp(String name, String packageName) { super(name, null); this.packageName = packageName; } diff --git a/src/cgeo/geocaching/apps/cache/navi/AbstractNavigationApp.java b/src/cgeo/geocaching/apps/cache/navi/AbstractNavigationApp.java index 5ae8f44..f14c053 100644 --- a/src/cgeo/geocaching/apps/cache/navi/AbstractNavigationApp.java +++ b/src/cgeo/geocaching/apps/cache/navi/AbstractNavigationApp.java @@ -4,11 +4,11 @@ import cgeo.geocaching.apps.AbstractApp; abstract class AbstractNavigationApp extends AbstractApp implements NavigationApp { - AbstractNavigationApp(String name, String intent, String packageName) { + protected AbstractNavigationApp(String name, String intent, String packageName) { super(name, intent, packageName); } - AbstractNavigationApp(String name, String intent) { + protected AbstractNavigationApp(String name, String intent) { super(name, intent); } diff --git a/src/cgeo/geocaching/cgBase.java b/src/cgeo/geocaching/cgBase.java index 79e67b5..057dd3f 100644 --- a/src/cgeo/geocaching/cgBase.java +++ b/src/cgeo/geocaching/cgBase.java @@ -422,10 +422,10 @@ public class cgBase { String[] viewstates = new String[count]; // Get the viewstates + int no; final Matcher matcherViewstates = patternViewstates.matcher(page); while (matcherViewstates.find()) { String sno = matcherViewstates.group(1); // number of viewstate - int no; if ("".equals(sno)) no = 0; else @@ -585,13 +585,13 @@ public class cgBase { // on every page final Matcher matcherLogged2In = patternLogged2In.matcher(page); - while (matcherLogged2In.find()) { + if (matcherLogged2In.find()) { return true; } // after login final Matcher matcherLoggedIn = patternLoggedIn.matcher(page); - while (matcherLoggedIn.find()) { + if (matcherLoggedIn.find()) { return true; } @@ -914,9 +914,7 @@ public class cgBase { final String host = "www.geocaching.com"; final String path = "/seek/nearest.aspx"; final StringBuilder params = new StringBuilder(); - params.append("__EVENTTARGET="); - params.append("&"); - params.append("__EVENTARGUMENT="); + params.append("__EVENTTARGET=&__EVENTARGUMENT="); if (caches.viewstates != null && caches.viewstates.length > 0) { params.append("&__VIEWSTATE="); params.append(urlencode_rfc3986(caches.viewstates[0])); @@ -929,21 +927,17 @@ public class cgBase { } } for (String cid : cids) { - params.append("&"); - params.append("CID="); + params.append("&CID="); params.append(urlencode_rfc3986(cid)); } if (recaptchaChallenge != null && recaptchaText != null && recaptchaText.length() > 0) { - params.append("&"); - params.append("recaptcha_challenge_field="); + params.append("&recaptcha_challenge_field="); params.append(urlencode_rfc3986(recaptchaChallenge)); - params.append("&"); - params.append("recaptcha_response_field="); + params.append("&recaptcha_response_field="); params.append(urlencode_rfc3986(recaptchaText)); } - params.append("&"); - params.append("ctl00%24ContentBody%24uxDownloadLoc=Download+Waypoints"); + params.append("&ctl00%24ContentBody%24uxDownloadLoc=Download+Waypoints"); final String coordinates = request(false, host, path, "POST", params.toString(), 0, true).getData(); @@ -1903,7 +1897,7 @@ public class cgBase { } input = input.trim(); - + if (null != settings //&& null != settings.getGcCustomDate() && gcCustomDateFormats.containsKey(settings.getGcCustomDate())) @@ -1926,17 +1920,17 @@ public class cgBase { throw new ParseException("No matching pattern", 0); } - + public void detectGcCustomDate() { final String host = "www.geocaching.com"; final String path = "/account/ManagePreferences.aspx"; - + final String result = request(false, host, path, "GET", null, false, false, false).getData(); - + final Pattern pattern = Pattern.compile("<option selected=\"selected\" value=\"([ /Mdy-]+)\">", Pattern.CASE_INSENSITIVE); final Matcher matcher = pattern.matcher(result); - + if (matcher.find()) { settings.setGcCustomDate(matcher.group(1)); @@ -2328,7 +2322,7 @@ public class cgBase { while (matcherLogs.find()) { final cgLog logDone = new cgLog(); - + if (logTypes.containsKey(matcherLogs.group(1).toLowerCase())) { logDone.type = logTypes.get(matcherLogs.group(1).toLowerCase()); @@ -2339,15 +2333,15 @@ public class cgBase { } logDone.author = Html.fromHtml(matcherLogs.group(3)).toString(); - + try { logDone.date = parseGcCustomDate(matcherLogs.group(2)).getTime(); } catch (ParseException e) {} - + logDone.log = matcherLogs.group(6).trim(); - + if (matcherLogs.group(4) != null && matcherLogs.group(5) != null) { logDone.cacheGuid = matcherLogs.group(4); @@ -3605,7 +3599,7 @@ public class cgBase { if (c > 300) { logUpdated.append("&#"); logUpdated.append(Integer.toString((int) c)); - logUpdated.append(";"); + logUpdated.append(';'); } else { logUpdated.append(c); } @@ -3645,7 +3639,7 @@ public class cgBase { if (tb.action > 0) { hdnSelected.append(action); - hdnSelected.append(","); + hdnSelected.append(','); } } @@ -3706,7 +3700,7 @@ public class cgBase { params.put("ctl00$ContentBody$LogBookPanel1$uxTrackables$repTravelBugs$ctl" + ctl + "$ddlAction", action); if (tb.action > 0) { hdnSelected.append(action); - hdnSelected.append(","); + hdnSelected.append(','); } } @@ -5022,7 +5016,7 @@ public class cgBase { } return out; } - + public static int getCacheIcon(final String type) { fillIconsMap(); Integer iconId = gcIcons.get("type_" + type); diff --git a/src/cgeo/geocaching/cgCache.java b/src/cgeo/geocaching/cgCache.java index ee212e1..1fed844 100644 --- a/src/cgeo/geocaching/cgCache.java +++ b/src/cgeo/geocaching/cgCache.java @@ -275,7 +275,7 @@ public class cgCache { } public boolean isEventCache() { - return ("event".equalsIgnoreCase(type) || "mega".equalsIgnoreCase(type) || "cito".equalsIgnoreCase(type)); + return "event".equalsIgnoreCase(type) || "mega".equalsIgnoreCase(type) || "cito".equalsIgnoreCase(type); } public boolean logVisit(IAbstractActivity fromActivity) { diff --git a/src/cgeo/geocaching/cgCacheListAdapter.java b/src/cgeo/geocaching/cgCacheListAdapter.java index 57c6e5f..8ef1e8f 100644 --- a/src/cgeo/geocaching/cgCacheListAdapter.java +++ b/src/cgeo/geocaching/cgCacheListAdapter.java @@ -51,7 +51,7 @@ public class cgCacheListAdapter extends ArrayAdapter<cgCache> { private Double latitude = null; private Double longitude = null; private Double azimuth = Double.valueOf(0); - private long lastSort = 0l; + private long lastSort = 0L; private boolean sort = true; private int checked = 0; private boolean selectMode = false; diff --git a/src/cgeo/geocaching/cgData.java b/src/cgeo/geocaching/cgData.java index a8c6eda..34d15d3 100644 --- a/src/cgeo/geocaching/cgData.java +++ b/src/cgeo/geocaching/cgData.java @@ -1251,7 +1251,7 @@ public class cgData { if (statusOk == false) { cache.detailed = false; - cache.detailedUpdate = 0l; + cache.detailedUpdate = 0L; } init(); @@ -1604,7 +1604,7 @@ public class cgData { if (oneTrackable.released != null) { values.put("released", oneTrackable.released.getTime()); } else { - values.put("released", 0l); + values.put("released", 0L); } values.put("goal", oneTrackable.goal); values.put("description", oneTrackable.details); @@ -1638,9 +1638,9 @@ public class cgData { if (all.length() > 0) { all.append(", "); } - all.append("\""); + all.append('"'); all.append((String) one); - all.append("\""); + all.append('"'); } if (where.length() > 0) { @@ -1648,7 +1648,7 @@ public class cgData { } where.append("geocode in ("); where.append(all); - where.append(")"); + where.append(')'); } cursor = databaseRO.query( @@ -1739,9 +1739,9 @@ public class cgData { if (all.length() > 0) { all.append(", "); } - all.append("\""); + all.append('"'); all.append((String) one); - all.append("\""); + all.append('"'); } if (where.length() > 0) { @@ -1749,16 +1749,16 @@ public class cgData { } where.append("geocode in ("); where.append(all); - where.append(")"); + 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('"'); all.append((String) one); - all.append("\""); + all.append('"'); } if (where.length() > 0) { @@ -1766,7 +1766,7 @@ public class cgData { } where.append("guid in ("); where.append(all); - where.append(")"); + where.append(')'); } else { return caches; } @@ -1793,8 +1793,7 @@ public class cgData { if (where.length() > 0) { where.append(" and "); } - where.append("("); - where.append("latitude >= "); + where.append("(latitude >= "); where.append(String.format((Locale) null, "%.6f", latMin)); where.append(" and latitude <= "); where.append(String.format((Locale) null, "%.6f", latMax)); @@ -1802,7 +1801,7 @@ public class cgData { where.append(String.format((Locale) null, "%.6f", lonMin)); where.append(" and longitude <= "); where.append(String.format((Locale) null, "%.6f", lonMax)); - where.append(")"); + where.append(')'); } cursor = databaseRO.query( @@ -1888,13 +1887,13 @@ public class cgData { cache.rating = (Float) cursor.getFloat(cursor.getColumnIndex("rating")); cache.votes = (Integer) cursor.getInt(cursor.getColumnIndex("votes")); cache.myVote = (Float) cursor.getFloat(cursor.getColumnIndex("myvote")); - cache.disabled = cursor.getLong(cursor.getColumnIndex("disabled")) == 1l; - cache.archived = cursor.getLong(cursor.getColumnIndex("archived")) == 1l; - cache.members = cursor.getLong(cursor.getColumnIndex("members")) == 1l; - cache.found = cursor.getLong(cursor.getColumnIndex("found")) == 1l; - cache.favourite = cursor.getLong(cursor.getColumnIndex("favourite")) == 1l; + cache.disabled = cursor.getLong(cursor.getColumnIndex("disabled")) == 1L; + cache.archived = cursor.getLong(cursor.getColumnIndex("archived")) == 1L; + cache.members = cursor.getLong(cursor.getColumnIndex("members")) == 1L; + cache.found = cursor.getLong(cursor.getColumnIndex("found")) == 1L; + cache.favourite = cursor.getLong(cursor.getColumnIndex("favourite")) == 1L; cache.inventoryItems = (Integer) cursor.getInt(cursor.getColumnIndex("inventoryunknown")); - cache.onWatchlist = cursor.getLong(cursor.getColumnIndex("onWatchlist")) == 1l; + cache.onWatchlist = cursor.getLong(cursor.getColumnIndex("onWatchlist")) == 1L; if (loadA) { ArrayList<String> attributes = loadAttributes(cache.geocode); @@ -2480,7 +2479,7 @@ public class cgData { if (cachetype != null) { specifySql.append(" and type = \""); specifySql.append(cachetype); - specifySql.append("\""); + specifySql.append('"'); } try { @@ -2530,7 +2529,7 @@ public class cgData { if (cachetype != null) { specifySql.append(" and type = \""); specifySql.append(cachetype); - specifySql.append("\""); + specifySql.append('"'); } try { @@ -2614,7 +2613,7 @@ public class cgData { if (cachetype != null) { where.append(" and type = \""); where.append(cachetype); - where.append("\""); + where.append('"'); } // offline caches only @@ -2664,7 +2663,7 @@ public class cgData { // cachetype limitation if (cachetype != null) { where.append(cachetype); - where.append("\""); + where.append('"'); } // offline caches only diff --git a/src/cgeo/geocaching/cgDestination.java b/src/cgeo/geocaching/cgDestination.java index eb82889..0a2a493 100644 --- a/src/cgeo/geocaching/cgDestination.java +++ b/src/cgeo/geocaching/cgDestination.java @@ -1,13 +1,13 @@ package cgeo.geocaching; public class cgDestination { - + private long id; - + private long date; - + private double latitude; - + private double longitude; public cgDestination() { @@ -63,8 +63,9 @@ public class cgDestination { return true; if (obj == null) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof cgDestination)) { return false; + } cgDestination other = (cgDestination) obj; if (Double.doubleToLongBits(latitude) != Double .doubleToLongBits(other.latitude)) @@ -83,5 +84,5 @@ public class cgDestination { this.id = id; } - + } diff --git a/src/cgeo/geocaching/cgGeo.java b/src/cgeo/geocaching/cgGeo.java index 4ae2e32..8a191dd 100644 --- a/src/cgeo/geocaching/cgGeo.java +++ b/src/cgeo/geocaching/cgGeo.java @@ -30,7 +30,7 @@ public class cgGeo { private Integer distance = 0; private Location locGps = null; private Location locNet = null; - private long locGpsLast = 0l; + private long locGpsLast = 0L; private boolean g4cRunning = false; private Double lastGo4cacheLat = null; private Double lastGo4cacheLon = null; diff --git a/src/cgeo/geocaching/cgeo.java b/src/cgeo/geocaching/cgeo.java index df167fb..9f87c5b 100644 --- a/src/cgeo/geocaching/cgeo.java +++ b/src/cgeo/geocaching/cgeo.java @@ -250,7 +250,7 @@ public class cgeo extends AbstractActivity { final List<ResolveInfo> list = packageManager.queryIntentActivities( new Intent(intent), PackageManager.MATCH_DEFAULT_ONLY); - return (list.size() > 0); + return list.size() > 0; } @Override diff --git a/src/cgeo/geocaching/cgeoaddresses.java b/src/cgeo/geocaching/cgeoaddresses.java index a5e7f37..797c018 100644 --- a/src/cgeo/geocaching/cgeoaddresses.java +++ b/src/cgeo/geocaching/cgeoaddresses.java @@ -54,7 +54,7 @@ public class cgeoaddresses extends AbstractActivity { while (address.getAddressLine(index) != null) { if (allAdd.length() > 0) { - allAdd.append("\n"); + allAdd.append('\n'); } if (allAddLine.length() > 0) { allAddLine.append("; "); diff --git a/src/cgeo/geocaching/cgeoauth.java b/src/cgeo/geocaching/cgeoauth.java index 0343adf..1c2e8bb 100644 --- a/src/cgeo/geocaching/cgeoauth.java +++ b/src/cgeo/geocaching/cgeoauth.java @@ -170,7 +170,7 @@ public class cgeoauth extends AbstractActivity { while ((lineOne = br.readLine()) != null) { sb.append(lineOne); - sb.append("\n"); + sb.append('\n'); } code = connection.getResponseCode(); @@ -275,7 +275,7 @@ public class cgeoauth extends AbstractActivity { while ((lineOne = br.readLine()) != null) { sb.append(lineOne); - sb.append("\n"); + sb.append('\n'); } code = connection.getResponseCode(); diff --git a/src/cgeo/geocaching/cgeocaches.java b/src/cgeo/geocaching/cgeocaches.java index 642336d..ddc383e 100644 --- a/src/cgeo/geocaching/cgeocaches.java +++ b/src/cgeo/geocaching/cgeocaches.java @@ -154,7 +154,7 @@ public class cgeocaches extends AbstractListActivity { private String title = ""; private int detailTotal = 0; private int detailProgress = 0; - private long detailProgressTime = 0l; + private long detailProgressTime = 0L; private geocachesLoadDetails threadD = null; private geocachesLoadFromWeb threadW = null; private geocachesDropDetails threadR = null; @@ -1943,7 +1943,7 @@ public class cgeocaches extends AbstractListActivity { private int reason = 1; private volatile boolean needToStop = false; private int checked = 0; - private long last = 0l; + private long last = 0L; public geocachesLoadDetails(Handler handlerIn, int reasonIn) { setPriority(Thread.MIN_PRIORITY); @@ -2280,9 +2280,9 @@ public class cgeocaches extends AbstractListActivity { if (null != logTypes.get(log.type)) { fieldNoteBuffer.append(cache.geocode) - .append(",") + .append(',') .append(fieldNoteDateFormat.format(new Date(log.date))) - .append(",") + .append(',') .append(logTypes.get(log.type)) .append(",\"") .append(log.log.replaceAll("\"", "'")) diff --git a/src/cgeo/geocaching/cgeodetail.java b/src/cgeo/geocaching/cgeodetail.java index 48b6430..90d02f5 100644 --- a/src/cgeo/geocaching/cgeodetail.java +++ b/src/cgeo/geocaching/cgeodetail.java @@ -858,7 +858,7 @@ public class cgeodetail extends AbstractActivity { StringBuilder inventoryString = new StringBuilder(); for (cgTrackable inventoryItem : cache.inventory) { if (inventoryString.length() > 0) { - inventoryString.append("\n"); + inventoryString.append('\n'); } // avoid HTML parsing where possible if (inventoryItem.name.indexOf('<') >= 0 || inventoryItem.name.indexOf('&') >= 0 ) { @@ -1975,7 +1975,7 @@ public class cgeodetail extends AbstractActivity { if (noAttributeIconsFound) { return; } - + // toggle if (attributesShowAsIcons) { showAttributeDescriptions(attribBox); @@ -2013,7 +2013,7 @@ public class cgeodetail extends AbstractActivity { // dynamically search icon of the attribute Drawable d = null; - int id = res.getIdentifier("attribute_" + attributeName, "drawable", + int id = res.getIdentifier("attribute_" + attributeName, "drawable", base.context.getPackageName()); if (id > 0) { noAttributeIconsFound = false; @@ -2058,7 +2058,7 @@ public class cgeodetail extends AbstractActivity { attribute = cache.attributes.get(i); // dynamically search for a translation of the attribute - int id = res.getIdentifier("attribute_" + attribute, "string", + int id = res.getIdentifier("attribute_" + attribute, "string", base.context.getPackageName()); if (id > 0) { String translated = res.getString(id); @@ -2069,7 +2069,7 @@ public class cgeodetail extends AbstractActivity { if (buffer.length() > 0) buffer.append('\n'); buffer.append(attribute); } - + if (noAttributeIconsFound) buffer.append("\n\n").append(res.getString(R.string.cache_attributes_no_icons)); diff --git a/src/cgeo/geocaching/files/FileList.java b/src/cgeo/geocaching/files/FileList.java index 67e89a0..eae1e4d 100644 --- a/src/cgeo/geocaching/files/FileList.java +++ b/src/cgeo/geocaching/files/FileList.java @@ -127,7 +127,7 @@ public abstract class FileList<T extends ArrayAdapter<File>> extends AbstractLis * @return The folder to start the recursive search in */ protected abstract String[] getBaseFolders(); - + /** * Triggers the deriving class to set the title */ @@ -221,18 +221,18 @@ public abstract class FileList<T extends ArrayAdapter<File>> extends AbstractLis return; } - - public FileList(final String extension) { + + protected FileList(final String extension) { setExtensions(new String[] {extension}); } - public FileList(final String[] extensions) { + protected FileList(final String[] extensions) { setExtensions(extensions); } private void setExtensions(String[] extensionsIn) { for (String extension : extensionsIn) { - if (!extension.startsWith(".")) { + if (extension.length() == 0 || extension.charAt(0) != '.') { extension = "." + extension; } } diff --git a/src/cgeo/geocaching/files/GPXParser.java b/src/cgeo/geocaching/files/GPXParser.java index 14607bf..e6b5748 100644 --- a/src/cgeo/geocaching/files/GPXParser.java +++ b/src/cgeo/geocaching/files/GPXParser.java @@ -62,7 +62,7 @@ public abstract class GPXParser extends FileParser { private String name = null; private String cmt = null; private String desc = null; - + private class CacheAttribute { // List of cache attributes matching IDs used in GPX files. // The ID is represented by the position of the String in the array. @@ -143,7 +143,7 @@ public abstract class GPXParser extends FileParser { private Boolean active = null; // for yes/no private String baseName; // "food", "parkngrab", ... - + public void setActive(boolean active) { this.active = active; } @@ -179,7 +179,7 @@ public abstract class GPXParser extends FileParser { } } - public GPXParser(cgeoapplication appIn, int listIdIn, cgSearch searchIn, String namespaceIn, String versionIn) { + protected GPXParser(cgeoapplication appIn, int listIdIn, cgSearch searchIn, String namespaceIn, String versionIn) { app = appIn; listId = listIdIn; search = searchIn; @@ -398,14 +398,14 @@ public abstract class GPXParser extends FileParser { // waypoint.cache.attributes // @see issue #299 - + // <groundspeak:attributes> // <groundspeak:attribute id="32" inc="1">Bicycles</groundspeak:attribute> // <groundspeak:attribute id="13" inc="1">Available at all times</groundspeak:attribute> // where inc = 0 => _no, inc = 1 => _yes // IDs see array CACHE_ATTRIBUTES final Element gcAttributes = gcCache.getChild(nsGC, "attributes"); - + // waypoint.cache.attribute final Element gcAttribute = gcAttributes.getChild(nsGC, "attribute"); @@ -651,16 +651,16 @@ public abstract class GPXParser extends FileParser { } catch (SAXException e) { Log.e(cgSettings.tag, "Cannot parse .gpx file as GPX " + version + ": could not parse XML - " + e.toString()); } - return parsed ? search.getCurrentId() : 0l; + return parsed ? search.getCurrentId() : 0L; } private long parse(final File file, final Handler handlerIn) { if (file == null) { - return 0l; + return 0L; } FileInputStream fis = null; - long result = 0l; + long result = 0L; try { fis = new FileInputStream(file); result = parse(fis, handlerIn); @@ -715,12 +715,12 @@ public abstract class GPXParser extends FileParser { public static Long parseGPX(cgeoapplication app, File file, int listId, Handler handler) { cgSearch search = new cgSearch(); - long searchId = 0l; + long searchId = 0L; try { GPXParser parser = new GPX10Parser(app, listId, search); searchId = parser.parse(file, handler); - if (searchId == 0l) { + if (searchId == 0L) { parser = new GPX11Parser(app, listId, search); searchId = parser.parse(file, handler); } diff --git a/src/cgeo/geocaching/files/LocParser.java b/src/cgeo/geocaching/files/LocParser.java index 152293c..fd68fdc 100644 --- a/src/cgeo/geocaching/files/LocParser.java +++ b/src/cgeo/geocaching/files/LocParser.java @@ -144,7 +144,7 @@ public final class LocParser extends FileParser { public static long parseLoc(cgeoapplication app, File file, int listId,
Handler handler) {
cgSearch search = new cgSearch();
- long searchId = 0l;
+ long searchId = 0L;
try {
HashMap<String, cgCoord> coords = parseCoordinates(readFile(file).toString());
diff --git a/src/cgeo/geocaching/geopoint/Geopoint.java b/src/cgeo/geocaching/geopoint/Geopoint.java index 533854b..85149be 100644 --- a/src/cgeo/geocaching/geopoint/Geopoint.java +++ b/src/cgeo/geocaching/geopoint/Geopoint.java @@ -9,7 +9,7 @@ public class Geopoint public static final double deg2rad = Math.PI / 180; public static final double rad2deg = 180 / Math.PI; public static final float erad = 6371.0f; - + private double latitude; private double longitude; @@ -76,7 +76,7 @@ public class Geopoint return this; } - + /** * Set latitude in microdegree. * @@ -113,7 +113,7 @@ public class Geopoint { return latitude; } - + /** * Get latitude in microdegree. * @@ -144,7 +144,7 @@ public class Geopoint return this; } - + /** * Set longitude in microdegree. * @@ -181,7 +181,7 @@ public class Geopoint { return longitude; } - + /** * Get longitude in microdegree. * @@ -268,7 +268,7 @@ public class Geopoint double c = Math.acos(Math.sin(lat2) * Math.sin(lat1) + Math.cos(lat2) * Math.cos(lat1) * Math.cos(lon2 - lon1)); double A = Math.asin(Math.cos(lat2) * Math.sin(lon2 - lon1) / Math.sin(c)); double result = A * rad2deg; - + if (ilat2 > ilat1 && ilon2 > ilon1) { // result don't need change @@ -285,7 +285,7 @@ public class Geopoint { result += 360f; } - + return result; } } @@ -318,7 +318,7 @@ public class Geopoint */ public boolean isEqualTo(Geopoint gp) { - return (null != gp && gp.getLatitude() == latitude && gp.getLongitude() == longitude); + return null != gp && gp.getLatitude() == latitude && gp.getLongitude() == longitude; } /** @@ -330,7 +330,7 @@ public class Geopoint */ public boolean isEqualTo(Geopoint gp, double tolerance) { - return (null != gp && distanceTo(gp) <= tolerance); + return null != gp && distanceTo(gp) <= tolerance; } /** diff --git a/src/cgeo/geocaching/mapcommon/ItemizedOverlayBase.java b/src/cgeo/geocaching/mapcommon/ItemizedOverlayBase.java index 4e0379c..99bf2fd 100644 --- a/src/cgeo/geocaching/mapcommon/ItemizedOverlayBase.java +++ b/src/cgeo/geocaching/mapcommon/ItemizedOverlayBase.java @@ -20,7 +20,7 @@ public abstract class ItemizedOverlayBase implements OverlayBase { private ItemizedOverlayImpl ovlImpl; - public ItemizedOverlayBase(ItemizedOverlayImpl ovlImplIn) { + protected ItemizedOverlayBase(ItemizedOverlayImpl ovlImplIn) { ovlImpl = ovlImplIn; } diff --git a/src/cgeo/geocaching/mapcommon/MapBase.java b/src/cgeo/geocaching/mapcommon/MapBase.java index 1f967a0..1f2d769 100644 --- a/src/cgeo/geocaching/mapcommon/MapBase.java +++ b/src/cgeo/geocaching/mapcommon/MapBase.java @@ -18,7 +18,7 @@ public abstract class MapBase { ActivityImpl mapActivity; - public MapBase(ActivityImpl activity) { + protected MapBase(ActivityImpl activity) { mapActivity = activity; } diff --git a/src/cgeo/geocaching/mapcommon/cgOverlayScale.java b/src/cgeo/geocaching/mapcommon/cgOverlayScale.java index b8d6f09..cb73c75 100644 --- a/src/cgeo/geocaching/mapcommon/cgOverlayScale.java +++ b/src/cgeo/geocaching/mapcommon/cgOverlayScale.java @@ -21,7 +21,7 @@ public class cgOverlayScale implements OverlayBase { private Paint scale = null; private Paint scaleShadow = null; private BlurMaskFilter blur = null; - private float pixelDensity = 0l; + private float pixelDensity = 0L; private double pixels = 0d; private int bottom = 0; private double distance = 0d; diff --git a/src/cgeo/geocaching/mapcommon/cgeomap.java b/src/cgeo/geocaching/mapcommon/cgeomap.java index 9360899..9574661 100644 --- a/src/cgeo/geocaching/mapcommon/cgeomap.java +++ b/src/cgeo/geocaching/mapcommon/cgeomap.java @@ -28,13 +28,13 @@ import cgeo.geocaching.cgCoord; import cgeo.geocaching.cgDirection; import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgSettings; +import cgeo.geocaching.cgSettings.mapSourceEnum; import cgeo.geocaching.cgUpdateDir; import cgeo.geocaching.cgUpdateLoc; import cgeo.geocaching.cgUser; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.activity.ActivityMixin; -import cgeo.geocaching.cgSettings.mapSourceEnum; import cgeo.geocaching.mapinterfaces.ActivityImpl; import cgeo.geocaching.mapinterfaces.CacheOverlayItemImpl; import cgeo.geocaching.mapinterfaces.GeoPointImpl; @@ -101,8 +101,8 @@ public class cgeomap extends MapBase { private UsersThread usersThread = null; private DisplayUsersThread displayUsersThread = null; private LoadDetails loadDetailsThread = null; - private volatile long loadThreadRun = 0l; - private volatile long usersThreadRun = 0l; + private volatile long loadThreadRun = 0L; + private volatile long usersThreadRun = 0L; private volatile boolean downloaded = false; // overlays private cgMapOverlay overlayCaches = null; @@ -119,7 +119,7 @@ public class cgeomap extends MapBase { private ProgressDialog waitDialog = null; private int detailTotal = 0; private int detailProgress = 0; - private Long detailProgressTime = 0l; + private Long detailProgressTime = 0L; // views private ImageView myLocSwitch = null; // other things @@ -145,10 +145,9 @@ public class cgeomap extends MapBase { } if (caches != null && cachesCnt > 0) { - title.append(" "); - title.append("["); + title.append(" ["); title.append(caches.size()); - title.append("]"); + title.append(']'); } ActivityMixin.setTitle(activity, title.toString()); @@ -308,7 +307,7 @@ public class cgeomap extends MapBase { waypointTypeIntent = extras.getString("wpttype"); mapStateIntent = extras.getIntArray("mapstate"); - if (searchIdIntent == 0l) { + if (searchIdIntent == 0L) { searchIdIntent = null; } if (latitudeIntent == 0.0) { @@ -746,7 +745,7 @@ public class cgeomap extends MapBase { try { boolean repaintRequired = false; - + if (overlayMyLoc == null && mapView != null) { overlayMyLoc = mapView.createAddPositionOverlay(activity, settings); } @@ -771,11 +770,11 @@ public class cgeomap extends MapBase { } repaintRequired = true; } - + if (repaintRequired) { mapView.repaintRequired(overlayMyLoc); } - + } catch (Exception e) { Log.w(cgSettings.tag, "Failed to update location."); } @@ -942,7 +941,7 @@ public class cgeomap extends MapBase { } catch (Exception e) { Log.w(cgSettings.tag, "cgeomap.LoadTimer.run: " + e.toString()); } - }; + } } } @@ -1024,7 +1023,7 @@ public class cgeomap extends MapBase { } catch (Exception e) { Log.w(cgSettings.tag, "cgeomap.LoadUsersTimer.run: " + e.toString()); } - }; + } } } @@ -1080,24 +1079,14 @@ public class cgeomap extends MapBase { //if in live map and stored caches are found / disables are also shown. if (live && settings.maplive >= 1) { - // I know code is crude, but temporary fix - int i = 0; - boolean excludeMine = settings.excludeMine > 0; - boolean excludeDisabled = settings.excludeDisabled > 0; - - while (i < caches.size()) - { - boolean remove = false; - if ((caches.get(i).found) && (excludeMine)) - remove = true; - if ((caches.get(i).own) && (excludeMine)) - remove = true; - if ((caches.get(i).disabled) && (excludeDisabled)) - remove = true; - if (remove) + final boolean excludeMine = settings.excludeMine > 0; + final boolean excludeDisabled = settings.excludeDisabled > 0; + + for (int i = caches.size() - 1; i >= 0; i--) { + cgCache cache = caches.get(i); + if ((cache.found && excludeMine) || (cache.own && excludeMine) || (cache.disabled && excludeDisabled)) { caches.remove(i); - else - i++; + } } } @@ -1508,10 +1497,10 @@ public class cgeomap extends MapBase { protected boolean working = true; protected boolean stop = false; - protected long centerLat = 0l; - protected long centerLon = 0l; - protected long spanLat = 0l; - protected long spanLon = 0l; + protected long centerLat = 0L; + protected long centerLon = 0L; + protected long spanLat = 0L; + protected long spanLon = 0L; public DoThread(long centerLatIn, long centerLonIn, long spanLatIn, long spanLonIn) { centerLat = centerLatIn; @@ -1550,7 +1539,7 @@ public class cgeomap extends MapBase { private Handler handler = null; private ArrayList<String> geocodes = null; private volatile boolean stop = false; - private long last = 0l; + private long last = 0L; public LoadDetails(Handler handlerIn, ArrayList<String> geocodesIn) { handler = handlerIn; |
