diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2013-09-12 08:10:49 +0200 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2013-09-12 08:10:49 +0200 |
commit | cf4322dc3fdc337307e83ae65ef36dd89f8ef7c1 (patch) | |
tree | cd17415d817c197c4c12c9f07ac715b3af4ec91d | |
parent | d47b38e071ab91e5f9b421f64dc18105f2596e68 (diff) | |
download | cgeo-cf4322dc3fdc337307e83ae65ef36dd89f8ef7c1.zip cgeo-cf4322dc3fdc337307e83ae65ef36dd89f8ef7c1.tar.gz cgeo-cf4322dc3fdc337307e83ae65ef36dd89f8ef7c1.tar.bz2 |
refactoring: cleanup of gcvote code
-rw-r--r-- | main/src/cgeo/geocaching/LogCacheActivity.java | 5 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/gcvote/GCVote.java | 15 |
2 files changed, 8 insertions, 12 deletions
diff --git a/main/src/cgeo/geocaching/LogCacheActivity.java b/main/src/cgeo/geocaching/LogCacheActivity.java index 41d3854..0ff0c97 100644 --- a/main/src/cgeo/geocaching/LogCacheActivity.java +++ b/main/src/cgeo/geocaching/LogCacheActivity.java @@ -213,7 +213,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia if (!postButton.isEnabled()) { return res.getString(R.string.log_post_not_possible); } - if (!Settings.isGCvoteLogin() || !cache.supportsGCVote()) { + if (!GCVote.isVotingPossible(cache)) { return res.getString(R.string.log_post); } if (GCVote.isValidRating(rating)) { @@ -423,8 +423,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); - final boolean voteAvailable = Settings.isGCvoteLogin() && StringUtils.isNotBlank(cache.getGuid()) && cache.supportsGCVote(); - menu.findItem(SUBMENU_VOTE).setVisible(voteAvailable); + menu.findItem(SUBMENU_VOTE).setVisible(GCVote.isVotingPossible(cache)); return true; } diff --git a/main/src/cgeo/geocaching/gcvote/GCVote.java b/main/src/cgeo/geocaching/gcvote/GCVote.java index 15d0024..3f7d33d 100644 --- a/main/src/cgeo/geocaching/gcvote/GCVote.java +++ b/main/src/cgeo/geocaching/gcvote/GCVote.java @@ -195,14 +195,7 @@ public final class GCVote { * @return {@code true} if the rating was submitted successfully */ public static boolean setRating(final Geocache cache, final float vote) { - if (!Settings.isGCvoteLogin()) { - return false; - } - if (!cache.supportsGCVote()) { - return false; - } - String guid = cache.getGuid(); - if (StringUtils.isBlank(guid)) { + if (!isVotingPossible(cache)) { return false; } if (!isValidRating(vote)) { @@ -217,7 +210,7 @@ public final class GCVote { final Parameters params = new Parameters( "userName", login.left, "password", login.right, - "cacheId", guid, + "cacheId", cache.getGuid(), "voteUser", String.format("%.1f", vote).replace(',', '.'), "version", "cgeo"); @@ -271,4 +264,8 @@ public final class GCVote { return String.format(Locale.getDefault(), "%.1f", rating); } + public static boolean isVotingPossible(final Geocache cache) { + return Settings.isGCvoteLogin() && StringUtils.isNotBlank(cache.getGuid()) && cache.supportsGCVote(); + } + } |