Merge pull request #270 from misaochan/fix-location-null

Add check for decimalCoords != null in template
This commit is contained in:
Josephine Lim 2016-09-13 01:04:37 +12:00 committed by GitHub
commit 79294200ac

View file

@ -133,8 +133,7 @@ public class Contribution extends Media {
public String getPageContents() { public String getPageContents() {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd");
//TODO: Add location template immediately after Information template. {{Location|37.51136|-77.602615}}
buffer buffer
.append("== {{int:filedesc}} ==\n") .append("== {{int:filedesc}} ==\n")
.append("{{Information\n") .append("{{Information\n")
@ -146,9 +145,14 @@ public class Contribution extends Media {
.append("|date={{According to EXIF data|").append(isoFormat.format(dateCreated)).append("}}\n"); .append("|date={{According to EXIF data|").append(isoFormat.format(dateCreated)).append("}}\n");
} }
buffer buffer
.append("}}").append("\n") .append("}}").append("\n");
.append("{{Location|").append(decimalCoords).append("}}").append("\n")
.append("== {{int:license-header}} ==\n") //Only add Location template (e.g. {{Location|37.51136|-77.602615}} ) if coords is not null
if (decimalCoords != null) {
buffer.append("{{Location|").append(decimalCoords).append("}}").append("\n");
}
buffer.append("== {{int:license-header}} ==\n")
.append(Utils.licenseTemplateFor(getLicense())).append("\n\n") .append(Utils.licenseTemplateFor(getLicense())).append("\n\n")
.append("{{Uploaded from Mobile|platform=Android|version=").append(CommonsApplication.APPLICATION_VERSION).append("}}\n") .append("{{Uploaded from Mobile|platform=Android|version=").append(CommonsApplication.APPLICATION_VERSION).append("}}\n")
.append(getTrackingTemplates()); .append(getTrackingTemplates());