Skip to content
Snippets Groups Projects
Commit 189917a7 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Android TV: fix file description while browsing

Fixes #1531
If the file size is available, it's displayed, else, no description is displayed
parent ca4d4bc4
No related branches found
No related tags found
1 merge request!787Android TV: fix file description while browsing
Pipeline #37420 passed with stage
in 2 minutes and 31 seconds
......@@ -167,7 +167,13 @@ class FileTvItemAdapter(private val eventsHandler: IEventsHandler<MediaLibraryIt
if (item is MediaWrapper) {
if (item.type == MediaWrapper.TYPE_VIDEO) {
resolution = generateResolutionClass(item.width, item.height) ?: ""
description = if (item.time == 0L) Tools.millisToString(item.length) else Tools.getProgressText(item)
description = when {
item.description?.isNotEmpty() == true -> item.description
item.time != 0L -> Tools.getProgressText(item)
item.time == 0L && item.length != 0L -> Tools.millisToString(item.length)
else -> ""
}
binding.badge = resolution
seen = item.seen
var max = 0
......
......@@ -42,13 +42,11 @@ import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.medialibrary.media.Storage
import org.videolan.resources.VLCInstance
import org.videolan.resources.util.HeaderProvider
import org.videolan.tools.AppScope
import org.videolan.tools.CoroutineContextProvider
import org.videolan.tools.DependencyProvider
import org.videolan.tools.Settings
import org.videolan.tools.*
import org.videolan.tools.livedata.LiveDataset
import org.videolan.vlc.R
import org.videolan.vlc.util.*
import java.io.File
const val TAG = "VLC/BrowserProvider"
......@@ -255,7 +253,18 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
val current = when (item.itemType) {
MediaLibraryItem.TYPE_MEDIA -> {
val mw = item as MediaWrapper
if (mw.type != MediaWrapper.TYPE_DIR && mw.type != MediaWrapper.TYPE_PLAYLIST) continue@loop
if (mw.type != MediaWrapper.TYPE_DIR && mw.type != MediaWrapper.TYPE_PLAYLIST){
if (mw.length == 0L) {
parseMediaSize(mw)?.let {
withContext(coroutineContextProvider.Main) {
item.description = if (it == 0L) "" else it.readableFileSize()
descriptionUpdate.value = Pair(currentParsedPosition, item.description)
}
}
}
continue@loop
}
if (mw.uri.scheme == "otg" || mw.uri.scheme == "content") continue@loop
mw
}
......@@ -292,6 +301,13 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
parsingJob = null
}
private fun parseMediaSize(mw:MediaWrapper):Long? {
mw.uri?.path?.let {
return File(it).length()
}
return null
}
fun hasSubfolders(media: MediaWrapper): Boolean = foldersContentMap.get(media)?.map { it as MediaWrapper }?.filter { it.type == MediaWrapper.TYPE_DIR }?.size ?: 0 > 0
fun hasMedias(media: MediaWrapper): Boolean = foldersContentMap.get(media)?.map { it as MediaWrapper }?.filter { it.type != MediaWrapper.TYPE_DIR }?.size ?: 0 > 0
......
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