mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-28 17:19:00 +03:00
fix null check
This commit is contained in:
parent
1d1aa51de3
commit
faff8b6f0b
5 changed files with 14 additions and 7 deletions
|
@ -47,10 +47,14 @@ import eu.kanade.tachiyomi.data.download.anime.AnimeDownloadManager
|
||||||
import eu.kanade.tachiyomi.source.anime.AnimeSourceManager
|
import eu.kanade.tachiyomi.source.anime.AnimeSourceManager
|
||||||
import eu.kanade.tachiyomi.ui.player.EpisodeLoader
|
import eu.kanade.tachiyomi.ui.player.EpisodeLoader
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import logcat.LogPriority
|
||||||
|
import tachiyomi.core.util.lang.launchUI
|
||||||
import tachiyomi.core.util.lang.withIOContext
|
import tachiyomi.core.util.lang.withIOContext
|
||||||
|
import tachiyomi.core.util.system.logcat
|
||||||
import tachiyomi.domain.entries.anime.model.Anime
|
import tachiyomi.domain.entries.anime.model.Anime
|
||||||
import tachiyomi.domain.items.episode.model.Episode
|
import tachiyomi.domain.items.episode.model.Episode
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
|
@ -120,6 +124,7 @@ class EpisodeOptionsDialogScreen(
|
||||||
val resultList: Result<List<Video>>? = null,
|
val resultList: Result<List<Video>>? = null,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun EpisodeOptionsDialog(
|
fun EpisodeOptionsDialog(
|
||||||
episode: Episode?,
|
episode: Episode?,
|
||||||
|
@ -151,7 +156,7 @@ class EpisodeOptionsDialogScreen(
|
||||||
LoadingScreen()
|
LoadingScreen()
|
||||||
} else {
|
} else {
|
||||||
val videoList = resultList.getOrNull()
|
val videoList = resultList.getOrNull()
|
||||||
if (videoList != null) {
|
if (!videoList.isNullOrEmpty()) {
|
||||||
videoList.forEach { video ->
|
videoList.forEach { video ->
|
||||||
val downloadEpisode: (Boolean) -> Unit = {
|
val downloadEpisode: (Boolean) -> Unit = {
|
||||||
downloadManager.downloadEpisodes(anime!!, listOf(episode!!), true, it, video)
|
downloadManager.downloadEpisodes(anime!!, listOf(episode!!), true, it, video)
|
||||||
|
@ -172,7 +177,9 @@ class EpisodeOptionsDialogScreen(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// yes
|
logcat(LogPriority.ERROR) { "Error getting links" }
|
||||||
|
launchUI { context.toast("Video list is missing") }
|
||||||
|
onDismissEpisodeOptionsDialogScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ data class AnimeTrackInfoDialogHomeScreen(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} 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) }
|
withUIContext { context.toast(e.message) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ class EpisodeLoader {
|
||||||
val video = Video(episode.url, "Local source: ${episode.url}", episode.url, Uri.parse(episode.url))
|
val video = Video(episode.url, "Local source: ${episode.url}", episode.url, Uri.parse(episode.url))
|
||||||
Observable.just(listOf(video))
|
Observable.just(listOf(video))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
errorMessage = e.message ?: "error getting links"
|
errorMessage = e.message ?: "Error getting links"
|
||||||
Observable.just(emptyList())
|
Observable.just(emptyList())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -576,7 +576,7 @@ class PlayerActivity :
|
||||||
else -> setVideoList(switchMethod.first!!)
|
else -> setVideoList(switchMethod.first!!)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logcat(LogPriority.ERROR) { "Error getting links." }
|
logcat(LogPriority.ERROR) { "Error getting links" }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInPipMode && playerPreferences.pipEpisodeToasts().get()) {
|
if (isInPipMode && playerPreferences.pipEpisodeToasts().get()) {
|
||||||
|
|
|
@ -268,7 +268,7 @@ class PlayerViewModel(
|
||||||
currentVideoList = EpisodeLoader.getLinks(currentEpisode.toDomainEpisode()!!, anime, source).asFlow().first()
|
currentVideoList = EpisodeLoader.getLinks(currentEpisode.toDomainEpisode()!!, anime, source).asFlow().first()
|
||||||
episodeId = currentEpisode.id!!
|
episodeId = currentEpisode.id!!
|
||||||
} catch (e: Exception) {
|
} 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)
|
Pair(currentVideoList, anime.title + " - " + episodeList[index + 1].name)
|
||||||
|
@ -289,7 +289,7 @@ class PlayerViewModel(
|
||||||
currentVideoList = EpisodeLoader.getLinks(currentEpisode.toDomainEpisode()!!, anime, source).asFlow().first()
|
currentVideoList = EpisodeLoader.getLinks(currentEpisode.toDomainEpisode()!!, anime, source).asFlow().first()
|
||||||
episodeId = currentEpisode.id!!
|
episodeId = currentEpisode.id!!
|
||||||
} catch (e: Exception) {
|
} 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)
|
Pair(currentVideoList, anime.title + " - " + episodeList[index - 1].name)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue