aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2011-11-17 17:55:32 +0100
committerBananeweizen <bananeweizen@gmx.de>2011-11-17 17:55:32 +0100
commit13ec57058263ad4f1eb3927c2ab0ff32b8deda95 (patch)
tree7ddd39a71ef418d9667271206ed0d1da4b324617 /main/src/cgeo/geocaching
parent67650f1e6ca20c8f9d2cd19b62993fbf4d559c0e (diff)
downloadcgeo-13ec57058263ad4f1eb3927c2ab0ff32b8deda95.zip
cgeo-13ec57058263ad4f1eb3927c2ab0ff32b8deda95.tar.gz
cgeo-13ec57058263ad4f1eb3927c2ab0ff32b8deda95.tar.bz2
show event date in cache list, fixes #805
Diffstat (limited to 'main/src/cgeo/geocaching')
-rw-r--r--main/src/cgeo/geocaching/cgCache.java8
-rw-r--r--main/src/cgeo/geocaching/cgCacheListAdapter.java40
2 files changed, 30 insertions, 18 deletions
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index 6db1a4c..08447c3 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -920,4 +920,12 @@ public class cgCache implements ICache {
}
}
+ public boolean hasDifficulty() {
+ return difficulty != null && difficulty > 0f;
+ }
+
+ public boolean hasTerrain() {
+ return terrain != null && terrain > 0f;
+ }
+
}
diff --git a/main/src/cgeo/geocaching/cgCacheListAdapter.java b/main/src/cgeo/geocaching/cgCacheListAdapter.java
index 1b0082b..c765b1a 100644
--- a/main/src/cgeo/geocaching/cgCacheListAdapter.java
+++ b/main/src/cgeo/geocaching/cgCacheListAdapter.java
@@ -47,6 +47,7 @@ import java.util.Set;
public class cgCacheListAdapter extends ArrayAdapter<cgCache> {
+ private static final String SEPARATOR = " | ";
final private Resources res;
final private List<cgCache> list;
private cgCacheView holder = null;
@@ -546,7 +547,7 @@ public class cgCacheListAdapter extends ArrayAdapter<cgCache> {
}
holder.favourite.setBackgroundResource(favoriteBack);
- StringBuilder cacheInfo = new StringBuilder();
+ StringBuilder cacheInfo = new StringBuilder(50);
if (historic && cache.getVisitedDate() != null) {
cacheInfo.append(base.formatTime(cache.getVisitedDate()));
cacheInfo.append("; ");
@@ -555,38 +556,41 @@ public class cgCacheListAdapter extends ArrayAdapter<cgCache> {
if (StringUtils.isNotBlank(cache.getGeocode())) {
cacheInfo.append(cache.getGeocode());
}
- if ((cache.getDifficulty() != null && cache.getDifficulty() > 0f) || (cache.getTerrain() != null && cache.getTerrain() > 0f) || (cache.getRating() != null && cache.getRating() > 0f)) {
- if (cacheInfo.length() > 0 && ((cache.getDifficulty() != null && cache.getDifficulty() > 0f) || (cache.getTerrain() != null && cache.getTerrain() > 0f))) {
- cacheInfo.append(" |");
+ if (cache.hasDifficulty() || cache.hasTerrain()) {
+ if (cacheInfo.length() > 0) {
+ cacheInfo.append(SEPARATOR);
}
- if (cache.getDifficulty() != null && cache.getDifficulty() > 0f) {
- cacheInfo.append(" D:");
- cacheInfo.append(String.format("%.1f", cache.getDifficulty()));
+ if (cache.hasDifficulty()) {
+ cacheInfo.append("D:");
+ cacheInfo.append(String.format("%.1f ", cache.getDifficulty()));
}
- if (cache.getTerrain() != null && cache.getTerrain() > 0f) {
- cacheInfo.append(" T:");
+ if (cache.hasTerrain()) {
+ cacheInfo.append("T:");
cacheInfo.append(String.format("%.1f", cache.getTerrain()));
}
}
- if (cache.getSize() != null) {
- // don't show "not chosen" for events and virtuals, that should be the normal case
- if (cache.showSize()) {
- if (cacheInfo.length() > 0) {
- cacheInfo.append(" | ");
- }
- cacheInfo.append(res.getString(cache.getSize().stringId));
+ // don't show "not chosen" for events and virtuals, that should be the normal case
+ if (cache.getSize() != null && cache.showSize()) {
+ if (cacheInfo.length() > 0) {
+ cacheInfo.append(SEPARATOR);
+ }
+ cacheInfo.append(res.getString(cache.getSize().stringId));
+ } else if (cache.isEventCache() && cache.getHiddenDate() != null) {
+ if (cacheInfo.length() > 0) {
+ cacheInfo.append(SEPARATOR);
}
+ cacheInfo.append(base.formatShortDate(cache.getHidden().getTime()));
}
if (cache.isMembers()) {
if (cacheInfo.length() > 0) {
- cacheInfo.append(" | ");
+ cacheInfo.append(SEPARATOR);
}
cacheInfo.append(res.getString(R.string.cache_premium));
}
if (cache.getReason() != null && cache.getReason() == 1) {
if (cacheInfo.length() > 0) {
- cacheInfo.append(" | ");
+ cacheInfo.append(SEPARATOR);
}
cacheInfo.append(res.getString(R.string.cache_offline));
}