From fb2a43e04e3b1f810fa34a074dff7a7f4cf135aa Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Tue, 12 Dec 2023 19:00:36 +0900 Subject: [PATCH 1/4] =?UTF-8?q?chore=20:=20coroutines,=20version=20"1.7.0"?= =?UTF-8?q?=20=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index 8dcdc40..12605b5 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -21,7 +21,7 @@ retrofit = "2.9.0" okhttp = "4.11.0" kotlinx-serialization = "1.6.0" kotlinx-serialization-converter = "1.0.0" -coroutines = "1.3.5" +coroutines = "1.7.0" glide = "4.15.0" timber = "5.0.1" From a37b2293814c2d0ada9a5eb17a8a78af13daee19 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Tue, 12 Dec 2023 19:19:05 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat=20:=20player.release()=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ohdodok/catchytape/mediasession/PlaybackService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/android/app/src/main/java/com/ohdodok/catchytape/mediasession/PlaybackService.kt b/android/app/src/main/java/com/ohdodok/catchytape/mediasession/PlaybackService.kt index 59796f6..028ce69 100644 --- a/android/app/src/main/java/com/ohdodok/catchytape/mediasession/PlaybackService.kt +++ b/android/app/src/main/java/com/ohdodok/catchytape/mediasession/PlaybackService.kt @@ -20,7 +20,6 @@ class PlaybackService : MediaSessionService() { override fun onDestroy() { mediaSession?.run { - player.release() release() mediaSession = null } From 7dba27467dc5fe0155220d98656ba3bee0346da4 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Tue, 12 Dec 2023 19:19:32 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat=20:=20consumeEach=20=EB=8C=80=EC=8B=A0?= =?UTF-8?q?=20->=20for=EB=AC=B8=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ohdodok/catchytape/feature/player/PlayerViewModel.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerViewModel.kt b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerViewModel.kt index 56d9f2a..bf70810 100644 --- a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerViewModel.kt +++ b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerViewModel.kt @@ -10,7 +10,6 @@ import com.ohdodok.catchytape.core.domain.repository.MusicRepository import com.ohdodok.catchytape.core.domain.usecase.player.CurrentPlaylistUseCase import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.CoroutineExceptionHandler -import kotlinx.coroutines.channels.consumeEach import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow @@ -39,12 +38,14 @@ sealed interface PlayerEvent { data class PlaylistChanged(val currentPlaylist: CurrentPlaylist) : PlayerEvent } + @HiltViewModel class PlayerViewModel @Inject constructor( private val currentPlaylistUseCase: CurrentPlaylistUseCase, private val musicRepository: MusicRepository, ) : ViewModel(), PlayerEventListener { + private val _currentPlaylist = MutableStateFlow?>(null) val currentPlaylist: StateFlow?> = _currentPlaylist.asStateFlow() @@ -65,9 +66,9 @@ class PlayerViewModel @Inject constructor( private fun observePlaylistChange() { viewModelScope.launch(exceptionHandler) { - currentPlaylistUseCase.currentPlaylist.consumeEach { - _currentPlaylist.value = it.musics - _events.emit(PlayerEvent.PlaylistChanged(it)) + for (currentPlaylist in currentPlaylistUseCase.currentPlaylist) { + _currentPlaylist.value = currentPlaylist.musics + _events.emit(PlayerEvent.PlaylistChanged(currentPlaylist)) } } } From 16e4fe47f194d0369c56c2108816f5f998d330d5 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Tue, 12 Dec 2023 19:19:54 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat=20:=20=EA=B0=9C=ED=96=89=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/domain/usecase/player/CurrentPlayListUseCase.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/android/core/domain/src/main/java/com/ohdodok/catchytape/core/domain/usecase/player/CurrentPlayListUseCase.kt b/android/core/domain/src/main/java/com/ohdodok/catchytape/core/domain/usecase/player/CurrentPlayListUseCase.kt index d930094..2606b58 100644 --- a/android/core/domain/src/main/java/com/ohdodok/catchytape/core/domain/usecase/player/CurrentPlayListUseCase.kt +++ b/android/core/domain/src/main/java/com/ohdodok/catchytape/core/domain/usecase/player/CurrentPlayListUseCase.kt @@ -23,8 +23,6 @@ class CurrentPlaylistUseCase @Inject constructor() { musics = musics, ) - scope.launch { - _currentPlaylist.send(newPlaylist) - } + scope.launch { _currentPlaylist.send(newPlaylist) } } } \ No newline at end of file