Rename music widget VM methods
This commit is contained in:
parent
b9054f04cd
commit
42c1ec3ce1
@ -90,7 +90,7 @@ fun MusicWidget() {
|
|||||||
) {
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
viewModel.onPreviousClick()
|
viewModel.skipPrevious()
|
||||||
}) {
|
}) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Rounded.SkipPrevious,
|
imageVector = Icons.Rounded.SkipPrevious,
|
||||||
@ -98,14 +98,14 @@ fun MusicWidget() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
val playPauseIcon = AnimatedImageVector.animatedVectorResource(R.drawable.anim_ic_play_pause)
|
val playPauseIcon = AnimatedImageVector.animatedVectorResource(R.drawable.anim_ic_play_pause)
|
||||||
IconButton(onClick = { viewModel.onPlayClick() }) {
|
IconButton(onClick = { viewModel.togglePause() }) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = rememberAnimatedVectorPainter(playPauseIcon, atEnd = playbackState == PlaybackState.Playing),
|
painter = rememberAnimatedVectorPainter(playPauseIcon, atEnd = playbackState == PlaybackState.Playing),
|
||||||
contentDescription = ""
|
contentDescription = ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
IconButton(onClick = {
|
IconButton(onClick = {
|
||||||
viewModel.onNextClick()
|
viewModel.skipNext()
|
||||||
}) {
|
}) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Rounded.SkipNext,
|
imageVector = Icons.Rounded.SkipNext,
|
||||||
@ -119,10 +119,10 @@ fun MusicWidget() {
|
|||||||
.size(144.dp)
|
.size(144.dp)
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
onClick = {
|
onClick = {
|
||||||
viewModel.onAlbumArtClick()
|
viewModel.openPlayer()
|
||||||
},
|
},
|
||||||
onLongClick = {
|
onLongClick = {
|
||||||
viewModel.onAlbumArtLongClick(context)
|
viewModel.openPlayerSelector(context)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.conditional(
|
.conditional(
|
||||||
|
|||||||
@ -21,19 +21,19 @@ class MusicWidgetVM: ViewModel(), KoinComponent {
|
|||||||
val albumArt: LiveData<Bitmap?> = musicRepository.albumArt.asLiveData()
|
val albumArt: LiveData<Bitmap?> = musicRepository.albumArt.asLiveData()
|
||||||
val playbackState: LiveData<PlaybackState> = musicRepository.playbackState.asLiveData()
|
val playbackState: LiveData<PlaybackState> = musicRepository.playbackState.asLiveData()
|
||||||
|
|
||||||
fun onPreviousClick() {
|
fun skipPrevious() {
|
||||||
musicRepository.previous()
|
musicRepository.previous()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onNextClick() {
|
fun skipNext() {
|
||||||
musicRepository.next()
|
musicRepository.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onPlayClick() {
|
fun togglePause() {
|
||||||
musicRepository.togglePause()
|
musicRepository.togglePause()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onAlbumArtClick() {
|
fun openPlayer() {
|
||||||
try {
|
try {
|
||||||
musicRepository.getLaunchIntent().send()
|
musicRepository.getLaunchIntent().send()
|
||||||
} catch (e: PendingIntent.CanceledException) {
|
} catch (e: PendingIntent.CanceledException) {
|
||||||
@ -41,7 +41,7 @@ class MusicWidgetVM: ViewModel(), KoinComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onAlbumArtLongClick(context: Context) {
|
fun openPlayerSelector(context: Context) {
|
||||||
musicRepository.openPlayerChooser(context)
|
musicRepository.openPlayerChooser(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user