mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
fix the watch progress
This commit is contained in:
parent
485cc19023
commit
7844cc7792
@ -56,9 +56,9 @@ object DatabaseHelper {
|
|||||||
|
|
||||||
fun removeWatchPosition(videoId: String) {
|
fun removeWatchPosition(videoId: String) {
|
||||||
Thread {
|
Thread {
|
||||||
Database.watchPositionDao().delete(
|
Database.watchPositionDao().findById(videoId)?.let {
|
||||||
Database.watchPositionDao().findById(videoId)
|
Database.watchPositionDao().delete(it)
|
||||||
)
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ fun View?.setWatchProgressLength(videoId: String, duration: Long) {
|
|||||||
|
|
||||||
Thread {
|
Thread {
|
||||||
try {
|
try {
|
||||||
progress = Database.watchPositionDao().findById(videoId).position
|
progress = Database.watchPositionDao().findById(videoId)?.position
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
progress = null
|
progress = null
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package com.github.libretube.util
|
package com.github.libretube.util
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.github.libretube.extensions.TAG
|
|
||||||
|
|
||||||
object PlayingQueue {
|
object PlayingQueue {
|
||||||
private val queue = mutableListOf<String>()
|
private val queue = mutableListOf<String>()
|
||||||
private var currentVideoId: String? = null
|
private var currentVideoId: String? = null
|
||||||
@ -12,20 +9,23 @@ object PlayingQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun add(videoId: String) {
|
fun add(videoId: String) {
|
||||||
|
if (currentVideoId == videoId) return
|
||||||
|
if (queue.contains(videoId)) queue.remove(videoId)
|
||||||
queue.add(videoId)
|
queue.add(videoId)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun playNext(nextVideoId: String) {
|
fun playNext(videoId: String) {
|
||||||
|
if (currentVideoId == videoId) return
|
||||||
|
if (queue.contains(videoId)) queue.remove(videoId)
|
||||||
queue.add(
|
queue.add(
|
||||||
queue.indexOf(currentVideoId),
|
queue.indexOf(currentVideoId) + 1,
|
||||||
nextVideoId
|
videoId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getNext(): String? {
|
fun getNext(): String? {
|
||||||
val currentIndex = queue.indexOf(currentVideoId)
|
val currentIndex = queue.indexOf(currentVideoId)
|
||||||
Log.e(TAG(), queue.toString())
|
return if (currentIndex >= queue.size) {
|
||||||
return if (currentIndex > queue.size) {
|
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
queue[currentIndex + 1]
|
queue[currentIndex + 1]
|
||||||
@ -40,7 +40,7 @@ object PlayingQueue {
|
|||||||
|
|
||||||
fun hasPrev(): Boolean {
|
fun hasPrev(): Boolean {
|
||||||
val currentIndex = queue.indexOf(currentVideoId)
|
val currentIndex = queue.indexOf(currentVideoId)
|
||||||
return currentIndex >= 1
|
return queue.size > currentIndex + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
fun contains(videoId: String): Boolean {
|
fun contains(videoId: String): Boolean {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user