mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-06 01:20:29 +05:30
some bug fixes
This commit is contained in:
parent
7d993fcd5c
commit
587a3ba9ac
@ -14,7 +14,7 @@ import com.github.libretube.obj.WatchPosition
|
|||||||
SearchHistoryItem::class,
|
SearchHistoryItem::class,
|
||||||
CustomInstance::class
|
CustomInstance::class
|
||||||
],
|
],
|
||||||
version = 5
|
version = 6
|
||||||
)
|
)
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
/**
|
/**
|
||||||
|
@ -26,10 +26,11 @@ class CustomInstanceDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.addInstance.setOnClickListener {
|
binding.addInstance.setOnClickListener {
|
||||||
val customInstance = CustomInstance()
|
val customInstance = CustomInstance(
|
||||||
customInstance.name = binding.instanceName.text.toString()
|
name = binding.instanceName.text.toString(),
|
||||||
customInstance.apiUrl = binding.instanceApiUrl.text.toString()
|
apiUrl = binding.instanceApiUrl.text.toString(),
|
||||||
customInstance.frontendUrl = binding.instanceFrontendUrl.text.toString()
|
frontendUrl = binding.instanceFrontendUrl.text.toString()
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
customInstance.name != "" &&
|
customInstance.name != "" &&
|
||||||
|
@ -5,42 +5,36 @@ import android.view.ViewTreeObserver
|
|||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.github.libretube.database.DatabaseHolder
|
import com.github.libretube.database.DatabaseHolder
|
||||||
import com.github.libretube.extensions.await
|
import com.github.libretube.extensions.await
|
||||||
import com.github.libretube.obj.WatchPosition
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* shows the already watched time under the video
|
* shows the already watched time under the video
|
||||||
*/
|
*/
|
||||||
fun View?.setWatchProgressLength(videoId: String, duration: Long) {
|
fun View?.setWatchProgressLength(videoId: String, duration: Long) {
|
||||||
val view = this!!
|
val view = this!!
|
||||||
var positions = listOf<WatchPosition>()
|
var progress: Long? = null
|
||||||
var newWidth: Long? = null
|
|
||||||
|
|
||||||
Thread {
|
Thread {
|
||||||
positions = DatabaseHolder.database.watchPositionDao().getAll()
|
try {
|
||||||
|
progress = DatabaseHolder.database.watchPositionDao().findById(videoId).position
|
||||||
|
} catch (e: Exception) {
|
||||||
|
progress = null
|
||||||
|
}
|
||||||
}.await()
|
}.await()
|
||||||
|
|
||||||
view.getViewTreeObserver()
|
view.getViewTreeObserver()
|
||||||
.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
override fun onGlobalLayout() {
|
override fun onGlobalLayout() {
|
||||||
this@setWatchProgressLength.getViewTreeObserver().removeOnGlobalLayoutListener(this)
|
this@setWatchProgressLength.getViewTreeObserver().removeOnGlobalLayoutListener(this)
|
||||||
positions.forEach {
|
if (progress == null) {
|
||||||
if (it.videoId == videoId) {
|
|
||||||
val fullWidth = (parent as LinearLayout).width
|
|
||||||
if (duration != 0L) newWidth =
|
|
||||||
(fullWidth * (it.position / (duration))) / 1000
|
|
||||||
return@forEach
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (newWidth != null) {
|
|
||||||
val lp = view.layoutParams
|
|
||||||
lp.apply {
|
|
||||||
width = newWidth!!.toInt()
|
|
||||||
}
|
|
||||||
view.layoutParams = lp
|
|
||||||
view.visibility = View.VISIBLE
|
|
||||||
} else {
|
|
||||||
view.visibility = View.GONE
|
view.visibility = View.GONE
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
val fullWidth = (parent as LinearLayout).width
|
||||||
|
val newWidth = (fullWidth * (progress!! / (duration))) / 1000
|
||||||
|
val lp = view.layoutParams
|
||||||
|
lp.width = newWidth.toInt()
|
||||||
|
view.layoutParams = lp
|
||||||
|
view.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,6 @@ import com.github.libretube.obj.ChapterSegment
|
|||||||
import com.github.libretube.obj.Segment
|
import com.github.libretube.obj.Segment
|
||||||
import com.github.libretube.obj.Segments
|
import com.github.libretube.obj.Segments
|
||||||
import com.github.libretube.obj.Streams
|
import com.github.libretube.obj.Streams
|
||||||
import com.github.libretube.obj.WatchPosition
|
|
||||||
import com.github.libretube.preferences.PreferenceHelper
|
import com.github.libretube.preferences.PreferenceHelper
|
||||||
import com.github.libretube.preferences.PreferenceKeys
|
import com.github.libretube.preferences.PreferenceKeys
|
||||||
import com.github.libretube.services.BackgroundMode
|
import com.github.libretube.services.BackgroundMode
|
||||||
@ -936,17 +935,14 @@ class PlayerFragment : BaseFragment() {
|
|||||||
|
|
||||||
private fun seekToWatchPosition() {
|
private fun seekToWatchPosition() {
|
||||||
// seek to saved watch position if available
|
// seek to saved watch position if available
|
||||||
var watchPositions = listOf<WatchPosition>()
|
|
||||||
Thread {
|
|
||||||
watchPositions = DatabaseHolder.database.watchPositionDao().getAll()
|
|
||||||
}.await()
|
|
||||||
var position: Long? = null
|
var position: Long? = null
|
||||||
watchPositions.forEach {
|
Thread {
|
||||||
if (it.videoId == videoId &&
|
try {
|
||||||
// don't seek to the position if it's the end, autoplay would skip it immediately
|
position = DatabaseHolder.database.watchPositionDao().findById(videoId!!).position
|
||||||
streams.duration!! - it.position / 1000 > 2
|
} catch (e: Exception) {
|
||||||
) position = it.position
|
position = null
|
||||||
}
|
}
|
||||||
|
}.await()
|
||||||
// support for time stamped links
|
// support for time stamped links
|
||||||
val timeStamp: Long? = arguments?.getLong("timeStamp")
|
val timeStamp: Long? = arguments?.getLong("timeStamp")
|
||||||
if (timeStamp != null && timeStamp != 0L) {
|
if (timeStamp != null && timeStamp != 0L) {
|
||||||
|
@ -6,8 +6,7 @@ import androidx.room.PrimaryKey
|
|||||||
|
|
||||||
@Entity(tableName = "customInstance")
|
@Entity(tableName = "customInstance")
|
||||||
class CustomInstance(
|
class CustomInstance(
|
||||||
@PrimaryKey(autoGenerate = true) var id: Int = 0,
|
@PrimaryKey var name: String = "",
|
||||||
@ColumnInfo var name: String = "",
|
|
||||||
@ColumnInfo var apiUrl: String = "",
|
@ColumnInfo var apiUrl: String = "",
|
||||||
@ColumnInfo var frontendUrl: String = ""
|
@ColumnInfo var frontendUrl: String = ""
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.github.libretube.preferences
|
package com.github.libretube.preferences
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
Loading…
Reference in New Issue
Block a user