Skip to content

Commit c05a75f

Browse files
authored
fix(player): Fix npe issue caused in player controls (#1986)
1 parent 3ac6ce7 commit c05a75f

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerViewModel.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,12 @@ class PlayerViewModel @JvmOverloads constructor(
11171117
_hasPreviousEpisode.update { _ -> value }
11181118
}
11191119

1120+
fun showEpisodeListDialog() {
1121+
if (currentAnime.value != null) {
1122+
showDialog(Dialogs.EpisodeList)
1123+
}
1124+
}
1125+
11201126
/**
11211127
* Called when the activity is saved and not changing configurations. It updates the database
11221128
* to persist the current progress of the active episode.

app/src/main/java/eu/kanade/tachiyomi/ui/player/controls/PlayerControls.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ fun PlayerControls(
413413
TopLeftPlayerControls(
414414
animeTitle = animeTitle,
415415
mediaTitle = mediaTitle,
416-
onTitleClick = { viewModel.showDialog(Dialogs.EpisodeList) },
416+
onTitleClick = { viewModel.showEpisodeListDialog() },
417417
onBackClick = onBackPress,
418418
)
419419
}
@@ -614,8 +614,7 @@ fun PlayerControls(
614614

615615
PlayerDialogs(
616616
dialogShown = dialog,
617-
618-
episodeDisplayMode = anime!!.displayMode,
617+
episodeDisplayMode = anime?.displayMode,
619618
episodeList = playlist,
620619
currentEpisodeIndex = viewModel.getCurrentEpisodeIndex(),
621620
dateRelativeTime = viewModel.relativeTime,

app/src/main/java/eu/kanade/tachiyomi/ui/player/controls/PlayerDialogs.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fun PlayerDialogs(
1212
dialogShown: Dialogs,
1313

1414
// Episode list
15-
episodeDisplayMode: Long,
15+
episodeDisplayMode: Long?,
1616
currentEpisodeIndex: Int,
1717
episodeList: List<Episode>,
1818
dateRelativeTime: Boolean,

app/src/main/java/eu/kanade/tachiyomi/ui/player/controls/components/dialogs/EpisodeListDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import java.time.format.DateTimeFormatter
5050

5151
@Composable
5252
fun EpisodeListDialog(
53-
displayMode: Long,
53+
displayMode: Long?,
5454
currentEpisodeIndex: Int,
5555
episodeList: List<Episode>,
5656
dateRelativeTime: Boolean,

0 commit comments

Comments
 (0)