Example #1
0
  /**
   * Transmit user vote to gcvote.com
   *
   * @param cache
   * @param vote
   * @return {@code true} if the rating was submitted successfully
   */
  public static boolean setRating(final Geocache cache, final float vote) {
    if (!isVotingPossible(cache)) {
      return false;
    }
    if (!isValidRating(vote)) {
      return false;
    }

    final ImmutablePair<String, String> login = Settings.getGCvoteLogin();
    if (login == null) {
      return false;
    }

    final Parameters params =
        new Parameters(
            "userName",
            login.left,
            "password",
            login.right,
            "cacheId",
            cache.getGuid(),
            "voteUser",
            String.format("%.1f", vote).replace(',', '.'),
            "version",
            "cgeo");

    final String result =
        Network.getResponseData(Network.getRequest("http://gcvote.com/setVote.php", params));

    return result != null && result.trim().equalsIgnoreCase("ok");
  }
Example #2
0
 public static boolean isVotingPossible(final Geocache cache) {
   return Settings.isGCvoteLogin()
       && StringUtils.isNotBlank(cache.getGuid())
       && cache.supportsGCVote();
 }