[Now Playing] Fixed Seekbar behaviour
This commit is contained in:
parent
67e5cea649
commit
8b9c8d7855
15 changed files with 128 additions and 182 deletions
|
@ -14,14 +14,17 @@
|
|||
*/
|
||||
package code.name.monkey.retromusic.fragments.base
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.PorterDuff
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateInterpolator
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.core.view.isVisible
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -31,6 +34,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
|
||||
|
@ -51,7 +55,10 @@ abstract class AbsPlayerControlsFragment(@LayoutRes layout: Int) : AbsMusicServi
|
|||
|
||||
var lastDisabledPlaybackControlsColor: Int = 0
|
||||
|
||||
open val seekBar: SeekBar? = null
|
||||
var isSeeking = false
|
||||
private set
|
||||
|
||||
open val progressSlider: SeekBar? = null
|
||||
|
||||
abstract val shuffleButton: ImageButton
|
||||
|
||||
|
@ -61,17 +68,51 @@ abstract class AbsPlayerControlsFragment(@LayoutRes layout: Int) : AbsMusicServi
|
|||
|
||||
open val previousButton: ImageButton? = null
|
||||
|
||||
open val songTotalTime: TextView? = null
|
||||
|
||||
open val songCurrentProgress: TextView? = null
|
||||
|
||||
private var progressAnimator: ObjectAnimator? = null
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
progressSlider?.max = total
|
||||
|
||||
if (isSeeking) {
|
||||
progressSlider?.progress = progress
|
||||
} else {
|
||||
progressAnimator = ObjectAnimator.ofInt(progressSlider, "progress", progress).apply {
|
||||
duration = SLIDER_ANIMATION_TIME
|
||||
interpolator = LinearInterpolator()
|
||||
start()
|
||||
}
|
||||
|
||||
}
|
||||
songTotalTime?.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
songCurrentProgress?.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
private fun setUpProgressSlider() {
|
||||
seekBar?.setOnSeekBarChangeListener(object : SimpleOnSeekbarChangeListener() {
|
||||
progressSlider?.setOnSeekBarChangeListener(object : SimpleOnSeekbarChangeListener() {
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
MusicPlayerRemote.seekTo(progress)
|
||||
onUpdateProgressViews(
|
||||
MusicPlayerRemote.songProgressMillis,
|
||||
progress,
|
||||
MusicPlayerRemote.songDurationMillis
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
isSeeking = true
|
||||
progressViewUpdateHelper.stop()
|
||||
progressAnimator?.cancel()
|
||||
}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||
isSeeking = false
|
||||
MusicPlayerRemote.seekTo(seekBar.progress)
|
||||
progressViewUpdateHelper.start()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.view.View
|
|||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
|
@ -40,7 +41,7 @@ class AdaptivePlaybackControlsFragment :
|
|||
private var _binding: FragmentAdaptivePlayerPlaybackControlsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -55,6 +56,12 @@ class AdaptivePlaybackControlsFragment :
|
|||
override val previousButton: ImageButton
|
||||
get() = binding.previousButton
|
||||
|
||||
override val songTotalTime: TextView
|
||||
get() = binding.songTotalTime
|
||||
|
||||
override val songCurrentProgress: TextView
|
||||
get() = binding.songCurrentProgress
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentAdaptivePlayerPlaybackControlsBinding.bind(view)
|
||||
|
@ -160,18 +167,6 @@ class AdaptivePlaybackControlsFragment :
|
|||
|
||||
override fun hide() {}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
|
|
|
@ -18,13 +18,12 @@ import android.animation.ObjectAnimator
|
|||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateInterpolator
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
|
@ -46,7 +45,7 @@ class BlurPlaybackControlsFragment :
|
|||
private var _binding: FragmentBlurPlayerPlaybackControlsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -61,6 +60,12 @@ class BlurPlaybackControlsFragment :
|
|||
override val previousButton: ImageButton
|
||||
get() = binding.previousButton
|
||||
|
||||
override val songTotalTime: TextView
|
||||
get() = binding.songTotalTime
|
||||
|
||||
override val songCurrentProgress: TextView
|
||||
get() = binding.songCurrentProgress
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentBlurPlayerPlaybackControlsBinding.bind(view)
|
||||
|
@ -179,18 +184,6 @@ class BlurPlaybackControlsFragment :
|
|||
}
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
|
|
|
@ -47,7 +47,7 @@ class CardPlaybackControlsFragment :
|
|||
private var _binding: FragmentCardPlayerPlaybackControlsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -170,18 +170,6 @@ class CardPlaybackControlsFragment :
|
|||
}
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
private fun updateProgressTextColor() {
|
||||
val color = MaterialValueHelper.getPrimaryTextColor(context, false)
|
||||
binding.songTotalTime.setTextColor(color)
|
||||
|
|
|
@ -43,7 +43,7 @@ class CardBlurPlaybackControlsFragment :
|
|||
private var _binding: FragmentCardBlurPlayerPlaybackControlsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -149,18 +149,6 @@ class CardBlurPlaybackControlsFragment :
|
|||
}
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
|
|
|
@ -25,6 +25,7 @@ import android.view.animation.DecelerateInterpolator
|
|||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -48,7 +49,7 @@ class ColorPlaybackControlsFragment :
|
|||
private var _binding: FragmentColorPlayerPlaybackControlsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -63,6 +64,12 @@ class ColorPlaybackControlsFragment :
|
|||
override val previousButton: ImageButton
|
||||
get() = binding.previousButton
|
||||
|
||||
override val songTotalTime: TextView
|
||||
get() = binding.songTotalTime
|
||||
|
||||
override val songCurrentProgress: TextView
|
||||
get() = binding.songCurrentProgress
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentColorPlayerPlaybackControlsBinding.bind(view)
|
||||
|
@ -174,18 +181,6 @@ class ColorPlaybackControlsFragment :
|
|||
}
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
fun createRevealAnimator(view: View): Animator {
|
||||
val location = IntArray(2)
|
||||
binding.playPauseButton.getLocationOnScreen(location)
|
||||
|
|
|
@ -17,12 +17,11 @@ package code.name.monkey.retromusic.fragments.player.fit
|
|||
import android.animation.ObjectAnimator
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateInterpolator
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import androidx.core.view.isVisible
|
||||
import android.widget.TextView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
|
@ -44,7 +43,7 @@ class FitPlaybackControlsFragment :
|
|||
private var _binding: FragmentFitPlaybackControlsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -59,6 +58,12 @@ class FitPlaybackControlsFragment :
|
|||
override val previousButton: ImageButton
|
||||
get() = binding.previousButton
|
||||
|
||||
override val songTotalTime: TextView
|
||||
get() = binding.songTotalTime
|
||||
|
||||
override val songCurrentProgress: TextView
|
||||
get() = binding.songCurrentProgress
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentFitPlaybackControlsBinding.bind(view)
|
||||
|
@ -182,18 +187,6 @@ class FitPlaybackControlsFragment :
|
|||
}
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
|
|
|
@ -45,7 +45,7 @@ class FlatPlaybackControlsFragment :
|
|||
private var _binding: FragmentFlatPlayerPlaybackControlsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -178,18 +178,6 @@ class FlatPlaybackControlsFragment :
|
|||
updateShuffleState()
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.view.animation.DecelerateInterpolator
|
|||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
|
@ -46,7 +47,6 @@ import code.name.monkey.retromusic.fragments.base.goToAlbum
|
|||
import code.name.monkey.retromusic.fragments.base.goToArtist
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
|
@ -70,7 +70,7 @@ class FullPlaybackControlsFragment :
|
|||
private var _binding: FragmentFullPlayerControlsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -85,6 +85,12 @@ class FullPlaybackControlsFragment :
|
|||
override val previousButton: ImageButton
|
||||
get() = binding.previousButton
|
||||
|
||||
override val songTotalTime: TextView
|
||||
get() = binding.songTotalTime
|
||||
|
||||
override val songCurrentProgress: TextView
|
||||
get() = binding.songCurrentProgress
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentFullPlayerControlsBinding.bind(view)
|
||||
|
@ -206,18 +212,6 @@ class FullPlaybackControlsFragment :
|
|||
return (parentFragment as FullPlayerFragment).onMenuItemClick(item!!)
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
override fun onRepeatModeChanged() {
|
||||
updateRepeatState()
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.view.animation.DecelerateInterpolator
|
|||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
|
@ -46,7 +47,7 @@ class LockScreenControlsFragment :
|
|||
private var _binding: FragmentLockScreenPlaybackControlsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -61,6 +62,12 @@ class LockScreenControlsFragment :
|
|||
override val previousButton: ImageButton
|
||||
get() = binding.previousButton
|
||||
|
||||
override val songTotalTime: TextView
|
||||
get() = binding.songTotalTime
|
||||
|
||||
override val songCurrentProgress: TextView
|
||||
get() = binding.songCurrentProgress
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentLockScreenPlaybackControlsBinding.bind(view)
|
||||
|
@ -166,18 +173,6 @@ class LockScreenControlsFragment :
|
|||
}
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.view.View
|
|||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
|
@ -46,7 +47,7 @@ class MaterialControlsFragment :
|
|||
private var _binding: FragmentMaterialPlaybackControlsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -61,6 +62,12 @@ class MaterialControlsFragment :
|
|||
override val previousButton: ImageButton
|
||||
get() = binding.previousButton
|
||||
|
||||
override val songTotalTime: TextView
|
||||
get() = binding.songTotalTime
|
||||
|
||||
override val songCurrentProgress: TextView
|
||||
get() = binding.songCurrentProgress
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentMaterialPlaybackControlsBinding.bind(view)
|
||||
|
@ -174,18 +181,6 @@ class MaterialControlsFragment :
|
|||
|
||||
public override fun hide() {}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
|
|
|
@ -14,13 +14,12 @@
|
|||
*/
|
||||
package code.name.monkey.retromusic.fragments.player.normal
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
|
@ -33,7 +32,6 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
|||
import code.name.monkey.retromusic.fragments.base.goToAlbum
|
||||
import code.name.monkey.retromusic.fragments.base.goToArtist
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
|
||||
|
@ -43,7 +41,7 @@ class PlayerPlaybackControlsFragment :
|
|||
private var _binding: FragmentPlayerPlaybackControlsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -58,6 +56,12 @@ class PlayerPlaybackControlsFragment :
|
|||
override val previousButton: ImageButton
|
||||
get() = binding.previousButton
|
||||
|
||||
override val songTotalTime: TextView
|
||||
get() = binding.songTotalTime
|
||||
|
||||
override val songCurrentProgress: TextView
|
||||
get() = binding.songCurrentProgress
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentPlayerPlaybackControlsBinding.bind(view)
|
||||
|
@ -183,18 +187,6 @@ class PlayerPlaybackControlsFragment :
|
|||
}
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.view.View
|
|||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
|
@ -45,7 +46,7 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment(R.layout.fragment_pe
|
|||
private var _binding: FragmentPeakControlPlayerBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -60,6 +61,12 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment(R.layout.fragment_pe
|
|||
override val previousButton: ImageButton
|
||||
get() = binding.previousButton
|
||||
|
||||
override val songTotalTime: TextView
|
||||
get() = binding.songTotalTime
|
||||
|
||||
override val songCurrentProgress: TextView
|
||||
get() = binding.songCurrentProgress
|
||||
|
||||
override fun onViewCreated(
|
||||
view: View,
|
||||
savedInstanceState: Bundle?
|
||||
|
@ -109,18 +116,6 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment(R.layout.fragment_pe
|
|||
}
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
private fun setUpPlayPauseFab() {
|
||||
TintHelper.setTintAuto(binding.playPauseButton, Color.WHITE, true)
|
||||
TintHelper.setTintAuto(binding.playPauseButton, Color.BLACK, false)
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.view.animation.DecelerateInterpolator
|
|||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
|
@ -48,7 +49,7 @@ class PlainPlaybackControlsFragment :
|
|||
private var _binding: FragmentPlainControlsFragmentBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override val seekBar: SeekBar
|
||||
override val progressSlider: SeekBar
|
||||
get() = binding.progressSlider
|
||||
|
||||
override val shuffleButton: ImageButton
|
||||
|
@ -63,6 +64,12 @@ class PlainPlaybackControlsFragment :
|
|||
override val previousButton: ImageButton
|
||||
get() = binding.previousButton
|
||||
|
||||
override val songTotalTime: TextView
|
||||
get() = binding.songTotalTime
|
||||
|
||||
override val songCurrentProgress: TextView
|
||||
get() = binding.songCurrentProgress
|
||||
|
||||
override fun onPlayStateChanged() {
|
||||
updatePlayPauseDrawableState()
|
||||
}
|
||||
|
@ -175,18 +182,6 @@ class PlainPlaybackControlsFragment :
|
|||
}
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
binding.progressSlider.max = total
|
||||
|
||||
val animator = ObjectAnimator.ofInt(binding.progressSlider, "progress", progress)
|
||||
animator.duration = SLIDER_ANIMATION_TIME
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.start()
|
||||
|
||||
binding.songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
binding.songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
|
|
|
@ -18,7 +18,6 @@ import android.os.Bundle
|
|||
import android.view.View
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.widget.ImageButton
|
||||
import android.widget.SeekBar
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue