Fixed Gradient Player queue sheet
This commit is contained in:
parent
64401ec012
commit
3f5d83b4d4
2 changed files with 31 additions and 7 deletions
|
@ -28,7 +28,9 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.view.*
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.core.view.updatePadding
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
@ -63,7 +65,8 @@ import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_player),
|
class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_player),
|
||||||
MusicProgressViewUpdateHelper.Callback, PopupMenu.OnMenuItemClickListener {
|
MusicProgressViewUpdateHelper.Callback,
|
||||||
|
View.OnLayoutChangeListener, PopupMenu.OnMenuItemClickListener {
|
||||||
private var lastColor: Int = 0
|
private var lastColor: Int = 0
|
||||||
private var lastPlaybackControlsColor: Int = 0
|
private var lastPlaybackControlsColor: Int = 0
|
||||||
private var lastDisabledPlaybackControlsColor: Int = 0
|
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||||
|
@ -126,9 +129,9 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupPanel() {
|
private fun setupPanel() {
|
||||||
binding.colorBackground.doOnLayout {
|
if (!ViewCompat.isLaidOut(binding.colorBackground) || binding.colorBackground.isLayoutRequested) {
|
||||||
val panel = getQueuePanel()
|
binding.colorBackground.addOnLayoutChangeListener(this)
|
||||||
panel.peekHeight = binding.container.height
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,7 +453,7 @@ 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)) {
|
||||||
binding.nextSong.text = "Last song"
|
binding.nextSong.text = context?.resources?.getString(R.string.last_song)
|
||||||
} else {
|
} else {
|
||||||
val title = MusicPlayerRemote.playingQueue[MusicPlayerRemote.position + 1].title
|
val title = MusicPlayerRemote.playingQueue[MusicPlayerRemote.position + 1].title
|
||||||
binding.nextSong.text = title
|
binding.nextSong.text = title
|
||||||
|
@ -458,6 +461,25 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onLayoutChange(
|
||||||
|
v: View?,
|
||||||
|
left: Int,
|
||||||
|
top: Int,
|
||||||
|
right: Int,
|
||||||
|
bottom: Int,
|
||||||
|
oldLeft: Int,
|
||||||
|
oldTop: Int,
|
||||||
|
oldRight: Int,
|
||||||
|
oldBottom: Int
|
||||||
|
) {
|
||||||
|
val panel = getQueuePanel()
|
||||||
|
if (panel.state == STATE_COLLAPSED) {
|
||||||
|
panel.peekHeight = binding.container.height
|
||||||
|
} else if (panel.state == STATE_EXPANDED) {
|
||||||
|
panel.peekHeight = binding.container.height + navBarHeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupRecyclerView() {
|
private fun setupRecyclerView() {
|
||||||
playingQueueAdapter = PlayingQueueAdapter(
|
playingQueueAdapter = PlayingQueueAdapter(
|
||||||
requireActivity() as AppCompatActivity,
|
requireActivity() as AppCompatActivity,
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/colorSurface">
|
android:background="?attr/colorSurface"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/colorBackground"
|
android:id="@+id/colorBackground"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue