From 37e1834e2ab4c5b4c4272ff5d90499fabe6ae275 Mon Sep 17 00:00:00 2001 From: Quickdev Date: Sat, 9 Nov 2024 07:27:18 -0500 Subject: [PATCH] fix: Safe intent extra checks (#1816) --- .../java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt | 8 ++++---- .../java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt index 5ec9247c21..c94b214a11 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt @@ -72,11 +72,11 @@ class ExternalIntents { */ suspend fun getExternalIntent( context: Context, - animeId: Long?, - episodeId: Long?, + animeId: Long, + episodeId: Long, chosenVideo: Video?, ): Intent? { - anime = getAnime.await(animeId!!) ?: return null + anime = getAnime.await(animeId) ?: return null source = sourceManager.get(anime.source) ?: return null episode = getEpisodesByAnimeId.await(anime.id).find { it.id == episodeId } ?: return null @@ -555,7 +555,7 @@ class ExternalIntents { * @param animeId the id of the anime. * @param episodeId the id of the episode. */ - suspend fun newIntent(context: Context, animeId: Long?, episodeId: Long?, video: Video?): Intent? { + suspend fun newIntent(context: Context, animeId: Long, episodeId: Long, video: Video?): Intent? { return externalIntents.getExternalIntent(context, animeId, episodeId, video) } } 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 d6aa857ea9..940995035d 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 @@ -147,10 +147,10 @@ class PlayerActivity : BaseActivity() { } override fun onNewIntent(intent: Intent) { - val animeId = intent.extras!!.getLong("animeId", -1) - val episodeId = intent.extras!!.getLong("episodeId", -1) - val vidList = intent.extras!!.getString("vidList", "") - val vidIndex = intent.extras!!.getInt("vidIndex", 0) + val animeId = intent.extras?.getLong("animeId") ?: -1 + val episodeId = intent.extras?.getLong("episodeId") ?: -1 + val vidList = intent.extras?.getString("vidList") ?: "" + val vidIndex = intent.extras?.getInt("vidIndex") ?: 0 if (animeId == -1L || episodeId == -1L) { finish() return