diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2012-09-02 14:59:29 +0200 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2012-09-02 14:59:29 +0200 |
commit | cc009b9abe14cbdfe0b950d7459feaf193e9ea9a (patch) | |
tree | 20d255e0826f0c6c946e617ce47cc8f5f4b9b86e /main/src/cgeo | |
parent | 83c2839a59e9928f105e35b4fcb5b14845f21abb (diff) | |
download | cgeo-cc009b9abe14cbdfe0b950d7459feaf193e9ea9a.zip cgeo-cc009b9abe14cbdfe0b950d7459feaf193e9ea9a.tar.gz cgeo-cc009b9abe14cbdfe0b950d7459feaf193e9ea9a.tar.bz2 |
fix #2015: export crashes on missing hidden date
Diffstat (limited to 'main/src/cgeo')
-rw-r--r-- | main/src/cgeo/geocaching/export/GpxExport.java | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/main/src/cgeo/geocaching/export/GpxExport.java b/main/src/cgeo/geocaching/export/GpxExport.java index 8af85a8..6aa46e6 100644 --- a/main/src/cgeo/geocaching/export/GpxExport.java +++ b/main/src/cgeo/geocaching/export/GpxExport.java @@ -15,6 +15,7 @@ import cgeo.geocaching.utils.BaseUtils; import cgeo.geocaching.utils.Log; import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; import android.app.Activity; import android.app.AlertDialog; @@ -153,9 +154,12 @@ class GpxExport extends AbstractExport { gpx.write(Double.toString(cache.getCoords().getLongitude())); gpx.write("\">"); - gpx.write("<time>"); - gpx.write(StringEscapeUtils.escapeXml(dateFormatZ.format(cache.getHiddenDate()))); - gpx.write("</time>"); + final Date hiddenDate = cache.getHiddenDate(); + if (hiddenDate != null) { + gpx.write("<time>"); + gpx.write(StringEscapeUtils.escapeXml(dateFormatZ.format(hiddenDate))); + gpx.write("</time>"); + } gpx.write("<name>"); gpx.write(StringEscapeUtils.escapeXml(cache.getGeocode())); @@ -228,21 +232,13 @@ class GpxExport extends AbstractExport { gpx.write("<groundspeak:state></groundspeak:state>"); // c:geo cannot manage 2 separate fields, so we export as country gpx.write("<groundspeak:short_description html=\""); - if (BaseUtils.containsHtml(cache.getShortDescription())) { - gpx.write("True"); - } else { - gpx.write("False"); - } + gpx.write(BaseUtils.containsHtml(cache.getShortDescription()) ? "True" : "False"); gpx.write("\">"); gpx.write(StringEscapeUtils.escapeXml(cache.getShortDescription())); gpx.write("</groundspeak:short_description>"); gpx.write("<groundspeak:long_description html=\""); - if (BaseUtils.containsHtml(cache.getDescription())) { - gpx.write("True"); - } else { - gpx.write("False"); - } + gpx.write(BaseUtils.containsHtml(cache.getDescription()) ? "True" : "False"); gpx.write("\">"); gpx.write(StringEscapeUtils.escapeXml(cache.getDescription())); gpx.write("</groundspeak:long_description>"); @@ -309,10 +305,7 @@ class GpxExport extends AbstractExport { } for (cgWaypoint wp : ownWaypoints) { maxPrefix++; - String prefix = String.valueOf(maxPrefix); - if (prefix.length() == 1) { - prefix = "0" + prefix; - } + String prefix = StringUtils.leftPad(String.valueOf(maxPrefix), 2, '0'); writeCacheWaypoint(wp, prefix); } } |