[Android] Add the progress and play state to the browser cards
Nicolas Pomepuy
git at videolan.org
Wed Mar 20 14:10:02 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Mar 20 09:05:21 2024 +0100| [21842eb7aca4ec75e00d5628f5113baa87794e06] | committer: Duncan McNamara
Add the progress and play state to the browser cards
Even if it's never displayed for now, we may want to
make it available in the future
> https://code.videolan.org/videolan/vlc-android/commit/21842eb7aca4ec75e00d5628f5113baa87794e06
---
.../vlc-android/res/layout/card_browser_item.xml | 42 ++++++++++++++++++++++
.../videolan/vlc/gui/browser/BaseBrowserAdapter.kt | 1 -
.../vlc/gui/browser/BrowserItemBindingContainer.kt | 7 ++--
3 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/application/vlc-android/res/layout/card_browser_item.xml b/application/vlc-android/res/layout/card_browser_item.xml
index eb9bf90bb5..b22a2ec000 100644
--- a/application/vlc-android/res/layout/card_browser_item.xml
+++ b/application/vlc-android/res/layout/card_browser_item.xml
@@ -54,6 +54,18 @@
name="checkEnabled"
type="boolean" />
+ <variable
+ name="played"
+ type="boolean" />
+
+ <variable
+ name="max"
+ type="int" />
+
+ <variable
+ name="progress"
+ type="int" />
+
<variable
name="favorite"
type="boolean" />
@@ -128,6 +140,19 @@
app:layout_constraintTop_toTopOf="parent"
app:media="@{item}" />
+ <ImageView
+ android:id="@+id/ml_item_seen"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/rounded_corners_black_bottom_right"
+ android:padding="3dp"
+ android:visibility="@{played ? View.VISIBLE : View.GONE, default=gone}"
+ app:layout_constraintStart_toStartOf="@+id/item_icon"
+ app:layout_constraintTop_toTopOf="@+id/item_icon"
+ app:layout_goneMarginStart="4dp"
+ app:srcCompat="@drawable/ic_check"
+ tools:visibility="visible" />
+
<TextView
android:id="@+id/dvi_icon"
android:layout_width="0dp"
@@ -204,6 +229,23 @@
android:contentDescription="@string/more_actions"
app:srcCompat="@drawable/ic_more"
tools:visibility="visible" />
+
+ <ProgressBar
+ android:id="@+id/ml_item_progress"
+ style="@android:style/Widget.ProgressBar.Horizontal"
+ android:layout_width="0dp"
+ android:layout_height="3dp"
+ android:indeterminate="false"
+ android:max="@{max}"
+ android:maxHeight="2dip"
+ android:minHeight="2dip"
+ android:progress="@{progress}"
+ android:progressDrawable="?attr/gridview_progressbar"
+ android:secondaryProgress="0"
+ android:visibility="@{progress == 0 || played ? View.GONE : View.VISIBLE}"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/item_icon" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</layout>
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt
index dddb403cb2..97c1d1edde 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt
@@ -148,7 +148,6 @@ open class BaseBrowserAdapter(val browserContainer: BrowserContainer<MediaLibrar
val max = (media.length / 1000).toInt()
val progress = (media.displayTime / 1000).toInt()
(holder as MediaViewHolder).bindingContainer.setProgress(holder.bindingContainer.container.context, progress, max)
- holder.bindingContainer.setItem(media)
if (media.type != MediaWrapper.TYPE_AUDIO) holder.bindingContainer.setIsPlayed(holder.bindingContainer.container.context, media.playCount > 0)
} else if (payloads[0] is CharSequence) {
(holder as MediaViewHolder).bindingContainer.text.visibility = View.VISIBLE
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserItemBindingContainer.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserItemBindingContainer.kt
index d2ebd30390..8aa5ee050b 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserItemBindingContainer.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserItemBindingContainer.kt
@@ -112,7 +112,7 @@ class BrowserItemBindingContainer(val binding: ViewDataBinding) {
fun setIsPlayed(context: Context, played:Boolean) {
if (!Settings.getInstance(context).getBoolean(PLAYBACK_HISTORY, true)) return
when (binding) {
- is CardBrowserItemBinding -> {}
+ is CardBrowserItemBinding -> binding.played = played
is BrowserItemBinding -> binding.played = played
else -> throw IllegalStateException("Binding should be either a CardBrowserItemBinding or BrowserItemBinding")
}
@@ -120,7 +120,10 @@ class BrowserItemBindingContainer(val binding: ViewDataBinding) {
fun setProgress(context: Context, progress: Int, max: Int) {
if (!Settings.getInstance(context).getBoolean(PLAYBACK_HISTORY, true)) return
when (binding) {
- is CardBrowserItemBinding -> {}
+ is CardBrowserItemBinding -> {
+ binding.progress = progress
+ binding.max = max
+ }
is BrowserItemBinding -> {
binding.progress = progress
binding.max = max
More information about the Android
mailing list