[Android] InfoActivity: hide the file size view if the file size cannot be determined

Nicolas Pomepuy git at videolan.org
Mon Mar 21 12:37:24 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Mar 21 13:17:25 2022 +0100| [1d7fe50ab0d746411a43e879326974d54cb66967] | committer: Duncan McNamara

InfoActivity: hide the file size view if the file size cannot be determined

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

 application/vlc-android/res/layout/info_activity.xml           |  6 ++++++
 .../vlc-android/src/org/videolan/vlc/gui/InfoActivity.kt       | 10 ++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/res/layout/info_activity.xml b/application/vlc-android/res/layout/info_activity.xml
index 09336213c..c9b83930a 100644
--- a/application/vlc-android/res/layout/info_activity.xml
+++ b/application/vlc-android/res/layout/info_activity.xml
@@ -269,6 +269,12 @@
                         vlc:layout_constraintStart_toStartOf="@+id/length_title"
                         vlc:layout_constraintTop_toBottomOf="@+id/length_title" />
 
+                <androidx.constraintlayout.widget.Group
+                        android:id="@+id/file_size_views"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        vlc:constraint_referenced_ids="size_title,size_value,size_icon" />
+
                 <ImageView
                         android:id="@+id/size_icon"
                         android:layout_width="wrap_content"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/InfoActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/InfoActivity.kt
index 5a53bda6c..c8638bc4e 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/InfoActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/InfoActivity.kt
@@ -109,7 +109,10 @@ class InfoActivity : AudioPlayerContainerActivity(), View.OnClickListener, PathA
         }
         model.hasSubs.observe(this) { if (it) binding.infoSubtitles.visibility = View.VISIBLE }
         model.mediaTracks.observe(this) { adapter.setTracks(it) }
-        model.sizeText.observe(this) { binding.sizeValueText = it }
+        model.sizeText.observe(this) {
+            binding.fileSizeViews.visibility = if (it.isNotBlank()) View.VISIBLE else View.GONE
+            binding.sizeValueText = it
+        }
         model.cover.observe(this) {
             if (it != null) {
                 binding.cover = BitmapDrawable(this at InfoActivity.resources, it)
@@ -279,7 +282,10 @@ class InfoModel : ViewModel() {
     fun checkFile(mw: MediaWrapper) = viewModelScope.launch {
         val itemFile = withContext(Dispatchers.IO) { File(Uri.decode(mw.location.substring(5))) }
 
-        if (!withContext(Dispatchers.IO) { itemFile.exists() } || !isActive) return at launch
+        if (!withContext(Dispatchers.IO) { itemFile.exists() } || !isActive) {
+            sizeText.value = ""
+            return at launch
+        }
         if (mw.type == MediaWrapper.TYPE_VIDEO) checkSubtitles(itemFile)
         sizeText.value = itemFile.length().readableFileSize()
     }



More information about the Android mailing list