Merge branch 'release/1.10.1'

This commit is contained in:
bvn13 2023-03-02 17:43:07 +03:00
commit 9168ae9875
3 changed files with 28 additions and 7 deletions

7
.gitignore vendored
View File

@ -368,4 +368,9 @@ gradle-app.setting
**/build/
# End of https://www.toptal.com/developers/gitignore/api/java,gradle,git,intellij,linux,windows,macos,node
**/target/
**/target/
.idea/
.idea/**
GpxAndroidSdk.iml

View File

@ -6,7 +6,7 @@
<artifactId>GpxAndroidSdk</artifactId>
<groupId>me.bvn13.sdk.android.gpx</groupId>
<version>1.9</version>
<version>1.10.1</version>
<packaging>jar</packaging>
@ -58,6 +58,11 @@
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
@ -234,7 +239,7 @@
<developmentBranch>develop</developmentBranch>
</gitFlowConfig>
<incrementVersionAtFinish>true</incrementVersionAtFinish>
<versionDigitToIncrement>2</versionDigitToIncrement>
<versionDigitToIncrement>3</versionDigitToIncrement>
</configuration>
</plugin>
</plugins>

View File

@ -82,6 +82,9 @@ import me.bvn13.sdk.android.gpx.GpxConstant.Companion.HEADER
import me.bvn13.sdk.android.gpx.GpxWriter.Companion.SCHEMA_LOCATION
import me.bvn13.sdk.android.gpx.GpxWriter.Companion.XMLNS
import me.bvn13.sdk.android.gpx.GpxWriter.Companion.XMLNS_XSI
import me.bvn13.sdk.android.gpx.GpxWriter.Companion.log
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.time.Clock
import java.time.OffsetDateTime
@ -257,10 +260,17 @@ fun toXmlString(value: Double?, nodeName: String) = if (value != null) {
""
}
fun toXmlString(value: OffsetDateTime?, nodeName: String) = if (value != null) {
"<${nodeName}>${value.format(DTF)}</${nodeName}>"
} else {
""
fun toXmlString(value: OffsetDateTime?, nodeName: String): String {
if (value != null) {
try {
return "<${nodeName}>${value.format(DTF)}</${nodeName}>"
} catch (e: Exception) {
log.warn(String.format("Unable to format datetime value %s in node %s", value, nodeName), e)
return ""
}
} else {
return ""
}
}
fun toXmlString(value: Map<String, String>?) = value?.entries?.joinToString(separator = "") {
@ -280,5 +290,6 @@ class GpxWriter {
const val XMLNS = "http://www.topografix.com/GPX/1/1"
const val XMLNS_XSI = "http://www.w3.org/2001/XMLSchema-instance"
const val SCHEMA_LOCATION = "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
val log: Logger = LoggerFactory.getLogger(GpxWriter.javaClass)
}
}