fix null check

This commit is contained in:
Quickdesh 2023-05-30 20:07:46 +05:30
parent 1d1aa51de3
commit faff8b6f0b
5 changed files with 14 additions and 7 deletions

View file

@ -47,10 +47,14 @@ import eu.kanade.tachiyomi.data.download.anime.AnimeDownloadManager
import eu.kanade.tachiyomi.source.anime.AnimeSourceManager
import eu.kanade.tachiyomi.ui.player.EpisodeLoader
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import logcat.LogPriority
import tachiyomi.core.util.lang.launchUI
import tachiyomi.core.util.lang.withIOContext
import tachiyomi.core.util.system.logcat
import tachiyomi.domain.entries.anime.model.Anime
import tachiyomi.domain.items.episode.model.Episode
import uy.kohesive.injekt.Injekt
@ -120,6 +124,7 @@ class EpisodeOptionsDialogScreen(
val resultList: Result<List<Video>>? = null,
)
@OptIn(DelicateCoroutinesApi::class)
@Composable
fun EpisodeOptionsDialog(
episode: Episode?,
@ -151,7 +156,7 @@ class EpisodeOptionsDialogScreen(
LoadingScreen()
} else {
val videoList = resultList.getOrNull()
if (videoList != null) {
if (!videoList.isNullOrEmpty()) {
videoList.forEach { video ->
val downloadEpisode: (Boolean) -> Unit = {
downloadManager.downloadEpisodes(anime!!, listOf(episode!!), true, it, video)
@ -172,7 +177,9 @@ class EpisodeOptionsDialogScreen(
)
}
} else {
// yes
logcat(LogPriority.ERROR) { "Error getting links" }
launchUI { context.toast("Video list is missing") }
onDismissEpisodeOptionsDialogScreen()
}
}
}

View file

@ -240,7 +240,7 @@ data class AnimeTrackInfoDialogHomeScreen(
}
}
} catch (e: Exception) {
logcat(LogPriority.ERROR, e) { "Failed to refresh track data mangaId=$animeId" }
logcat(LogPriority.ERROR, e) { "Failed to refresh track data animeId=$animeId" }
withUIContext { context.toast(e.message) }
}
}

View file

@ -69,7 +69,7 @@ class EpisodeLoader {
val video = Video(episode.url, "Local source: ${episode.url}", episode.url, Uri.parse(episode.url))
Observable.just(listOf(video))
} catch (e: Exception) {
errorMessage = e.message ?: "error getting links"
errorMessage = e.message ?: "Error getting links"
Observable.just(emptyList())
}
}

View file

@ -576,7 +576,7 @@ class PlayerActivity :
else -> setVideoList(switchMethod.first!!)
}
} else {
logcat(LogPriority.ERROR) { "Error getting links." }
logcat(LogPriority.ERROR) { "Error getting links" }
}
if (isInPipMode && playerPreferences.pipEpisodeToasts().get()) {

View file

@ -268,7 +268,7 @@ class PlayerViewModel(
currentVideoList = EpisodeLoader.getLinks(currentEpisode.toDomainEpisode()!!, anime, source).asFlow().first()
episodeId = currentEpisode.id!!
} catch (e: Exception) {
logcat(LogPriority.ERROR, e) { e.message ?: "Error getting links." }
logcat(LogPriority.ERROR, e) { e.message ?: "Error getting links" }
}
Pair(currentVideoList, anime.title + " - " + episodeList[index + 1].name)
@ -289,7 +289,7 @@ class PlayerViewModel(
currentVideoList = EpisodeLoader.getLinks(currentEpisode.toDomainEpisode()!!, anime, source).asFlow().first()
episodeId = currentEpisode.id!!
} catch (e: Exception) {
logcat(LogPriority.ERROR, e) { e.message ?: "Error getting links." }
logcat(LogPriority.ERROR, e) { e.message ?: "Error getting links" }
}
Pair(currentVideoList, anime.title + " - " + episodeList[index - 1].name)
}