Merge pull request #2930 from Isira-Seneviratne/Remove_String_all

Remove uses of String.all().
This commit is contained in:
Bnyro 2023-02-01 18:06:49 +01:00 committed by GitHub
commit 43d5e8ce3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -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,12 @@ 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
}
}
}

View File

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