mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 14:50:30 +05:30
Fixes #2815
This commit is contained in:
parent
f9e96e9b27
commit
bd556baa76
@ -84,9 +84,7 @@ class PlaylistAdapter(
|
|||||||
|
|
||||||
if (!streamItem.uploaderUrl.isNullOrBlank()) {
|
if (!streamItem.uploaderUrl.isNullOrBlank()) {
|
||||||
channelContainer.setOnClickListener {
|
channelContainer.setOnClickListener {
|
||||||
streamItem.uploaderUrl?.toID()?.let {
|
NavigationHelper.navigateChannel(root.context, streamItem.uploaderUrl.toID())
|
||||||
NavigationHelper.navigateChannel(root.context, it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +94,7 @@ class PlaylistAdapter(
|
|||||||
removeFromPlaylist(root.context, position)
|
removeFromPlaylist(root.context, position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
watchProgress.setWatchProgressLength(videoId, streamItem.duration!!)
|
watchProgress.setWatchProgressLength(videoId, streamItem.duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package com.github.libretube.ui.extensions
|
package com.github.libretube.ui.extensions
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewTreeObserver
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import android.widget.LinearLayout
|
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import com.github.libretube.db.DatabaseHolder.Companion.Database
|
import com.github.libretube.db.DatabaseHolder.Companion.Database
|
||||||
import com.github.libretube.extensions.awaitQuery
|
import com.github.libretube.extensions.awaitQuery
|
||||||
@ -16,6 +15,13 @@ import com.github.libretube.extensions.awaitQuery
|
|||||||
fun View?.setWatchProgressLength(videoId: String, duration: Long): Boolean {
|
fun View?.setWatchProgressLength(videoId: String, duration: Long): Boolean {
|
||||||
val view = this!!
|
val view = this!!
|
||||||
|
|
||||||
|
view.apply {
|
||||||
|
updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||||
|
matchConstraintPercentWidth = 0f
|
||||||
|
}
|
||||||
|
visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
val progress = try {
|
val progress = try {
|
||||||
awaitQuery {
|
awaitQuery {
|
||||||
Database.watchPositionDao().findById(videoId)?.position
|
Database.watchPositionDao().findById(videoId)?.position
|
||||||
@ -26,22 +32,15 @@ fun View?.setWatchProgressLength(videoId: String, duration: Long): Boolean {
|
|||||||
?.toFloat()?.div(1000)
|
?.toFloat()?.div(1000)
|
||||||
|
|
||||||
if (progress == null || duration == 0L) {
|
if (progress == null || duration == 0L) {
|
||||||
view.visibility = View.GONE
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
view.viewTreeObserver
|
view.apply {
|
||||||
.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||||
override fun onGlobalLayout() {
|
matchConstraintPercentWidth = (progress / duration.toFloat())
|
||||||
this@setWatchProgressLength.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
|
||||||
val fullWidth = (parent as LinearLayout).width
|
|
||||||
val newWidth = fullWidth * (progress / duration.toFloat())
|
|
||||||
view.updateLayoutParams {
|
|
||||||
width = newWidth.toInt()
|
|
||||||
}
|
}
|
||||||
view.visibility = View.VISIBLE
|
visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
return progress / duration.toFloat() > 0.9
|
return progress / duration.toFloat() > 0.9
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,16 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/thumbnail"
|
android:id="@+id/thumbnail"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -39,7 +38,9 @@
|
|||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
app:cardBackgroundColor="@color/duration_background_color"
|
app:cardBackgroundColor="@color/duration_background_color"
|
||||||
app:cardCornerRadius="8dp"
|
app:cardCornerRadius="8dp"
|
||||||
app:cardElevation="0dp">
|
app:cardElevation="0dp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/watch_progress"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/thumbnail_duration"
|
android:id="@+id/thumbnail_duration"
|
||||||
@ -55,10 +56,11 @@
|
|||||||
<View
|
<View
|
||||||
android:id="@+id/watch_progress"
|
android:id="@+id/watch_progress"
|
||||||
style="@style/WatchProgress"
|
style="@style/WatchProgress"
|
||||||
android:layout_height="5dp" />
|
android:layout_height="5dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
</LinearLayout>
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,18 +25,16 @@
|
|||||||
app:layout_constraintVertical_bias="0.0"
|
app:layout_constraintVertical_bias="0.0"
|
||||||
app:strokeWidth="0dp">
|
app:strokeWidth="0dp">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/thumbnail"
|
android:id="@+id/thumbnail"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -45,7 +43,9 @@
|
|||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
app:cardBackgroundColor="@color/duration_background_color"
|
app:cardBackgroundColor="@color/duration_background_color"
|
||||||
app:cardCornerRadius="8dp"
|
app:cardCornerRadius="8dp"
|
||||||
app:cardElevation="0dp">
|
app:cardElevation="0dp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/watch_progress"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/thumbnail_duration"
|
android:id="@+id/thumbnail_duration"
|
||||||
@ -61,9 +61,10 @@
|
|||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/watch_progress"
|
android:id="@+id/watch_progress"
|
||||||
style="@style/WatchProgress" />
|
style="@style/WatchProgress"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
</LinearLayout>
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
@ -137,9 +137,8 @@
|
|||||||
|
|
||||||
<style name="WatchProgress">
|
<style name="WatchProgress">
|
||||||
|
|
||||||
<item name="android:layout_width">match_parent</item>
|
<item name="android:layout_width">0dp</item>
|
||||||
<item name="android:layout_height">4dp</item>
|
<item name="android:layout_height">4dp</item>
|
||||||
<item name="android:layout_gravity">bottom</item>
|
|
||||||
<item name="android:background">?attr/colorPrimaryDark</item>
|
<item name="android:background">?attr/colorPrimaryDark</item>
|
||||||
<item name="android:visibility">gone</item>
|
<item name="android:visibility">gone</item>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user