Skip to content
Snippets Groups Projects
Commit 1d7fe50a authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Duncan McNamara
Browse files

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

parent 442c2449
No related branches found
No related tags found
1 merge request!1307Fix video quality top margin in InfoActivity
Pipeline #202616 passed with stage
in 20 minutes and 52 seconds
......@@ -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"
......
......@@ -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@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@launch
if (!withContext(Dispatchers.IO) { itemFile.exists() } || !isActive) {
sizeText.value = ""
return@launch
}
if (mw.type == MediaWrapper.TYPE_VIDEO) checkSubtitles(itemFile)
sizeText.value = itemFile.length().readableFileSize()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment