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