From 3cf1c1c9cb1b11049a3e04c84458877bf15c3ad5 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 28 Jul 2022 14:55:05 +0200 Subject: [PATCH] watch progress for playlists --- .../libretube/adapters/PlaylistAdapter.kt | 6 ++- app/src/main/res/layout/playlist_row.xml | 48 ++++++++++++------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt index e28b6267c..97c9a77a1 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt @@ -16,6 +16,7 @@ import com.github.libretube.preferences.PreferenceHelper import com.github.libretube.util.ConnectionHelper import com.github.libretube.util.NavigationHelper import com.github.libretube.util.RetrofitInstance +import com.github.libretube.util.setWatchProgressLength import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -51,13 +52,13 @@ class PlaylistAdapter( holder.binding.apply { playlistTitle.text = streamItem.title playlistDescription.text = streamItem.uploaderName - playlistDuration.text = DateUtils.formatElapsedTime(streamItem.duration!!) + thumbnailDuration.text = DateUtils.formatElapsedTime(streamItem.duration!!) ConnectionHelper.loadImage(streamItem.thumbnail, playlistThumbnail) root.setOnClickListener { NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId) } + val videoId = streamItem.url!!.replace("/watch?v=", "") root.setOnLongClickListener { - val videoId = streamItem.url!!.replace("/watch?v=", "") VideoOptionsDialog(videoId, root.context) .show(childFragmentManager, "VideoOptionsDialog") true @@ -70,6 +71,7 @@ class PlaylistAdapter( removeFromPlaylist(token, position) } } + watchProgress.setWatchProgressLength(videoId, streamItem.duration!!) } } diff --git a/app/src/main/res/layout/playlist_row.xml b/app/src/main/res/layout/playlist_row.xml index cca5c2238..37b4ad34b 100644 --- a/app/src/main/res/layout/playlist_row.xml +++ b/app/src/main/res/layout/playlist_row.xml @@ -36,27 +36,43 @@ android:layout_height="match_parent" tools:srcCompat="@tools:sample/backgrounds/scenic" /> - + android:layout_gravity="bottom" + android:orientation="vertical"> - + android:layout_gravity="end" + android:layout_marginEnd="5dp" + android:layout_marginBottom="5dp" + app:cardBackgroundColor="@color/duration_background_color" + app:cardCornerRadius="8dp" + app:cardElevation="0dp"> + + + + + + + + -