-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[Wear] Adds episode screen #1350
Conversation
kul3r4
commented
Apr 18, 2024
- Adds episode screen
- Adds capability to delete the queue
- Removes playback speed change from entity screen (will be added to Player screen in another PR)
- Refactor state classes to state interfaces for consistencies
@@ -129,6 +133,35 @@ class MockEpisodePlayer( | |||
next() | |||
} | |||
|
|||
override fun play(playerEpisodes: List<PlayerEpisode>) { | |||
if (isPlaying.value) { |
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.
Maybe you could...
never mind...
I'm not 100% convinced this is the exact logic I'd expect in a player, but seems fine.
Jetcaster/wear/src/main/java/com/example/jetcaster/ui/library/LatestEpisodeViewModel.kt
Outdated
Show resolved
Hide resolved
Jetcaster/wear/src/main/java/com/example/jetcaster/ui/library/LatestEpisodesScreen.kt
Outdated
Show resolved
Hide resolved
@@ -62,7 +65,7 @@ class PodcastDetailsViewModel @Inject constructor( | |||
) : ViewModel() { | |||
|
|||
private val podcastUri: String = | |||
savedStateHandle.get<String>(PodcastDetails.podcastUri).let { | |||
savedStateHandle.get<String>(PodcastDetails.PODCAST_URI).let { | |||
Uri.decode(it) |
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.
We should check, I suspect decode is done already. But encoding is needed when you use a string template.
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.
good question, in https://github.com/android/compose-samples/blob/main/Jetcaster/app/src/main/java/com/example/jetcaster/ui/player/PlayerViewModel.kt#L57 the URI is decoded. @arriolac shall we remove it everywhere?
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.
We encode the URI when we navigate (e.g. https://github.com/android/compose-samples/blob/main/Jetcaster/app/src/main/java/com/example/jetcaster/ui/JetcasterAppState.kt#L79) so decoding should be done in the receiver (view model)
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.
Isn't that because you are providing a string template, so must be already encoded?
object Player : Screen("player/{$ARG_EPISODE_URI}") {
fun createRoute(episodeUri: String) = "player/$episodeUri"
}
But I thought the navigation library decodes for you. Is it different for SavedStateHandle?
https://stackoverflow.com/a/68951045
https://android-review.git.corp.google.com/c/platform/frameworks/support/+/1949864
That maybe explains a bug in one of our screen titles, but a nasty API design if so.
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.
Oh TIL that it is already decoded. If so, then yes we wouldn't need to decode. Something to double check @kul3r4
modifier = modifier | ||
) { | ||
when (uiState) { | ||
is EpisodeScreenState.Loaded -> { |
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.
Are some of these screens very similar structurally? Could the UIState represent the different screens and reuse the same screen composable?
ac3bd25
to
d305b08
Compare
Jetcaster/core/src/main/java/com/example/jetcaster/core/player/MockEpisodePlayer.kt
Outdated
Show resolved
Hide resolved
Jetcaster/core/src/main/java/com/example/jetcaster/core/player/MockEpisodePlayer.kt
Show resolved
Hide resolved
Jetcaster/wear/src/main/java/com/example/jetcaster/ui/episode/EpisodeScreen.kt
Outdated
Show resolved
Hide resolved
Jetcaster/wear/src/main/java/com/example/jetcaster/ui/episode/EpisodeScreen.kt
Outdated
Show resolved
Hide resolved
d305b08
to
e690662
Compare