Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
531
Issue boards
Milestones
Wiki
Code
Merge requests
14
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
eb74ff30
Commit
eb74ff30
authored
6 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Feature: hide non media files in browser
Fixes
#480
parent
6d6cb24e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+12
-9
12 additions, 9 deletions
...android/src/org/videolan/vlc/providers/BrowserProvider.kt
with
12 additions
and
9 deletions
vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+
12
−
9
View file @
eb74ff30
...
...
@@ -28,8 +28,10 @@ import android.os.HandlerThread
import
android.os.Process
import
android.support.v4.util.SimpleArrayMap
import
kotlinx.coroutines.experimental.*
import
kotlinx.coroutines.experimental.android.Main
import
kotlinx.coroutines.experimental.channels.Channel
import
kotlinx.coroutines.experimental.channels.actor
import
kotlinx.coroutines.experimental.channels.mapNotNullTo
import
kotlinx.coroutines.experimental.channels.mapTo
import
org.videolan.libvlc.Media
import
org.videolan.libvlc.util.MediaBrowser
...
...
@@ -39,8 +41,7 @@ import org.videolan.medialibrary.media.MediaLibraryItem
import
org.videolan.medialibrary.media.MediaWrapper
import
org.videolan.medialibrary.media.Storage
import
org.videolan.vlc.R
import
org.videolan.vlc.util.LiveDataset
import
org.videolan.vlc.util.VLCInstance
import
org.videolan.vlc.util.*
import
java.util.*
const
val
TAG
=
"VLC/BrowserProvider"
...
...
@@ -54,6 +55,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
private
val
foldersContentMap
=
SimpleArrayMap
<
MediaLibraryItem
,
MutableList
<
MediaLibraryItem
>>()
private
lateinit
var
browserChannel
:
Channel
<
Media
>
protected
var
job
:
Job
?
=
null
private
val
showAll
=
Settings
.
getInstance
(
context
).
getBoolean
(
"browser_show_all_files"
,
true
)
val
descriptionUpdate
=
MutableLiveData
<
Pair
<
Int
,
String
>>()
internal
val
medialibrary
=
Medialibrary
.
getInstance
()
...
...
@@ -98,7 +100,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
browserChannel
=
Channel
(
Channel
.
UNLIMITED
)
requestBrowsing
(
url
)
job
=
launch
{
for
(
media
in
browserChannel
)
addMedia
(
findMedia
(
media
)
)
for
(
media
in
browserChannel
)
findMedia
(
media
)
?.
let
{
addMedia
(
it
)
}
if
(
dataset
.
value
.
isNotEmpty
())
parseSubDirectories
()
else
dataset
.
clear
()
// send observable event when folder is empty
}
...
...
@@ -120,7 +122,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
browserChannel
=
Channel
(
Channel
.
UNLIMITED
)
requestBrowsing
(
url
)
job
=
launch
{
dataset
.
value
=
browserChannel
.
mapTo
(
mutableListOf
())
{
findMedia
(
it
)
}
dataset
.
value
=
browserChannel
.
map
NotNull
To
(
mutableListOf
())
{
findMedia
(
it
)
}
parseSubDirectories
()
}
}
...
...
@@ -155,10 +157,10 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
mediabrowser
?.
browse
(
current
.
uri
,
0
)
// retrieve subitems
for
(
media
in
browserChannel
)
{
val
type
=
media
.
typ
e
val
mw
=
findMedia
(
media
)
if
(
type
==
Media
.
Type
.
Directory
)
directories
.
add
(
mw
)
else
if
(
type
==
Media
.
Type
.
File
)
files
.
add
(
mw
)
val
mw
=
findMedia
(
media
)
?:
continu
e
val
type
=
mw
.
type
if
(
type
==
Media
Wrapper
.
TYPE_DIR
)
directories
.
add
(
mw
)
else
files
.
add
(
mw
)
}
// all subitems are in
getDescription
(
directories
.
size
,
files
.
size
).
takeIf
{
it
.
isNotEmpty
()
}
?.
let
{
...
...
@@ -197,9 +199,10 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
return
sb
.
toString
()
}
private
suspend
fun
findMedia
(
media
:
Media
):
MediaWrapper
{
private
suspend
fun
findMedia
(
media
:
Media
):
MediaWrapper
?
{
val
mw
=
MediaWrapper
(
media
)
media
.
release
()
if
(!
showAll
&&
!
mw
.
isBrowserMedia
())
return
null
val
uri
=
mw
.
uri
if
((
mw
.
type
==
MediaWrapper
.
TYPE_AUDIO
||
mw
.
type
==
MediaWrapper
.
TYPE_VIDEO
)
&&
"file"
==
uri
.
scheme
)
return
withContext
(
Dispatchers
.
IO
)
{
medialibrary
.
getMedia
(
uri
)
?:
mw
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment