aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorMichael Keppler <michael.keppler@gmx.de>2014-04-22 11:03:23 +0200
committerMichael Keppler <michael.keppler@gmx.de>2014-04-22 11:03:23 +0200
commit0e1262604f3a06469724b334a6f6268414e91fb8 (patch)
tree63e1b22e5dc4e9f5f76d1c29deda6fd01719463f /main
parent8589d41a6a84c33bf0a4d6752483928aa3e5df67 (diff)
downloadcgeo-0e1262604f3a06469724b334a6f6268414e91fb8.zip
cgeo-0e1262604f3a06469724b334a6f6268414e91fb8.tar.gz
cgeo-0e1262604f3a06469724b334a6f6268414e91fb8.tar.bz2
fix #3697: have attended as log type on day of event
Diffstat (limited to 'main')
-rw-r--r--main/src/cgeo/geocaching/Geocache.java20
-rw-r--r--main/src/cgeo/geocaching/LogCacheActivity.java24
2 files changed, 24 insertions, 20 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java
index fa25576..1ed699e 100644
--- a/main/src/cgeo/geocaching/Geocache.java
+++ b/main/src/cgeo/geocaching/Geocache.java
@@ -25,6 +25,7 @@ import cgeo.geocaching.list.StoredList;
import cgeo.geocaching.network.HtmlImage;
import cgeo.geocaching.settings.Settings;
import cgeo.geocaching.utils.CancellableHandler;
+import cgeo.geocaching.utils.DateUtils;
import cgeo.geocaching.utils.ImageUtils;
import cgeo.geocaching.utils.LazyInitializedList;
import cgeo.geocaching.utils.Log;
@@ -1808,4 +1809,23 @@ public class Geocache implements ICache, IWaypoint {
return (getType().applyDistanceRule() || hasUserModifiedCoords()) && getConnector() == GCConnector.getInstance();
}
+ public LogType getDefaultLogType() {
+ if (isEventCache()) {
+ final Date eventDate = getHiddenDate();
+ boolean expired = DateUtils.isPastEvent(this);
+
+ if (hasOwnLog(LogType.WILL_ATTEND) || expired || (eventDate != null && DateUtils.daysSince(eventDate.getTime()) == 0)) {
+ return hasOwnLog(LogType.ATTENDED) ? LogType.NOTE : LogType.ATTENDED;
+ }
+ return LogType.WILL_ATTEND;
+ }
+ if (isFound()) {
+ return LogType.NOTE;
+ }
+ if (getType() == CacheType.WEBCAM) {
+ return LogType.WEBCAM_PHOTO_TAKEN;
+ }
+ return LogType.FOUND_IT;
+ }
+
}
diff --git a/main/src/cgeo/geocaching/LogCacheActivity.java b/main/src/cgeo/geocaching/LogCacheActivity.java
index 0f65a1d..a1368cc 100644
--- a/main/src/cgeo/geocaching/LogCacheActivity.java
+++ b/main/src/cgeo/geocaching/LogCacheActivity.java
@@ -3,7 +3,6 @@ package cgeo.geocaching;
import cgeo.geocaching.connector.ILoggingManager;
import cgeo.geocaching.connector.ImageResult;
import cgeo.geocaching.connector.LogResult;
-import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LoadFlags;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.LogTypeTrackable;
@@ -341,25 +340,10 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia
private void setDefaultValues() {
date = Calendar.getInstance();
rating = GCVote.NO_RATING;
- if (cache.isEventCache()) {
- final Date eventDate = cache.getHiddenDate();
- boolean expired = DateUtils.isPastEvent(cache);
-
- if (cache.hasOwnLog(LogType.WILL_ATTEND) || expired) {
- typeSelected = cache.hasOwnLog(LogType.ATTENDED) ? LogType.NOTE : LogType.ATTENDED;
- } else {
- typeSelected = LogType.WILL_ATTEND;
- }
- // it this is an attended event log, use the event date by default instead of the current date
- if (expired && typeSelected == LogType.ATTENDED) {
- date.setTime(eventDate);
- }
- } else {
- if (cache.isFound()) {
- typeSelected = LogType.NOTE;
- } else {
- typeSelected = cache.getType() == CacheType.WEBCAM ? LogType.WEBCAM_PHOTO_TAKEN : LogType.FOUND_IT;
- }
+ typeSelected = cache.getDefaultLogType();
+ // it this is an attended event log, use the event date by default instead of the current date
+ if (cache.isEventCache() && DateUtils.isPastEvent(cache) && typeSelected == LogType.ATTENDED) {
+ date.setTime(cache.getHiddenDate());
}
text = null;
imageCaption = StringUtils.EMPTY;