From a4a89a990f0573c3fd22d7476597f36995c7a1df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Muller?= Date: Thu, 29 Aug 2024 14:35:38 +0200 Subject: [PATCH] Replace Android/Java APIs with Kotlin APIs --- .../integrationlayer/data/ISO8601DateParser.kt | 3 ++- .../integrationlayer/data/remote/MediaComposition.kt | 3 +-- .../integrationlayer/data/remote/Resource.kt | 5 ++--- .../integrationlayer/data/remote/SRGMediaMetadata.kt | 3 +-- .../integrationlayer/data/remote/SearchParams.kt | 11 ++++------- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/ISO8601DateParser.kt b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/ISO8601DateParser.kt index d4cc6f8..f834d36 100644 --- a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/ISO8601DateParser.kt +++ b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/ISO8601DateParser.kt @@ -2,7 +2,8 @@ package ch.srg.dataProvider.integrationlayer.data import java.text.ParseException import java.text.SimpleDateFormat -import java.util.* +import java.util.Date +import java.util.Locale /** * DateParser to convert Integration Layer String date to date (ISO_8601) diff --git a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/MediaComposition.kt b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/MediaComposition.kt index f4b99ed..4e7e92d 100644 --- a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/MediaComposition.kt +++ b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/MediaComposition.kt @@ -1,6 +1,5 @@ package ch.srg.dataProvider.integrationlayer.data.remote -import android.text.TextUtils import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -80,7 +79,7 @@ data class MediaComposition( return false } for (chapter in chapterList) { - if (TextUtils.equals(chapter.urn, urn)) { + if (chapter.urn == urn) { return true } if (chapter.findSegment(urn) != null) { diff --git a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/Resource.kt b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/Resource.kt index b09cb28..5789498 100644 --- a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/Resource.kt +++ b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/Resource.kt @@ -1,6 +1,5 @@ package ch.srg.dataProvider.integrationlayer.data.remote -import android.net.Uri import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -49,7 +48,7 @@ data class Resource @JvmOverloads constructor( } fun isLocalFile(): Boolean { - return Uri.parse(url).scheme == LOCAL_FILE_SCHEME_URL + return url.startsWith(LOCAL_FILE_SCHEME_URL) } fun hasDrm(): Boolean { @@ -72,6 +71,6 @@ data class Resource @JvmOverloads constructor( } companion object { - const val LOCAL_FILE_SCHEME_URL = "file" + const val LOCAL_FILE_SCHEME_URL = "file:" } } diff --git a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/SRGMediaMetadata.kt b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/SRGMediaMetadata.kt index df607a6..c07ee0d 100644 --- a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/SRGMediaMetadata.kt +++ b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/SRGMediaMetadata.kt @@ -1,6 +1,5 @@ package ch.srg.dataProvider.integrationlayer.data.remote -import android.text.TextUtils import java.util.Date /** @@ -28,7 +27,7 @@ interface SRGMediaMetadata : SRGIdentifierMetadata, SRGImageMetadata, SRGMetadat fun getDownloadUri(quality: Quality = Quality.HD): String? { return when (quality) { Quality.SD -> podcastSdUrl - Quality.HD, Quality.HQ -> if (TextUtils.isEmpty(podcastHdUrl)) podcastSdUrl else podcastHdUrl + Quality.HD, Quality.HQ -> if (podcastHdUrl.isNullOrEmpty()) podcastSdUrl else podcastHdUrl } } diff --git a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/SearchParams.kt b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/SearchParams.kt index c2e929d..9cb8542 100644 --- a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/SearchParams.kt +++ b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/remote/SearchParams.kt @@ -1,8 +1,5 @@ package ch.srg.dataProvider.integrationlayer.data.remote -import android.text.TextUtils -import java.util.Locale - /** * Copyright (c) SRG SSR. All rights reserved. * @@ -16,7 +13,7 @@ class SearchParams { AND, OR; override fun toString(): String { - return name.lowercase(Locale.getDefault()) + return name.lowercase() } } @@ -24,7 +21,7 @@ class SearchParams { DEFAULT, DATE; override fun toString(): String { - return name.lowercase(Locale.getDefault()) + return name.lowercase() } } @@ -32,7 +29,7 @@ class SearchParams { DESC, ASC; override fun toString(): String { - return name.lowercase(Locale.getDefault()) + return name.lowercase() } } @@ -102,7 +99,7 @@ class SearchParams { private fun put(result: HashMap, key: String, values: List?) { if (values != null) { - result[key] = TextUtils.join(",", values) + result[key] = values.joinToString(",") } } }