From c517947fd66004433ab563aacf401e66e88b5578 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Wed, 6 Dec 2023 22:54:45 +0900 Subject: [PATCH 01/13] =?UTF-8?q?feat=20:=20PlayerUtil.kt=EC=97=90=20chang?= =?UTF-8?q?eMoveBtnState=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../catchytape/feature/player/PlayerUtil.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt index 5cffd9d..3fd766b 100644 --- a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt +++ b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt @@ -1,5 +1,6 @@ package com.ohdodok.catchytape.feature.player +import android.widget.Button import androidx.core.net.toUri import androidx.media3.common.MediaItem import androidx.media3.common.MediaMetadata @@ -20,6 +21,31 @@ fun ExoPlayer.movePreviousMedia() { } } +fun ExoPlayer.changeMoveBtnState(nextBtn: Button, previousBtn: Button) { + if (nextMediaItemIndex == -1) { + moveBtnUnable(nextBtn) + } else { + moveBtnEnable(nextBtn) + } + + if (previousMediaItemIndex == -1) { + moveBtnUnable(previousBtn) + } else { + moveBtnEnable(previousBtn) + } +} + +private fun moveBtnUnable(button: Button) { + button.isEnabled = false + button.alpha = 0.3f +} + +private fun moveBtnEnable(button: Button) { + button.isEnabled = true + button.alpha = 1.0f +} + + fun getMediasWithMetaData(musics: List): List { val mediaItemBuilder = MediaItem.Builder() val mediaMetadataBuilder = MediaMetadata.Builder() From 8b650f1ec6eacdedd8620b1548670f1697997523 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Wed, 6 Dec 2023 22:54:57 +0900 Subject: [PATCH 02/13] =?UTF-8?q?feat=20:=20changeMoveBtnState=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ohdodok/catchytape/feature/player/PlayerFragment.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt index 71d048d..e4c66ed 100644 --- a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt +++ b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt @@ -48,6 +48,8 @@ class PlayerFragment : BaseFragment(R.layout.fragment_pla } private fun setupButtons() { + player.changeMoveBtnState(binding.btnNext, binding.btnPrevious) + binding.btnPlay.setOnClickListener { if (viewModel.uiState.value.isPlaying) player.pause() else player.play() @@ -59,10 +61,12 @@ class PlayerFragment : BaseFragment(R.layout.fragment_pla binding.btnNext.setOnClickListener { player.moveNextMedia() + player.changeMoveBtnState(binding.btnNext, binding.btnPrevious) } binding.btnPrevious.setOnClickListener { player.movePreviousMedia() + player.changeMoveBtnState(binding.btnNext, binding.btnPrevious) } } From 685d82759d78f37beecb9d6feaf9f9d59c0b4859 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Wed, 6 Dec 2023 23:24:55 +0900 Subject: [PATCH 03/13] =?UTF-8?q?feat=20:=20binding=20view=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ohdodok/catchytape/feature/player/PlayerControlView.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerControlView.kt b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerControlView.kt index 2cd22df..a15f1e3 100644 --- a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerControlView.kt +++ b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerControlView.kt @@ -15,6 +15,9 @@ class PlayerControlView(context: Context, attrs: AttributeSet) : ConstraintLayou private val binding: ViewPlayerControlBinding = ViewPlayerControlBinding.inflate(LayoutInflater.from(context), this, true) + val moveNextImageView = binding.ibNext + val movePreviousImageView = binding.ibPrevious + val playImageView = binding.ibPlay var music: Music? = null set(value) { From cd1b21162e1938d262423deb8670eb035a7a736a Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Wed, 6 Dec 2023 23:25:24 +0900 Subject: [PATCH 04/13] =?UTF-8?q?feat=20:=20changePlayBtnState=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=ED=95=A8=EC=88=98=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../catchytape/feature/player/PlayerUtil.kt | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt index 3fd766b..521bbf0 100644 --- a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt +++ b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt @@ -1,6 +1,6 @@ package com.ohdodok.catchytape.feature.player -import android.widget.Button +import android.view.View import androidx.core.net.toUri import androidx.media3.common.MediaItem import androidx.media3.common.MediaMetadata @@ -21,28 +21,36 @@ fun ExoPlayer.movePreviousMedia() { } } -fun ExoPlayer.changeMoveBtnState(nextBtn: Button, previousBtn: Button) { +private fun unableBtn(button: View) { + button.isEnabled = false + button.alpha = 0.3f +} + +private fun enableBtn(button: View) { + button.isEnabled = true + button.alpha = 1.0f +} + +fun ExoPlayer.changeMoveBtnState(nextBtn: View, previousBtn: View) { if (nextMediaItemIndex == -1) { - moveBtnUnable(nextBtn) + unableBtn(nextBtn) } else { - moveBtnEnable(nextBtn) + enableBtn(nextBtn) } if (previousMediaItemIndex == -1) { - moveBtnUnable(previousBtn) + unableBtn(previousBtn) } else { - moveBtnEnable(previousBtn) + enableBtn(previousBtn) } } -private fun moveBtnUnable(button: Button) { - button.isEnabled = false - button.alpha = 0.3f -} - -private fun moveBtnEnable(button: Button) { - button.isEnabled = true - button.alpha = 1.0f +fun ExoPlayer.changePlayBtnState(playBtn: View) { + if (currentMediaItem == null) { + unableBtn(playBtn) + } else { + enableBtn(playBtn) + } } From 85f7366301c905b155be5bcde4db6e9fc1153d3d Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Wed, 6 Dec 2023 23:25:33 +0900 Subject: [PATCH 05/13] =?UTF-8?q?feat=20:=20changePlayBtnState=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ohdodok/catchytape/MainActivity.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/java/com/ohdodok/catchytape/MainActivity.kt b/android/app/src/main/java/com/ohdodok/catchytape/MainActivity.kt index 1ef97ab..7fc723c 100644 --- a/android/app/src/main/java/com/ohdodok/catchytape/MainActivity.kt +++ b/android/app/src/main/java/com/ohdodok/catchytape/MainActivity.kt @@ -14,7 +14,6 @@ import androidx.core.view.WindowCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle -import androidx.media3.common.MediaItem import androidx.media3.exoplayer.ExoPlayer import androidx.media3.session.MediaController import androidx.media3.session.SessionToken @@ -25,6 +24,8 @@ import androidx.navigation.ui.setupWithNavController import com.ohdodok.catchytape.databinding.ActivityMainBinding import com.ohdodok.catchytape.feature.player.PlayerListener import com.ohdodok.catchytape.feature.player.PlayerViewModel +import com.ohdodok.catchytape.feature.player.changeMoveBtnState +import com.ohdodok.catchytape.feature.player.changePlayBtnState import com.ohdodok.catchytape.feature.player.getMediasWithMetaData import com.ohdodok.catchytape.feature.player.millisecondsPerSecond import com.ohdodok.catchytape.feature.player.moveNextMedia @@ -32,9 +33,7 @@ import com.ohdodok.catchytape.feature.player.movePreviousMedia import com.ohdodok.catchytape.feature.player.navigateToPlayer import com.ohdodok.catchytape.mediasession.PlaybackService import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.channels.consumeEach import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.launch import javax.inject.Inject @@ -145,6 +144,11 @@ class MainActivity : AppCompatActivity() { private fun showPlayerController() { binding.pcvController.visibility = View.VISIBLE + player.changePlayBtnState(binding.pcvController.playImageView) + player.changeMoveBtnState( + binding.pcvController.moveNextImageView, + binding.pcvController.movePreviousImageView + ) } private fun setupPlayer() { @@ -187,17 +191,26 @@ class MainActivity : AppCompatActivity() { if (playViewModel.uiState.value.isPlaying) player.pause() else player.play() } + player.changePlayBtnState(binding.pcvController.playImageView) } private fun setupPreviousButton() { binding.pcvController.setOnPreviousButtonClick { player.movePreviousMedia() + player.changeMoveBtnState( + binding.pcvController.moveNextImageView, + binding.pcvController.movePreviousImageView + ) } } private fun setupNextButton() { binding.pcvController.setOnNextButtonClick { player.moveNextMedia() + player.changeMoveBtnState( + binding.pcvController.moveNextImageView, + binding.pcvController.movePreviousImageView + ) } } } \ No newline at end of file From 966fb1e45efd56eaff5149c169842f77ef89ab58 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Wed, 6 Dec 2023 23:26:41 +0900 Subject: [PATCH 06/13] =?UTF-8?q?refactor=20:=20=EA=B0=9C=ED=96=89=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt index 521bbf0..db4c0c1 100644 --- a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt +++ b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt @@ -53,7 +53,6 @@ fun ExoPlayer.changePlayBtnState(playBtn: View) { } } - fun getMediasWithMetaData(musics: List): List { val mediaItemBuilder = MediaItem.Builder() val mediaMetadataBuilder = MediaMetadata.Builder() From 91af277645623145bba297280ff3b78adcf07f4c Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Thu, 7 Dec 2023 13:17:27 +0900 Subject: [PATCH 07/13] =?UTF-8?q?feat=20:=20player=20icon=20selector=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/ui/src/main/res/drawable/ic_next.xml | 30 +++++++++++----- .../core/ui/src/main/res/drawable/ic_play.xml | 34 ++++++++++++++----- .../ui/src/main/res/drawable/ic_previous.xml | 30 +++++++++++----- 3 files changed, 67 insertions(+), 27 deletions(-) diff --git a/android/core/ui/src/main/res/drawable/ic_next.xml b/android/core/ui/src/main/res/drawable/ic_next.xml index a0f7a6f..e586993 100644 --- a/android/core/ui/src/main/res/drawable/ic_next.xml +++ b/android/core/ui/src/main/res/drawable/ic_next.xml @@ -1,9 +1,21 @@ - - - + + + + + + + + + + + + + diff --git a/android/core/ui/src/main/res/drawable/ic_play.xml b/android/core/ui/src/main/res/drawable/ic_play.xml index 02fb731..b32ab74 100644 --- a/android/core/ui/src/main/res/drawable/ic_play.xml +++ b/android/core/ui/src/main/res/drawable/ic_play.xml @@ -1,9 +1,25 @@ - - - + + + + + + + + + + + + + diff --git a/android/core/ui/src/main/res/drawable/ic_previous.xml b/android/core/ui/src/main/res/drawable/ic_previous.xml index 5e76bb2..dd9dc3a 100644 --- a/android/core/ui/src/main/res/drawable/ic_previous.xml +++ b/android/core/ui/src/main/res/drawable/ic_previous.xml @@ -1,9 +1,21 @@ - - - + + + + + + + + + + + + + From 1321832d6648cf41b89e179d6100dcdd994a9381 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Thu, 7 Dec 2023 13:17:46 +0900 Subject: [PATCH 08/13] feat : AppCompatButton -> ImageButton --- .../feature/player/PlayerFragment.kt | 12 +++--- .../src/main/res/layout/fragment_player.xml | 39 ++++++++++--------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt index e4c66ed..2704ade 100644 --- a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt +++ b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt @@ -48,9 +48,9 @@ class PlayerFragment : BaseFragment(R.layout.fragment_pla } private fun setupButtons() { - player.changeMoveBtnState(binding.btnNext, binding.btnPrevious) + player.changeMoveBtnState(binding.ibNext, binding.ibPrevious) - binding.btnPlay.setOnClickListener { + binding.ibPlay.setOnClickListener { if (viewModel.uiState.value.isPlaying) player.pause() else player.play() } @@ -59,14 +59,14 @@ class PlayerFragment : BaseFragment(R.layout.fragment_pla findNavController().popBackStack() } - binding.btnNext.setOnClickListener { + binding.ibNext.setOnClickListener { player.moveNextMedia() - player.changeMoveBtnState(binding.btnNext, binding.btnPrevious) + player.changeMoveBtnState(binding.ibNext, binding.ibPrevious) } - binding.btnPrevious.setOnClickListener { + binding.ibPrevious.setOnClickListener { player.movePreviousMedia() - player.changeMoveBtnState(binding.btnNext, binding.btnPrevious) + player.changeMoveBtnState(binding.ibNext, binding.ibPrevious) } } diff --git a/android/feature/player/src/main/res/layout/fragment_player.xml b/android/feature/player/src/main/res/layout/fragment_player.xml index 2200564..95e7cd8 100644 --- a/android/feature/player/src/main/res/layout/fragment_player.xml +++ b/android/feature/player/src/main/res/layout/fragment_player.xml @@ -137,38 +137,39 @@ app:seconds="@{viewModel.uiState.duration}" tools:text="2:04" /> - - - - + + + android:background="@android:color/transparent" + android:src="@drawable/ic_next" + app:layout_constraintBottom_toBottomOf="@id/ib_play" + app:layout_constraintStart_toEndOf="@id/ib_play" + app:layout_constraintTop_toTopOf="@id/ib_play" /> + \ No newline at end of file From 55fe7df1c9f8164b57a8bc0ff6edc10e1645a5d1 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Thu, 7 Dec 2023 14:16:19 +0900 Subject: [PATCH 09/13] =?UTF-8?q?feat=20:=20PlayerState=20=EC=97=90=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../catchytape/feature/player/PlayerViewModel.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 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 e5df8f2..52fd93e 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 @@ -25,7 +25,13 @@ data class PlayerState( val isPlaying: Boolean = false, val currentPositionSecond: Int = 0, val duration: Int = 0, -) + val isNextEnable: Boolean = false, + val isPreviousEnable: Boolean = false + +) { + val isPlayEnable: Boolean + get() = currentMusic != null +} sealed interface PlayerEvent { data class ShowError(val error: CtErrorType) : PlayerEvent @@ -77,7 +83,12 @@ class PlayerViewModel @Inject constructor( override fun onMediaItemChanged(index: Int, duration: Int) { currentPlaylist.value?.let { playlist -> _uiState.update { - it.copy(duration = duration, currentMusic = playlist.musics[index]) + it.copy( + duration = duration, + currentMusic = playlist.musics[index], + isNextEnable = playlist.musics.size != index + 1, + isPreviousEnable = index != 0 + ) } } } From 1b4fe4baba67a08e98885eccf30fddf49def2f48 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Thu, 7 Dec 2023 14:16:34 +0900 Subject: [PATCH 10/13] =?UTF-8?q?refactor=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../catchytape/feature/player/PlayerUtil.kt | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt index db4c0c1..5cffd9d 100644 --- a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt +++ b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerUtil.kt @@ -1,6 +1,5 @@ package com.ohdodok.catchytape.feature.player -import android.view.View import androidx.core.net.toUri import androidx.media3.common.MediaItem import androidx.media3.common.MediaMetadata @@ -21,38 +20,6 @@ fun ExoPlayer.movePreviousMedia() { } } -private fun unableBtn(button: View) { - button.isEnabled = false - button.alpha = 0.3f -} - -private fun enableBtn(button: View) { - button.isEnabled = true - button.alpha = 1.0f -} - -fun ExoPlayer.changeMoveBtnState(nextBtn: View, previousBtn: View) { - if (nextMediaItemIndex == -1) { - unableBtn(nextBtn) - } else { - enableBtn(nextBtn) - } - - if (previousMediaItemIndex == -1) { - unableBtn(previousBtn) - } else { - enableBtn(previousBtn) - } -} - -fun ExoPlayer.changePlayBtnState(playBtn: View) { - if (currentMediaItem == null) { - unableBtn(playBtn) - } else { - enableBtn(playBtn) - } -} - fun getMediasWithMetaData(musics: List): List { val mediaItemBuilder = MediaItem.Builder() val mediaMetadataBuilder = MediaMetadata.Builder() From 687d4fdf91db3fceca5c75675af7b8fd88c76119 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Thu, 7 Dec 2023 14:17:22 +0900 Subject: [PATCH 11/13] =?UTF-8?q?feat=20:=20enabled,=20DataBinding=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/player/PlayerControlView.kt | 21 ++++++++++++++++--- .../feature/player/PlayerFragment.kt | 4 ---- .../src/main/res/layout/fragment_player.xml | 2 ++ .../main/res/layout/view_player_control.xml | 3 +-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerControlView.kt b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerControlView.kt index a15f1e3..65202e6 100644 --- a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerControlView.kt +++ b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerControlView.kt @@ -15,9 +15,6 @@ class PlayerControlView(context: Context, attrs: AttributeSet) : ConstraintLayou private val binding: ViewPlayerControlBinding = ViewPlayerControlBinding.inflate(LayoutInflater.from(context), this, true) - val moveNextImageView = binding.ibNext - val movePreviousImageView = binding.ibPrevious - val playImageView = binding.ibPlay var music: Music? = null set(value) { @@ -50,6 +47,24 @@ class PlayerControlView(context: Context, attrs: AttributeSet) : ConstraintLayou binding.lpiPlayerProgress.max = value } + var nextEnabled: Boolean = false + set(value) { + field = value + binding.ibNext.isEnabled = value + } + + var playEnabled: Boolean = false + set(value) { + field = value + binding.ibPlay.isEnabled = value + } + + var previousEnabled: Boolean = false + set(value) { + field = value + binding.ibPrevious.isEnabled = value + } + fun setOnPlayButtonClick(onPlayButtonClick: () -> Unit) { binding.ibPlay.setOnClickListener { onPlayButtonClick() } } diff --git a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt index 2704ade..9219cec 100644 --- a/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt +++ b/android/feature/player/src/main/java/com/ohdodok/catchytape/feature/player/PlayerFragment.kt @@ -48,8 +48,6 @@ class PlayerFragment : BaseFragment(R.layout.fragment_pla } private fun setupButtons() { - player.changeMoveBtnState(binding.ibNext, binding.ibPrevious) - binding.ibPlay.setOnClickListener { if (viewModel.uiState.value.isPlaying) player.pause() else player.play() @@ -61,12 +59,10 @@ class PlayerFragment : BaseFragment(R.layout.fragment_pla binding.ibNext.setOnClickListener { player.moveNextMedia() - player.changeMoveBtnState(binding.ibNext, binding.ibPrevious) } binding.ibPrevious.setOnClickListener { player.movePreviousMedia() - player.changeMoveBtnState(binding.ibNext, binding.ibPrevious) } } diff --git a/android/feature/player/src/main/res/layout/fragment_player.xml b/android/feature/player/src/main/res/layout/fragment_player.xml index 95e7cd8..25a3ff0 100644 --- a/android/feature/player/src/main/res/layout/fragment_player.xml +++ b/android/feature/player/src/main/res/layout/fragment_player.xml @@ -154,6 +154,7 @@ android:layout_height="24dp" android:layout_marginEnd="40dp" android:background="@android:color/transparent" + android:enabled="@{viewModel.uiState.isPreviousEnable}" android:src="@drawable/ic_previous" app:layout_constraintBottom_toBottomOf="@id/ib_play" app:layout_constraintEnd_toStartOf="@id/ib_play" @@ -165,6 +166,7 @@ android:layout_height="24dp" android:layout_marginStart="40dp" android:background="@android:color/transparent" + android:enabled="@{viewModel.uiState.isNextEnable}" android:src="@drawable/ic_next" app:layout_constraintBottom_toBottomOf="@id/ib_play" app:layout_constraintStart_toEndOf="@id/ib_play" diff --git a/android/feature/player/src/main/res/layout/view_player_control.xml b/android/feature/player/src/main/res/layout/view_player_control.xml index 461487c..aa6bd4e 100644 --- a/android/feature/player/src/main/res/layout/view_player_control.xml +++ b/android/feature/player/src/main/res/layout/view_player_control.xml @@ -77,8 +77,7 @@ android:src="@drawable/ic_play" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/ib_next" - app:layout_constraintTop_toTopOf="parent" - app:tint="@color/on_surface" /> + app:layout_constraintTop_toTopOf="parent" /> Date: Thu, 7 Dec 2023 14:17:45 +0900 Subject: [PATCH 12/13] =?UTF-8?q?feat=20:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F?= =?UTF-8?q?=20databinding=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ohdodok/catchytape/MainActivity.kt | 16 ---------------- .../app/src/main/res/layout/activity_main.xml | 3 +++ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/android/app/src/main/java/com/ohdodok/catchytape/MainActivity.kt b/android/app/src/main/java/com/ohdodok/catchytape/MainActivity.kt index 7fc723c..32cda95 100644 --- a/android/app/src/main/java/com/ohdodok/catchytape/MainActivity.kt +++ b/android/app/src/main/java/com/ohdodok/catchytape/MainActivity.kt @@ -24,8 +24,6 @@ import androidx.navigation.ui.setupWithNavController import com.ohdodok.catchytape.databinding.ActivityMainBinding import com.ohdodok.catchytape.feature.player.PlayerListener import com.ohdodok.catchytape.feature.player.PlayerViewModel -import com.ohdodok.catchytape.feature.player.changeMoveBtnState -import com.ohdodok.catchytape.feature.player.changePlayBtnState import com.ohdodok.catchytape.feature.player.getMediasWithMetaData import com.ohdodok.catchytape.feature.player.millisecondsPerSecond import com.ohdodok.catchytape.feature.player.moveNextMedia @@ -144,11 +142,6 @@ class MainActivity : AppCompatActivity() { private fun showPlayerController() { binding.pcvController.visibility = View.VISIBLE - player.changePlayBtnState(binding.pcvController.playImageView) - player.changeMoveBtnState( - binding.pcvController.moveNextImageView, - binding.pcvController.movePreviousImageView - ) } private fun setupPlayer() { @@ -191,26 +184,17 @@ class MainActivity : AppCompatActivity() { if (playViewModel.uiState.value.isPlaying) player.pause() else player.play() } - player.changePlayBtnState(binding.pcvController.playImageView) } private fun setupPreviousButton() { binding.pcvController.setOnPreviousButtonClick { player.movePreviousMedia() - player.changeMoveBtnState( - binding.pcvController.moveNextImageView, - binding.pcvController.movePreviousImageView - ) } } private fun setupNextButton() { binding.pcvController.setOnNextButtonClick { player.moveNextMedia() - player.changeMoveBtnState( - binding.pcvController.moveNextImageView, - binding.pcvController.movePreviousImageView - ) } } } \ No newline at end of file diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml index 29d74d0..4fcaf14 100644 --- a/android/app/src/main/res/layout/activity_main.xml +++ b/android/app/src/main/res/layout/activity_main.xml @@ -40,7 +40,10 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:music="@{viewModel.uiState.currentMusic}" + app:nextEnabled="@{viewModel.uiState.nextEnable}" + app:playEnabled="@{viewModel.uiState.playEnable}" app:playing="@{viewModel.uiState.isPlaying}" + app:previousEnabled="@{viewModel.uiState.previousEnable}" app:progress="@{viewModel.uiState.currentPositionSecond}" /> Date: Thu, 7 Dec 2023 16:56:06 +0900 Subject: [PATCH 13/13] =?UTF-8?q?refactor=20:=20list.size=20=EB=8C=80?= =?UTF-8?q?=EC=8B=A0,=20lastIndex=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ohdodok/catchytape/feature/player/PlayerViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 52fd93e..ec1fea1 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 @@ -86,7 +86,7 @@ class PlayerViewModel @Inject constructor( it.copy( duration = duration, currentMusic = playlist.musics[index], - isNextEnable = playlist.musics.size != index + 1, + isNextEnable = playlist.musics.lastIndex != index, isPreviousEnable = index != 0 ) }