-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show playing tab when current chapter is tapped #59
Show playing tab when current chapter is tapped #59
Conversation
} | ||
|
||
fun onPlayerShown() { | ||
showPlayerObservable.accept(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't used it before but is this where you could use one of the new SharedFlow classes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, SharedFlow
can be a good candidate here. Thanks for suggesting it. Used it in e058f41.
@@ -186,6 +186,12 @@ open class PlaybackManager @Inject constructor( | |||
return upNextQueue.currentEpisode | |||
} | |||
|
|||
private suspend fun getCurrentChapter() = getCurrentEpisode()?.let { episode -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's possible to get the current chapter with the data already in the PlayerViewModel.
fun onChapterClick(chapter: Chapter) {
launch {
val listData = listDataLive.value
if (listData?.isSameChapter(chapter) == true) {
showPlayerObservable.accept(true)
} else {
playbackManager.skipToChapter(chapter)
}
}
}
data class ListData(
var podcastHeader: PlayerHeader,
var chaptersExpanded: Boolean,
var chapters: List<Chapter>,
var currentChapter: Chapter?,
var upNextExpanded: Boolean,
var upNextEpisodes: List<Playable>,
var upNextSummary: UpNextSummary,
var showPlayer: Boolean,
) {
fun isSameChapter(chapter: Chapter) = currentChapter?
.let { it.index == chapter.index } ?: false
}
val currentChapter = playbackState.chapters.getChapter(playbackState.positionMs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks better, see in fb81785.
d418b37
to
3b358e1
Compare
…click # Conflicts: # RELEASE-NOTES.md
Fixes #41
Description
Clicking a current chapter would start the chapter from the beginning. This PR addresses the issue by navigating to the "Now Playing" tab if the chapter clicked is the current one.
show-player-tab-on-current-chapter-click.mp4
P.S. I updated
ListData
UI state with theshowPlayer
value based on this principle:I couldn't find a good example in the existing code for handling
ViewModel
events. So feel free to point me in the right direction. 😅Checklist