Update GradientPlayerFragment.kt
This commit is contained in:
parent
67b59f7c00
commit
3fd8481522
1 changed files with 12 additions and 13 deletions
|
@ -36,7 +36,7 @@ import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior.*
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator
|
import com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
|
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager
|
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager
|
||||||
|
@ -61,7 +61,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
private var playingQueueAdapter: PlayingQueueAdapter? = null
|
private var playingQueueAdapter: PlayingQueueAdapter? = null
|
||||||
private lateinit var linearLayoutManager: LinearLayoutManager
|
private lateinit var linearLayoutManager: LinearLayoutManager
|
||||||
|
|
||||||
private val bottomSheetCallbackList = object : BottomSheetBehavior.BottomSheetCallback() {
|
private val bottomSheetCallbackList = object : BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||||
mainActivity.getBottomSheetBehavior().setAllowDragging(false)
|
mainActivity.getBottomSheetBehavior().setAllowDragging(false)
|
||||||
playerQueueSheet.setPadding(
|
playerQueueSheet.setPadding(
|
||||||
|
@ -74,11 +74,11 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
|
|
||||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||||
when (newState) {
|
when (newState) {
|
||||||
BottomSheetBehavior.STATE_EXPANDED,
|
STATE_EXPANDED,
|
||||||
BottomSheetBehavior.STATE_DRAGGING -> {
|
STATE_DRAGGING -> {
|
||||||
mainActivity.getBottomSheetBehavior().setAllowDragging(false)
|
mainActivity.getBottomSheetBehavior().setAllowDragging(false)
|
||||||
}
|
}
|
||||||
BottomSheetBehavior.STATE_COLLAPSED -> {
|
STATE_COLLAPSED -> {
|
||||||
resetToCurrentPosition()
|
resetToCurrentPosition()
|
||||||
mainActivity.getBottomSheetBehavior().setAllowDragging(true)
|
mainActivity.getBottomSheetBehavior().setAllowDragging(true)
|
||||||
}
|
}
|
||||||
|
@ -167,9 +167,9 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
|
|
||||||
override fun onBackPressed(): Boolean {
|
override fun onBackPressed(): Boolean {
|
||||||
var wasExpanded = false
|
var wasExpanded = false
|
||||||
if (getQueuePanel().state == BottomSheetBehavior.STATE_EXPANDED) {
|
if (getQueuePanel().state == STATE_EXPANDED) {
|
||||||
wasExpanded = getQueuePanel().state == BottomSheetBehavior.STATE_EXPANDED
|
wasExpanded = getQueuePanel().state == STATE_EXPANDED
|
||||||
getQueuePanel().state = BottomSheetBehavior.STATE_COLLAPSED
|
getQueuePanel().state = STATE_COLLAPSED
|
||||||
return wasExpanded
|
return wasExpanded
|
||||||
}
|
}
|
||||||
return wasExpanded
|
return wasExpanded
|
||||||
|
@ -359,13 +359,10 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
private fun updateLabel() {
|
private fun updateLabel() {
|
||||||
(MusicPlayerRemote.playingQueue.size - 1).apply {
|
(MusicPlayerRemote.playingQueue.size - 1).apply {
|
||||||
if (this == (MusicPlayerRemote.position)) {
|
if (this == (MusicPlayerRemote.position)) {
|
||||||
nextSong.hide()
|
nextSong.text = "Last song"
|
||||||
} else {
|
} else {
|
||||||
val title = MusicPlayerRemote.playingQueue[MusicPlayerRemote.position + 1].title
|
val title = MusicPlayerRemote.playingQueue[MusicPlayerRemote.position + 1].title
|
||||||
nextSong.apply {
|
nextSong.text = title
|
||||||
text = title
|
|
||||||
show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,4 +466,6 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||||
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue