queue: re-add adaptive divider visibility
Re-add the adaptive divider functionality that was accidentally removed prior.
This commit is contained in:
parent
bda42c9762
commit
d16fc2e446
2 changed files with 21 additions and 1 deletions
2
.github/ISSUE_TEMPLATE/bug-crash-report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug-crash-report.yml
vendored
|
@ -1,5 +1,5 @@
|
|||
name: Bug/Crash Report
|
||||
description: File a bug report
|
||||
description: Report a problem
|
||||
labels: ["bug"]
|
||||
assignees:
|
||||
- OxygenCobalt
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.oxycblt.auxio.playback.queue
|
|||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@ -54,6 +55,18 @@ class QueueFragment : ViewBindingFragment<FragmentQueueBinding>(), QueueAdapter.
|
|||
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 ----
|
||||
collectImmediately(
|
||||
queueModel.queue, queueModel.index, playbackModel.isPlaying, ::updateQueue)
|
||||
|
@ -73,6 +86,13 @@ class QueueFragment : ViewBindingFragment<FragmentQueueBinding>(), QueueAdapter.
|
|||
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) {
|
||||
val binding = requireBinding()
|
||||
|
||||
|
|
Loading…
Reference in a new issue