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 Jul 6, 2024
1 parent 2dd6570 commit 924846c
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 @@ -148,6 +148,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 {
viewModel.togglePlayed()
}
Expand Down Expand Up @@ -421,6 +425,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 @@ -223,6 +223,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 @@ -63,6 +64,7 @@ suspend fun BaseItemDto.toFindroidEpisode(
premiereDate = premiereDate,
seriesName = seriesName.orEmpty(),
seriesId = seriesId!!,
seasonName = seasonName,
seasonId = seasonId!!,
communityRating = communityRating?.let { Math.round(it * 10).div(10F) },
missing = locationType == LocationType.VIRTUAL,
Expand Down Expand Up @@ -102,6 +104,7 @@ fun FindroidEpisodeDto.toFindroidEpisode(database: ServerDatabaseDao, userId: UU
premiereDate = premiereDate,
seriesName = seriesName,
seriesId = seriesId,
seasonName = null,
seasonId = seasonId,
communityRating = communityRating,
images = FindroidImages(),
Expand Down

0 comments on commit 924846c

Please sign in to comment.