Merge pull request #1695 from Bnyro/master

Queue fixes
This commit is contained in:
Bnyro 2022-10-29 18:18:44 +02:00 committed by GitHub
commit 02bdffeb3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 14 deletions

View File

@ -13,8 +13,8 @@ android {
applicationId 'com.github.libretube'
minSdk 21
targetSdk 33
versionCode 20
versionName '0.6.1'
versionCode 21
versionName '0.7.0'
multiDexEnabled true
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
resValue "string", "app_name", "LibreTube"

View File

@ -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,13 @@ class PlayingQueueAdapter : RecyclerView.Adapter<PlayingQueueViewHolder>() {
videoInfo.text = streamItem.uploaderName + "" +
DateUtils.formatElapsedTime(streamItem.duration ?: 0)
if (PlayingQueue.currentIndex() == position) {
root.setBackgroundColor(
root.setBackgroundColor(
if (currentIndex == position) {
ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight)
)
}
} else {
Color.TRANSPARENT
}
)
}
}
}

View File

@ -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,11 @@ 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)

View File

@ -3,7 +3,6 @@ package com.github.libretube.util
import android.os.Handler
import android.os.Looper
import android.os.SystemClock
import android.util.Log
import android.view.View
abstract class DoubleTapListener : View.OnClickListener {
@ -31,7 +30,6 @@ abstract class DoubleTapListener : View.OnClickListener {
private val runnable = Runnable {
if (isSecondClick()) return@Runnable
Log.e("single", "single")
onSingleClick()
}