mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
fix the queue
This commit is contained in:
parent
6116a9decc
commit
77ff1e8f20
@ -1,6 +1,7 @@
|
||||
package com.github.libretube.ui.adapters
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Color
|
||||
import android.text.format.DateUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
@ -12,6 +13,8 @@ import com.github.libretube.util.PlayingQueue
|
||||
import com.github.libretube.util.ThemeHelper
|
||||
|
||||
class PlayingQueueAdapter : RecyclerView.Adapter<PlayingQueueViewHolder>() {
|
||||
private val currentIndex = PlayingQueue.currentIndex()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlayingQueueViewHolder {
|
||||
val binding = QueueRowBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
@ -34,11 +37,10 @@ class PlayingQueueAdapter : RecyclerView.Adapter<PlayingQueueViewHolder>() {
|
||||
videoInfo.text = streamItem.uploaderName + " • " +
|
||||
DateUtils.formatElapsedTime(streamItem.duration ?: 0)
|
||||
|
||||
if (PlayingQueue.currentIndex() == position) {
|
||||
root.setBackgroundColor(
|
||||
ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight)
|
||||
)
|
||||
}
|
||||
root.setBackgroundColor(
|
||||
if (currentIndex == position) ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight)
|
||||
else Color.TRANSPARENT
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,11 +34,11 @@ class PlayingQueueSheet : BottomSheetDialogFragment() {
|
||||
binding.optionsRecycler.adapter = adapter
|
||||
|
||||
binding.shuffle.setOnClickListener {
|
||||
val streams = PlayingQueue.getStreams()
|
||||
var streams = PlayingQueue.getStreams()
|
||||
val currentIndex = PlayingQueue.currentIndex()
|
||||
val current = streams[currentIndex]
|
||||
|
||||
streams.shuffle()
|
||||
streams = streams.shuffled().toMutableList()
|
||||
streams.remove(current)
|
||||
streams.add(currentIndex, current)
|
||||
PlayingQueue.setStreams(streams)
|
||||
@ -47,11 +47,10 @@ class PlayingQueueSheet : BottomSheetDialogFragment() {
|
||||
}
|
||||
|
||||
binding.clear.setOnClickListener {
|
||||
val streams = PlayingQueue.getStreams()
|
||||
val index = PlayingQueue.currentIndex()
|
||||
val currentIndex = PlayingQueue.currentIndex()
|
||||
|
||||
while (index >= PlayingQueue.size()) {
|
||||
streams.removeAt(index)
|
||||
val streams = PlayingQueue.getStreams().filterIndexed {
|
||||
position, _ -> position <= currentIndex
|
||||
}
|
||||
|
||||
PlayingQueue.setStreams(streams)
|
||||
|
@ -31,7 +31,6 @@ abstract class DoubleTapListener : View.OnClickListener {
|
||||
|
||||
private val runnable = Runnable {
|
||||
if (isSecondClick()) return@Runnable
|
||||
Log.e("single", "single")
|
||||
onSingleClick()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user