From 27f338cf726f95c4825f18cf1e7056063f50c3ba Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 1 Feb 2023 05:44:27 +0530 Subject: [PATCH 1/2] Remove uses of String.all(). --- .../main/java/com/github/libretube/api/PlaylistsHelper.kt | 7 ++++--- app/src/main/java/com/github/libretube/util/TextUtils.kt | 6 +----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt b/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt index f96a05282..c25e7b06c 100644 --- a/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt +++ b/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt @@ -2,6 +2,7 @@ package com.github.libretube.api import android.content.Context import android.util.Log +import androidx.core.text.isDigitsOnly import com.github.libretube.R import com.github.libretube.api.obj.Playlist import com.github.libretube.api.obj.PlaylistId @@ -237,8 +238,8 @@ object PlaylistsHelper { } private fun getPrivatePlaylistType(playlistId: String): PlaylistType { - if (playlistId.all { it.isDigit() }) return PlaylistType.LOCAL - if (playlistId.matches(pipedPlaylistRegex)) return PlaylistType.PRIVATE - return PlaylistType.PUBLIC + return if (playlistId.isDigitsOnly()) PlaylistType.LOCAL + else if (playlistId.matches(pipedPlaylistRegex)) PlaylistType.PRIVATE + else PlaylistType.PUBLIC } } diff --git a/app/src/main/java/com/github/libretube/util/TextUtils.kt b/app/src/main/java/com/github/libretube/util/TextUtils.kt index 1da931d67..26d29d5f9 100644 --- a/app/src/main/java/com/github/libretube/util/TextUtils.kt +++ b/app/src/main/java/com/github/libretube/util/TextUtils.kt @@ -41,11 +41,7 @@ object TextUtils { * @return Time in seconds */ fun parseTimestamp(t: String): Long? { - if (t.all { c -> c.isDigit() }) { - return t.toLong() - } - - return Duration.parseOrNull(t)?.inWholeSeconds + return t.toLongOrNull() ?: Duration.parseOrNull(t)?.inWholeSeconds } /** From 8916bd82148c02c923fa065977fdff35e20eb6db Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 1 Feb 2023 18:06:08 +0100 Subject: [PATCH 2/2] Merge master into `Remove_String_all` --- .../java/com/github/libretube/api/PlaylistsHelper.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt b/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt index c64933047..95579ed12 100644 --- a/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt +++ b/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt @@ -238,8 +238,12 @@ object PlaylistsHelper { } private fun getPrivatePlaylistType(playlistId: String): PlaylistType { - return if (playlistId.isDigitsOnly()) PlaylistType.LOCAL - else if (playlistId.matches(pipedPlaylistRegex)) PlaylistType.PRIVATE - else PlaylistType.PUBLIC + return if (playlistId.isDigitsOnly()) { + PlaylistType.LOCAL + } else if (playlistId.matches(pipedPlaylistRegex)) { + PlaylistType.PRIVATE + } else { + PlaylistType.PUBLIC + } } }