aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/LogEntry.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-05-07 08:49:17 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-05-07 08:49:17 +0200
commit5f93d6085db6de0d88d7ba5a6e4a7cbba25c7e1b (patch)
tree07122025040cc41edd33169a8e4a5716dba2960e /main/src/cgeo/geocaching/LogEntry.java
parent6d999226b74315e9d8cc72ec6c4b4e96869f8aae (diff)
downloadcgeo-5f93d6085db6de0d88d7ba5a6e4a7cbba25c7e1b.zip
cgeo-5f93d6085db6de0d88d7ba5a6e4a7cbba25c7e1b.tar.gz
cgeo-5f93d6085db6de0d88d7ba5a6e4a7cbba25c7e1b.tar.bz2
new: show days since last spotted for trackables
Diffstat (limited to 'main/src/cgeo/geocaching/LogEntry.java')
-rw-r--r--main/src/cgeo/geocaching/LogEntry.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/LogEntry.java b/main/src/cgeo/geocaching/LogEntry.java
index 3130822..e0e2e13 100644
--- a/main/src/cgeo/geocaching/LogEntry.java
+++ b/main/src/cgeo/geocaching/LogEntry.java
@@ -3,6 +3,7 @@ package cgeo.geocaching;
import cgeo.geocaching.enumerations.LogType;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Calendar;
@@ -83,4 +84,30 @@ public final class LogEntry {
public boolean hasLogImages() {
return CollectionUtils.isNotEmpty(logImages);
}
+
+ public CharSequence getImageTitles() {
+ final List<String> titles = new ArrayList<String>(5);
+ for (cgImage image : getLogImages()) {
+ if (StringUtils.isNotBlank(image.getTitle())) {
+ titles.add(image.getTitle());
+ }
+ }
+ if (titles.isEmpty()) {
+ titles.add(cgeoapplication.getInstance().getString(R.string.cache_log_image_default_title));
+ }
+ return StringUtils.join(titles, ", ");
+ }
+
+ public int daysSinceLog() {
+ final Calendar logDate = Calendar.getInstance();
+ logDate.setTimeInMillis(date);
+ logDate.set(Calendar.SECOND, 0);
+ logDate.set(Calendar.MINUTE, 0);
+ logDate.set(Calendar.HOUR, 0);
+ final Calendar today = Calendar.getInstance();
+ today.set(Calendar.SECOND, 0);
+ today.set(Calendar.MINUTE, 0);
+ today.set(Calendar.HOUR, 0);
+ return (int) Math.round((today.getTimeInMillis() - logDate.getTimeInMillis()) / 86400000d);
+ }
}