From c05d8b53cb7dc6391b0fdff993062d70b6c7f501 Mon Sep 17 00:00:00 2001 From: flaviuvsp Date: Wed, 23 Oct 2024 15:41:59 +0300 Subject: [PATCH] Change get ui address to handle empty locality, admin and country code --- app/build.gradle | 2 +- .../org/permanent/permanent/network/models/FileData.kt | 8 +------- .../java/org/permanent/permanent/network/models/LocnVO.kt | 7 +++++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4228e0b0..5520004a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,7 @@ android { applicationId "org.permanent.PermanentArchive" minSdkVersion 26 targetSdkVersion 34 - versionCode 72 + versionCode 73 versionName "1.9.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/org/permanent/permanent/network/models/FileData.kt b/app/src/main/java/org/permanent/permanent/network/models/FileData.kt index 5db95479..09940513 100644 --- a/app/src/main/java/org/permanent/permanent/network/models/FileData.kt +++ b/app/src/main/java/org/permanent/permanent/network/models/FileData.kt @@ -61,13 +61,7 @@ class FileData private constructor() : Parcelable { originalFileName = recordVO.uploadFileName?.substringBefore(".") originalFileType = recordVO.uploadFileName?.substringAfter(".") - completeAddress = recordVO.LocnVO?.let { - val streetName = if (it.streetName == null) "" else it.streetName + ", " - val addressValue = - (it.streetNumber ?: "") + " " + streetName + it.locality + - ", " + it.adminOneName + ", " + it.countryCode - if (!addressValue.contains("null")) addressValue else "" - } + completeAddress = recordVO.LocnVO?.getUIAddress() latitude = recordVO.LocnVO?.latitude ?: -1.0 longitude = recordVO.LocnVO?.longitude ?: -1.0 diff --git a/app/src/main/java/org/permanent/permanent/network/models/LocnVO.kt b/app/src/main/java/org/permanent/permanent/network/models/LocnVO.kt index cc09f40c..7441923a 100644 --- a/app/src/main/java/org/permanent/permanent/network/models/LocnVO.kt +++ b/app/src/main/java/org/permanent/permanent/network/models/LocnVO.kt @@ -27,10 +27,13 @@ class LocnVO() : Parcelable { } fun getUIAddress(): String { - if (uiAddress == null) { + if (uiAddress.isNullOrEmpty()) { val strName = if (streetName == null) "" else "$streetName, " + val localityName = if (locality == null) "" else "$locality, " + val adminName = if (adminOneName == null) "" else "$adminOneName, " + val countryCodeName = if (countryCode == null) "" else "$countryCode" val addressValue = (streetNumber ?: "") + " " + strName + - locality + ", " + adminOneName + ", " + countryCode + localityName + adminName + countryCodeName uiAddress = if (!addressValue.contains("null")) addressValue.trim() else "" }