Skip to content

Commit

Permalink
feat: navigate from episode to season
Browse files Browse the repository at this point in the history
clicking episode_name navigates to the season for that episode
seasonName added to episode classes so the opened season view can have it's name
  • Loading branch information
arnokeesman committed Nov 6, 2023
1 parent 6c3360f commit 143199c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() {
navigateToSeries(viewModel.item.seriesId, viewModel.item.seriesName)
}

binding.episodeName.setOnClickListener {
navigateToSeason(viewModel.item.seriesId, viewModel.item.seasonId, viewModel.item.seriesName, viewModel.item.seasonName)
}

binding.itemActions.checkButton.setOnClickListener {
val played = viewModel.togglePlayed()
bindCheckButtonState(played)
Expand Down Expand Up @@ -419,6 +423,17 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() {
)
}

private fun navigateToSeason(seriesId: UUID, seasonId: UUID, seriesName: String, seasonName: String?) {
findNavController().navigate(
EpisodeBottomSheetFragmentDirections.actionEpisodeBottomSheetFragmentToSeasonFragment(
seriesId,
seasonId,
seriesName,
seasonName,
),
)
}

private fun formatDateTime(datetime: DateTime?): String {
if (datetime == null) return ""
val instant = datetime.toInstant(ZoneOffset.UTC)
Expand Down
3 changes: 3 additions & 0 deletions app/phone/src/main/res/navigation/app_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@
<action
android:id="@+id/action_episodeBottomSheetFragment_to_showFragment"
app:destination="@id/showFragment" />
<action
android:id="@+id/action_episodeBottomSheetFragment_to_seasonFragment"
app:destination="@id/seasonFragment" />
</dialog>
<fragment
android:id="@+id/favoriteFragment"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ data class FindroidEpisode(
val premiereDate: DateTime?,
val seriesName: String,
val seriesId: UUID,
val seasonName: String? = null,
val seasonId: UUID,
val communityRating: Float?,
override val unplayedItemCount: Int? = null,
Expand Down Expand Up @@ -60,6 +61,7 @@ suspend fun BaseItemDto.toFindroidEpisode(
premiereDate = premiereDate,
seriesName = seriesName.orEmpty(),
seriesId = seriesId!!,
seasonName = seasonName,
seasonId = seasonId!!,
communityRating = communityRating,
missing = locationType == LocationType.VIRTUAL,
Expand Down Expand Up @@ -89,6 +91,7 @@ fun FindroidEpisodeDto.toFindroidEpisode(database: ServerDatabaseDao, userId: UU
premiereDate = premiereDate,
seriesName = seriesName,
seriesId = seriesId,
seasonName = null,
seasonId = seasonId,
communityRating = communityRating,
)
Expand Down

0 comments on commit 143199c

Please sign in to comment.