[Android] LibVLC: MediaBrowser: change browse() arguments
Thomas Guillem
git at videolan.org
Mon Jun 27 17:30:40 CEST 2016
vlc-android | branch: 2.0.x | Thomas Guillem <thomas at gllm.fr> | Mon Jun 27 16:56:14 2016 +0200| [c7536caa0a64b856993cba1bdecae1ad893dbf14] | committer: Geoffrey Métais
LibVLC: MediaBrowser: change browse() arguments
Use a flag instead of a bool
(cherry picked from commit e71d7d88717307eb988706a66af4db4e4ce15f92)
> https://code.videolan.org/videolan/vlc-android/commit/c7536caa0a64b856993cba1bdecae1ad893dbf14
---
.../src/org/videolan/libvlc/util/MediaBrowser.java | 29 +++++++++++++---------
.../vlc/gui/audio/AudioBrowserFragment.java | 2 +-
.../vlc/gui/browser/BaseBrowserFragment.java | 6 ++---
.../vlc/gui/tv/browser/BrowserGridFragment.java | 2 +-
.../vlc/gui/tv/browser/MediaSortedFragment.java | 2 +-
5 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/libvlc/src/org/videolan/libvlc/util/MediaBrowser.java b/libvlc/src/org/videolan/libvlc/util/MediaBrowser.java
index 4310c85..7bc8a7f 100644
--- a/libvlc/src/org/videolan/libvlc/util/MediaBrowser.java
+++ b/libvlc/src/org/videolan/libvlc/util/MediaBrowser.java
@@ -45,6 +45,11 @@ public class MediaBrowser {
private static final String IGNORE_LIST_OPTION = ":ignore-filetypes=";
private String mIgnoreList = "db,nfo,ini,jpg,jpeg,ljpg,gif,png,pgm,pgmyuv,pbm,pam,tga,bmp,pnm,xpm,xcf,pcx,tif,tiff,lbm,sfv,txt,sub,idx,srt,cue,ssa";
+ public static class Flag {
+ /** If this flag is set, browse() could fire up dialogs */
+ public final static int Interact = 1;
+ }
+
/**
* Listener called when medias are added or removed.
*/
@@ -154,12 +159,12 @@ public class MediaBrowser {
* Browse to the specified local path starting with '/'.
*
* @param path
- * @param interact true if browsing could fire up dialogs
+ * @param flags see {@link MediaBrowser.Flag}
*/
@MainThread
- public void browse(String path, boolean interact) {
+ public void browse(String path, int flags) {
final Media media = new Media(mLibVlc, path);
- browse(media, interact);
+ browse(media, flags);
media.release();
}
@@ -167,12 +172,12 @@ public class MediaBrowser {
* Browse to the specified uri.
*
* @param uri
- * @param interact true if browsing could fire up dialogs
+ * @param flags see {@link MediaBrowser.Flag}
*/
@MainThread
- public void browse(Uri uri, boolean interact) {
+ public void browse(Uri uri, int flags) {
final Media media = new Media(mLibVlc, uri);
- browse(media, interact);
+ browse(media, flags);
media.release();
}
@@ -180,22 +185,22 @@ public class MediaBrowser {
* Browse to the specified media.
*
* @param media Can be a media returned by MediaBrowser.
- * @param interact true if browsing could fire up dialogs
+ * @param flags see {@link MediaBrowser.Flag}
*/
@MainThread
- public void browse(Media media, boolean interact) {
+ public void browse(Media media, int flags) {
/* media can be associated with a medialist,
* so increment ref count in order to don't clean it with the medialist
*/
media.retain();
media.addOption(IGNORE_LIST_OPTION + mIgnoreList);
- int flags = Media.Parse.ParseNetwork;
- if (interact)
- flags |= Media.Parse.DoInteract;
+ int mediaFlags = Media.Parse.ParseNetwork;
+ if ((flags & Flag.Interact) != 0)
+ mediaFlags |= Media.Parse.DoInteract;
reset();
mBrowserMediaList = media.subItems();
mBrowserMediaList.setEventListener(mBrowserMediaListEventListener);
- media.parseAsync(flags, 0);
+ media.parseAsync(mediaFlags, 0);
mMedia = media;
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index b71c18f..e2be3b3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -542,7 +542,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
if (medias.size() == 1 && mPlaylistAdapter.getMedias(position).get(0).getType() == MediaWrapper.TYPE_PLAYLIST) {
if (mMediaBrowser == null)
mMediaBrowser = new MediaBrowser(VLCInstance.get(), this);
- mMediaBrowser.browse(mPlaylistAdapter.getMedias(position).get(0).getUri(), true);
+ mMediaBrowser.browse(mPlaylistAdapter.getMedias(position).get(0).getUri(), MediaBrowser.Flag.Interact);
return true;
}
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 3ab5019..163382a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -353,7 +353,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
if (mRoot)
browseRoot();
else
- mMediaBrowser.browse(mCurrentMedia != null ? mCurrentMedia.getUri() : Uri.parse(mMrl), true);
+ mMediaBrowser.browse(mCurrentMedia != null ? mCurrentMedia.getUri() : Uri.parse(mMrl), MediaBrowser.Flag.Interact);
}
private void deleteMedia(final MediaWrapper mw) {
@@ -588,7 +588,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
mw = null;
if (mw != null){
if (mw.getType() == MediaWrapper.TYPE_DIR || mw.getType() == MediaWrapper.TYPE_PLAYLIST){
- mMediaBrowser.browse(mw.getUri(), false);
+ mMediaBrowser.browse(mw.getUri(), 0);
return;
}
}
@@ -641,7 +641,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
if (mw != null) {
if (mCurrentParsedPosition < mAdapter.getItemCount()) {
- mMediaBrowser.browse(mw.getUri(), false);
+ mMediaBrowser.browse(mw.getUri(), 0);
} else {
mCurrentParsedPosition = -1;
releaseBrowser();
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
index 17f8f77..966c2d1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
@@ -72,7 +72,7 @@ public class BrowserGridFragment extends GridFragment implements MediaBrowser.Ev
if (mMediaBrowser != null) {
mMediaList = new ArrayList<>();
if (mUri != null)
- mMediaBrowser.browse(mUri, true);
+ mMediaBrowser.browse(mUri, MediaBrowser.Flag.Interact);
else
mMediaBrowser.discoverNetworkShares();
((BrowserActivityInterface)mContext).showProgress(true);
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaSortedFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaSortedFragment.java
index 9c510c8..fdadc19 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaSortedFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaSortedFragment.java
@@ -59,7 +59,7 @@ public abstract class MediaSortedFragment extends SortedBrowserFragment implemen
mMediaBrowser = new MediaBrowser(VLCInstance.get(), this);
if (mMediaBrowser != null) {
if (mUri != null)
- mMediaBrowser.browse(mUri, true);
+ mMediaBrowser.browse(mUri, MediaBrowser.Flag.Interact);
else
browseRoot();
((BrowserActivityInterface)getActivity()).showProgress(true);
More information about the Android
mailing list