mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
Simplify watch progress length extension
This commit is contained in:
parent
25c0d3c0c8
commit
c634cd9c9c
@ -12,15 +12,11 @@ import com.github.libretube.extensions.awaitQuery
|
||||
* @param duration The duration of the video in seconds
|
||||
* @return Whether the video is already watched more than 90%
|
||||
*/
|
||||
fun View?.setWatchProgressLength(videoId: String, duration: Long): Boolean {
|
||||
val view = this!!
|
||||
|
||||
view.apply {
|
||||
fun View.setWatchProgressLength(videoId: String, duration: Long): Boolean {
|
||||
updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
matchConstraintPercentWidth = 0f
|
||||
}
|
||||
visibility = View.GONE
|
||||
}
|
||||
|
||||
val progress = try {
|
||||
awaitQuery {
|
||||
@ -35,12 +31,10 @@ fun View?.setWatchProgressLength(videoId: String, duration: Long): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
view.apply {
|
||||
updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
matchConstraintPercentWidth = (progress / duration.toFloat())
|
||||
matchConstraintPercentWidth = progress / duration.toFloat()
|
||||
}
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
return progress / duration.toFloat() > 0.9
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user