watch progress for playlists

This commit is contained in:
Bnyro 2022-07-28 14:55:05 +02:00
parent 0fc0f78de5
commit 3cf1c1c9cb
2 changed files with 36 additions and 18 deletions

View File

@ -16,6 +16,7 @@ import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.ConnectionHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.RetrofitInstance
import com.github.libretube.util.setWatchProgressLength
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -51,13 +52,13 @@ class PlaylistAdapter(
holder.binding.apply { holder.binding.apply {
playlistTitle.text = streamItem.title playlistTitle.text = streamItem.title
playlistDescription.text = streamItem.uploaderName playlistDescription.text = streamItem.uploaderName
playlistDuration.text = DateUtils.formatElapsedTime(streamItem.duration!!) thumbnailDuration.text = DateUtils.formatElapsedTime(streamItem.duration!!)
ConnectionHelper.loadImage(streamItem.thumbnail, playlistThumbnail) ConnectionHelper.loadImage(streamItem.thumbnail, playlistThumbnail)
root.setOnClickListener { root.setOnClickListener {
NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId) NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId)
} }
val videoId = streamItem.url!!.replace("/watch?v=", "")
root.setOnLongClickListener { root.setOnLongClickListener {
val videoId = streamItem.url!!.replace("/watch?v=", "")
VideoOptionsDialog(videoId, root.context) VideoOptionsDialog(videoId, root.context)
.show(childFragmentManager, "VideoOptionsDialog") .show(childFragmentManager, "VideoOptionsDialog")
true true
@ -70,6 +71,7 @@ class PlaylistAdapter(
removeFromPlaylist(token, position) removeFromPlaylist(token, position)
} }
} }
watchProgress.setWatchProgressLength(videoId, streamItem.duration!!)
} }
} }

View File

@ -36,27 +36,43 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:srcCompat="@tools:sample/backgrounds/scenic" /> tools:srcCompat="@tools:sample/backgrounds/scenic" />
<androidx.cardview.widget.CardView <LinearLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_gravity="bottom"
android:layout_margin="5dp" android:orientation="vertical">
app:cardBackgroundColor="@color/duration_background_color"
app:cardCornerRadius="8dp"
app:cardElevation="0dp">
<TextView <androidx.cardview.widget.CardView
android:id="@+id/playlist_duration"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="6dp" android:layout_gravity="end"
android:paddingTop="2dp" android:layout_marginEnd="5dp"
android:paddingEnd="6dp" android:layout_marginBottom="5dp"
android:paddingBottom="2dp" app:cardBackgroundColor="@color/duration_background_color"
android:textColor="@color/duration_text_color" app:cardCornerRadius="8dp"
tools:text="05:36" /> app:cardElevation="0dp">
<TextView
android:id="@+id/thumbnail_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="6dp"
android:paddingVertical="2dp"
android:textColor="@color/duration_text_color"
android:textSize="11sp"
tools:text="05:36" />
</androidx.cardview.widget.CardView>
<View
android:id="@+id/watch_progress"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_gravity="bottom"
android:background="@android:color/holo_red_dark" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<TextView <TextView