queue: re-add adaptive divider visibility
Re-add the adaptive divider functionality that was accidentally removed prior.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
name: Bug/Crash Report
|
name: Bug/Crash Report
|
||||||
description: File a bug report
|
description: Report a problem
|
||||||
labels: ["bug"]
|
labels: ["bug"]
|
||||||
assignees:
|
assignees:
|
||||||
- OxygenCobalt
|
- OxygenCobalt
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.oxycblt.auxio.playback.queue
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import androidx.core.view.isInvisible
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
@@ -54,6 +55,18 @@ class QueueFragment : ViewBindingFragment<FragmentQueueBinding>(), QueueAdapter.
|
|||||||
touchHelper.attachToRecyclerView(this)
|
touchHelper.attachToRecyclerView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sometimes the scroll can change without the listener being updated, so we also
|
||||||
|
// check for relayout events.
|
||||||
|
binding.queueRecycler.apply {
|
||||||
|
addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> updateDivider() }
|
||||||
|
addOnScrollListener(
|
||||||
|
object : RecyclerView.OnScrollListener() {
|
||||||
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
|
updateDivider()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// --- VIEWMODEL SETUP ----
|
// --- VIEWMODEL SETUP ----
|
||||||
collectImmediately(
|
collectImmediately(
|
||||||
queueModel.queue, queueModel.index, playbackModel.isPlaying, ::updateQueue)
|
queueModel.queue, queueModel.index, playbackModel.isPlaying, ::updateQueue)
|
||||||
@@ -73,6 +86,13 @@ class QueueFragment : ViewBindingFragment<FragmentQueueBinding>(), QueueAdapter.
|
|||||||
touchHelper.startDrag(viewHolder)
|
touchHelper.startDrag(viewHolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateDivider() {
|
||||||
|
val binding = requireBinding()
|
||||||
|
binding.queueDivider.isInvisible =
|
||||||
|
(binding.queueRecycler.layoutManager as LinearLayoutManager)
|
||||||
|
.findFirstCompletelyVisibleItemPosition() < 1
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateQueue(queue: List<Song>, index: Int, isPlaying: Boolean) {
|
private fun updateQueue(queue: List<Song>, index: Int, isPlaying: Boolean) {
|
||||||
val binding = requireBinding()
|
val binding = requireBinding()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user