Skip to content

Commit

Permalink
Replace Android/Java APIs with Kotlin APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 committed Aug 30, 2024
1 parent 919bc4e commit e813378
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ch.srg.dataProvider.integrationlayer.data.remote

import android.text.TextUtils
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ch.srg.dataProvider.integrationlayer.data.remote

import android.net.Uri
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down Expand Up @@ -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 {
Expand All @@ -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:"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ch.srg.dataProvider.integrationlayer.data.remote

import android.text.TextUtils
import java.util.Date

/**
Expand Down Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -16,23 +13,23 @@ class SearchParams {
AND, OR;

override fun toString(): String {
return name.lowercase(Locale.getDefault())
return name.lowercase()
}
}

enum class SortBy {
DEFAULT, DATE;

override fun toString(): String {
return name.lowercase(Locale.getDefault())
return name.lowercase()
}
}

enum class SortDir {
DESC, ASC;

override fun toString(): String {
return name.lowercase(Locale.getDefault())
return name.lowercase()
}
}

Expand Down Expand Up @@ -102,7 +99,7 @@ class SearchParams {

private fun put(result: HashMap<String, String>, key: String, values: List<String?>?) {
if (values != null) {
result[key] = TextUtils.join(",", values)
result[key] = values.joinToString(",")
}
}
}
Expand Down

0 comments on commit e813378

Please sign in to comment.