diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2012-04-28 12:04:36 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2012-04-28 13:30:05 +0200 |
commit | 49716bc6a97ca76ff2b0ff90f0b06d826a1a6220 (patch) | |
tree | 1cb1317993cf4616c07348cc55d9cb7e52e6a306 /main | |
parent | b3c534f8c7b4d42819960486bb1942b109d877f8 (diff) | |
download | cgeo-49716bc6a97ca76ff2b0ff90f0b06d826a1a6220.zip cgeo-49716bc6a97ca76ff2b0ff90f0b06d826a1a6220.tar.gz cgeo-49716bc6a97ca76ff2b0ff90f0b06d826a1a6220.tar.bz2 |
Refactoring: remove unnecessary else statements
Diffstat (limited to 'main')
5 files changed, 43 insertions, 25 deletions
diff --git a/main/src/cgeo/geocaching/VisitCacheActivity.java b/main/src/cgeo/geocaching/VisitCacheActivity.java index 8221218..72e70e9 100644 --- a/main/src/cgeo/geocaching/VisitCacheActivity.java +++ b/main/src/cgeo/geocaching/VisitCacheActivity.java @@ -88,16 +88,13 @@ public class VisitCacheActivity extends AbstractActivity implements DateDialog.D showToast(res.getString(R.string.info_log_type_changed)); } - if (Login.isEmpty(viewstates) && attempts < 2) { - final LoadDataThread thread; - thread = new LoadDataThread(); - thread.start(); - - return; - } else if (Login.isEmpty(viewstates) && attempts >= 2) { - showToast(res.getString(R.string.err_log_load_data)); - showProgress(false); - + if (Login.isEmpty(viewstates)) { + if (attempts < 2) { + new LoadDataThread().start(); + } else { + showToast(res.getString(R.string.err_log_load_data)); + showProgress(false); + } return; } @@ -336,7 +333,9 @@ public class VisitCacheActivity extends AbstractActivity implements DateDialog.D if (id == MENU_SIGNATURE) { insertIntoLog(LogTemplateProvider.applyTemplates(Settings.getSignature(), false), true); return true; - } else if (id >= 10 && id <= 19) { + } + + if (id >= 10 && id <= 19) { rating = (id - 9) / 2.0; if (rating < 1) { rating = 0; @@ -344,12 +343,13 @@ public class VisitCacheActivity extends AbstractActivity implements DateDialog.D updatePostButtonText(); return true; } + final LogTemplate template = LogTemplateProvider.getTemplate(id); if (template != null) { - final String newText = template.getValue(false); - insertIntoLog(newText, true); + insertIntoLog(template.getValue(false), true); return true; } + return false; } @@ -400,9 +400,10 @@ public class VisitCacheActivity extends AbstractActivity implements DateDialog.D if (group == R.id.type) { setType(LogType.getById(id)); - return true; - } else if (group == R.id.changebutton) { + } + + if (group == R.id.changebutton) { try { final LogTypeTrackable logType = LogTypeTrackable.findById(id); if (logType != null) { diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java index c5abf7f..16b641e 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java @@ -46,13 +46,24 @@ abstract class AbstractPointNavigationApp extends AbstractNavigationApp { protected abstract void navigate(Activity activity, Geopoint point); - private static Geopoint getCoordinates(cgCache cache, cgWaypoint waypoint, Geopoint coords) { + /** + * Return the first of the cache coordinates, the waypoint coordinates or the extra coordinates. <code>null</code> + * entities are skipped. + * + * @param cache a cache + * @param waypoint a waypoint + * @param coords extra coordinates + * @return the first non-null coordinates, or null if none are set + */ + private static Geopoint getCoordinates(final cgCache cache, final cgWaypoint waypoint, final Geopoint coords) { if (cache != null && cache.getCoords() != null) { return cache.getCoords(); } - else if (waypoint != null && waypoint.getCoords() != null) { + + if (waypoint != null && waypoint.getCoords() != null) { return waypoint.getCoords(); } + return coords; } }
\ No newline at end of file diff --git a/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java b/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java index ce59901..165e277 100644 --- a/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java +++ b/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java @@ -226,7 +226,7 @@ final public class OkapiClient { if ("Found it".equalsIgnoreCase(logType)) { return LogType.LOG_FOUND_IT; } - else if ("Didn't find it".equalsIgnoreCase(logType)) { + if ("Didn't find it".equalsIgnoreCase(logType)) { return LogType.LOG_DIDNT_FIND_IT; } return LogType.LOG_NOTE; @@ -280,11 +280,14 @@ final public class OkapiClient { private static CacheType getCacheType(final String cacheType) { if (cacheType.equalsIgnoreCase("Traditional")) { return CacheType.TRADITIONAL; - } else if (cacheType.equalsIgnoreCase("Multi")) { + } + if (cacheType.equalsIgnoreCase("Multi")) { return CacheType.MULTI; - } else if (cacheType.equalsIgnoreCase("Quiz")) { + } + if (cacheType.equalsIgnoreCase("Quiz")) { return CacheType.MYSTERY; - } else if (cacheType.equalsIgnoreCase("Virtual")) { + } + if (cacheType.equalsIgnoreCase("Virtual")) { return CacheType.VIRTUAL; } return CacheType.UNKNOWN; diff --git a/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java b/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java index 606d8f3..08fd02e 100644 --- a/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java +++ b/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java @@ -44,14 +44,16 @@ public class Go4CacheUser { } public int getIconId() { - if (null == client) { + if (client == null) { return -1; } if (client.equalsIgnoreCase("c:geo")) { return R.drawable.client_cgeo; - } else if (client.equalsIgnoreCase("preCaching")) { + } + if (client.equalsIgnoreCase("preCaching")) { return R.drawable.client_precaching; - } else if (client.equalsIgnoreCase("Handy Geocaching")) { + } + if (client.equalsIgnoreCase("Handy Geocaching")) { return R.drawable.client_handygeocaching; } return -1; diff --git a/main/src/cgeo/geocaching/network/Parameters.java b/main/src/cgeo/geocaching/network/Parameters.java index 9cf51d2..90965e4 100644 --- a/main/src/cgeo/geocaching/network/Parameters.java +++ b/main/src/cgeo/geocaching/network/Parameters.java @@ -97,7 +97,8 @@ public class Parameters extends ArrayList<NameValuePair> { public static Parameters merge(final Parameters params, final Parameters extra) { if (params == null) { return extra; - } else if (extra != null) { + } + if (extra != null) { params.addAll(extra); } return params; |