diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt index f95fb73cf..769647cf6 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt @@ -40,7 +40,7 @@ import kotlinx.coroutines.withContext * playlists */ class PlaylistAdapter( - private val originalFeed: MutableList, + val originalFeed: MutableList, private val sortedFeed: MutableList, private val playlistId: String, private val playlistType: PlaylistType diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt index e44568b0e..6b1382b8f 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt @@ -4,6 +4,7 @@ import android.annotation.SuppressLint import android.content.res.Configuration import android.os.Bundle import android.os.Parcelable +import android.text.format.DateUtils import android.util.Log import android.view.LayoutInflater import android.view.View @@ -385,6 +386,8 @@ class PlaylistFragment : DynamicLayoutManagerFragment() { val itemTouchHelper = ItemTouchHelper(itemTouchCallback) itemTouchHelper.attachToRecyclerView(binding.playlistRecView) } + + updatePlaylistDuration() } @SuppressLint("StringFormatInvalid", "StringFormatMatches") @@ -416,10 +419,18 @@ class PlaylistFragment : DynamicLayoutManagerFragment() { nextPage = response.nextpage playlistAdapter?.updateItems(response.relatedStreams) + updatePlaylistDuration() isLoading = false } } + @SuppressLint("SetTextI18n") + private fun updatePlaylistDuration() { + val totalDuration = playlistAdapter?.originalFeed?.sumOf { it.duration ?: 0 } ?: return + binding.playlistDuration.text = DateUtils.formatElapsedTime(totalDuration) + + if (nextPage != null) "+" else "" + } + override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) // manually restore the recyclerview state due to https://github.com/material-components/material-components-android/issues/3473 diff --git a/app/src/main/res/layout/fragment_playlist.xml b/app/src/main/res/layout/fragment_playlist.xml index 97d3596dd..0cc587c31 100644 --- a/app/src/main/res/layout/fragment_playlist.xml +++ b/app/src/main/res/layout/fragment_playlist.xml @@ -10,8 +10,8 @@ android:id="@+id/playlist_progress" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:visibility="gone" - android:layout_gravity="center" /> + android:layout_gravity="center" + android:visibility="gone" /> + android:visibility="gone" + tools:visibility="visible"> - + android:layout_marginHorizontal="14dp" + android:layout_marginVertical="10dp"> + + + + + + + + + +