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 1f01927fd..95579ed12 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,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 + } } } 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 } /**