From faff8b6f0b39f553d0f7b8a32e34abcc71c95474 Mon Sep 17 00:00:00 2001 From: Quickdesh Date: Tue, 30 May 2023 20:07:46 +0530 Subject: [PATCH] fix null check --- .../entries/anime/EpisodeOptionsDialogScreen.kt | 11 +++++++++-- .../ui/entries/anime/track/AnimeTrackInfoDialog.kt | 2 +- .../eu/kanade/tachiyomi/ui/player/EpisodeLoader.kt | 2 +- .../eu/kanade/tachiyomi/ui/player/PlayerActivity.kt | 2 +- .../eu/kanade/tachiyomi/ui/player/PlayerViewModel.kt | 4 ++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/entries/anime/EpisodeOptionsDialogScreen.kt b/app/src/main/java/eu/kanade/presentation/entries/anime/EpisodeOptionsDialogScreen.kt index 6afcf37fe..53f9ad3e2 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/anime/EpisodeOptionsDialogScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/anime/EpisodeOptionsDialogScreen.kt @@ -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>? = 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() } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/track/AnimeTrackInfoDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/track/AnimeTrackInfoDialog.kt index 605a1c9b1..1c4a5898d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/track/AnimeTrackInfoDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/track/AnimeTrackInfoDialog.kt @@ -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) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/EpisodeLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/EpisodeLoader.kt index 50cf5eb22..c9a1dc299 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/EpisodeLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/EpisodeLoader.kt @@ -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()) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt index d5419c2df..03c7fe1ea 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt @@ -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()) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerViewModel.kt index 6f48db24d..6b088c69b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerViewModel.kt @@ -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) }