[Android] Add a progressbar to the video thumbnail while they are generated

Nicolas Pomepuy git at videolan.org
Wed Jul 12 13:26:53 UTC 2023


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Jul 12 15:13:43 2023 +0200| [a0c92909174b08e66221b9b498eec8c99580faa7] | committer: Nicolas Pomepuy

Add a progressbar to the video thumbnail while they are generated

Fixes #844

> https://code.videolan.org/videolan/vlc-android/commit/a0c92909174b08e66221b9b498eec8c99580faa7
---

 application/vlc-android/res/layout/video_grid_card.xml    | 15 +++++++++++++++
 application/vlc-android/res/layout/video_list_card.xml    | 15 +++++++++++++++
 .../src/org/videolan/vlc/gui/helpers/ImageLoader.kt       |  1 +
 .../src/org/videolan/vlc/gui/video/VideoListAdapter.kt    |  5 ++++-
 4 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/res/layout/video_grid_card.xml b/application/vlc-android/res/layout/video_grid_card.xml
index 950b15ca35..3804c77e40 100644
--- a/application/vlc-android/res/layout/video_grid_card.xml
+++ b/application/vlc-android/res/layout/video_grid_card.xml
@@ -33,6 +33,10 @@
             name="isFavorite"
             type="boolean" />
 
+        <variable
+            name="showProgress"
+            type="boolean" />
+
         <variable
                 name="inSelection"
                 type="boolean" />
@@ -303,6 +307,17 @@
                         vlc:layout_constraintEnd_toEndOf="parent"
                         vlc:layout_constraintStart_toStartOf="parent" />
 
+                <ProgressBar
+                        android:id="@+id/thumb_progress"
+                        style="?android:attr/progressBarStyle"
+                        android:layout_width="32dp"
+                        android:layout_height="32dp"
+                        android:visibility="@{showProgress ? View.VISIBLE : View.GONE}"
+                        vlc:layout_constraintBottom_toBottomOf="parent"
+                        vlc:layout_constraintStart_toStartOf="parent"
+                        vlc:layout_constraintTop_toTopOf="parent"
+                        vlc:layout_constraintEnd_toEndOf="parent" />
+
             </androidx.constraintlayout.widget.ConstraintLayout>
 
             <!-- Image loading is handled by org.videolan.vlc.gui.helpers.ImageLoader.loadImage() -->
diff --git a/application/vlc-android/res/layout/video_list_card.xml b/application/vlc-android/res/layout/video_list_card.xml
index 194098f098..586a43f9ec 100644
--- a/application/vlc-android/res/layout/video_list_card.xml
+++ b/application/vlc-android/res/layout/video_list_card.xml
@@ -33,6 +33,11 @@
             name="isFavorite"
             type="boolean" />
 
+
+        <variable
+                name="showProgress"
+                type="boolean" />
+
         <variable
                 name="inSelection"
                 type="boolean" />
@@ -222,6 +227,16 @@
                         vlc:layout_constraintBottom_toBottomOf="@+id/ml_item_thumbnail"
                         vlc:layout_constraintEnd_toEndOf="@+id/ml_item_thumbnail"
                         vlc:layout_constraintStart_toStartOf="@+id/ml_item_thumbnail" />
+                <ProgressBar
+                        android:id="@+id/thumb_progress"
+                        style="?android:attr/progressBarStyle"
+                        android:layout_width="24dp"
+                        android:layout_height="24dp"
+                        android:visibility="@{showProgress ? View.VISIBLE : View.GONE}"
+                        vlc:layout_constraintStart_toStartOf="parent"
+                        vlc:layout_constraintTop_toTopOf="parent"
+                        vlc:layout_constraintBottom_toBottomOf="parent"
+                        vlc:layout_constraintEnd_toEndOf="parent" />
             </androidx.constraintlayout.widget.ConstraintLayout>
         </com.google.android.material.card.MaterialCardView>
 
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
index 45ddb10c77..26ccd28b05 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
@@ -303,6 +303,7 @@ fun updateImageView(bitmap: Bitmap?, target: View, vdb: ViewDataBinding?, update
         vdb.setVariable(BR.scaleType, if (card) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER)
         vdb.setVariable(BR.cover, BitmapDrawable(target.resources, bitmap))
         vdb.setVariable(BR.protocol, null)
+        vdb.setVariable(BR.showProgress, false)
     } else when (target) {
         is ImageView -> {
             if (updateScaleType) target.scaleType = if (tv) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
index 6d3c6b6840..390361097d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
@@ -101,7 +101,10 @@ class VideoListAdapter(private var isSeenMediaMarkerVisible: Boolean
         fillView(holder, item)
         holder.binding.setVariable(BR.media, item)
         holder.selectView(multiSelectHelper.isSelected(position))
-        item.let { holder.binding.setVariable(BR.isFavorite, it.isFavorite) }
+        item.let {
+            holder.binding.setVariable(BR.isFavorite, it.isFavorite)
+            holder.binding.setVariable(BR.showProgress, item.artworkMrl.isNullOrBlank())
+        }
     }
 
     override fun onBindViewHolder(holder: ViewHolder, position: Int, payloads: List<Any>) {



More information about the Android mailing list