[Android] TV: Add Play All option in browsers
Geoffrey Métais
git at videolan.org
Tue Jun 14 11:01:29 CEST 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jun 13 18:46:44 2016 +0200| [32b1b3732448d4d6edd20b6449fb2e8269e78488] | committer: Geoffrey Métais
TV: Add Play All option in browsers
> https://code.videolan.org/videolan/vlc-android/commit/32b1b3732448d4d6edd20b6449fb2e8269e78488
---
.../videolan/vlc/gui/tv/MediaItemDetailsFragment.java | 18 ++++++++++++++++++
.../vlc/gui/tv/browser/SortedBrowserFragment.java | 10 ++++++++++
2 files changed, 28 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
index 1d8190d..6abfc2e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
@@ -41,15 +41,19 @@ import android.widget.Toast;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
+import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.PlaybackServiceFragment;
import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.gui.helpers.BitmapUtil;
+import org.videolan.vlc.gui.tv.browser.SortedBrowserFragment;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.FileUtils;
+import java.util.ArrayList;
+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class MediaItemDetailsFragment extends DetailsFragment implements PlaybackService.Client.Callback {
private static final String TAG = "MediaItemDetailsFragment";
@@ -59,6 +63,7 @@ public class MediaItemDetailsFragment extends DetailsFragment implements Playbac
private static final int ID_FAVORITE_DELETE = 4;
private static final int ID_BROWSE = 5;
private static final int ID_DL_SUBS = 6;
+ private static final int ID_PLAY_ALL = 7;
private ArrayObjectAdapter mRowsAdapter;
private MediaItemDetails mMedia;
private MediaWrapper mMediaWrapper;
@@ -95,6 +100,8 @@ public class MediaItemDetailsFragment extends DetailsFragment implements Playbac
media.setDisplayTitle(mMedia.getTitle());
}
mMediaWrapper = media;
+
+ final ArrayList<MediaWrapper> mediaList = (ArrayList<MediaWrapper>) VLCApplication.getData(SortedBrowserFragment.CURRENT_BROWSER_LIST);
// Attach your media item details presenter to the row presenter:
FullWidthDetailsOverviewRowPresenter rowPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
@@ -135,6 +142,13 @@ public class MediaItemDetailsFragment extends DetailsFragment implements Playbac
case ID_DL_SUBS:
MediaUtils.getSubs(getActivity(), media);
break;
+ case ID_PLAY_ALL:
+ int position = -1;
+ for (int i= 0; i < mediaList.size(); ++i)
+ if (media.equals(mediaList.get(i)))
+ position = i;
+ MediaUtils.openList(getActivity(), mediaList, position);
+ break;
}
}
});
@@ -164,6 +178,8 @@ public class MediaItemDetailsFragment extends DetailsFragment implements Playbac
detailsOverview.addAction(new Action(ID_PLAY, getString(R.string.play)));
detailsOverview.addAction(new Action(ID_LISTEN, getString(R.string.listen)));
+ if (mediaList != null && mediaList.contains(media))
+ detailsOverview.addAction(new Action(ID_PLAY_ALL, getString(R.string.play_all)));
} else if (media.getType() == MediaWrapper.TYPE_VIDEO) {
// Add images and action buttons to the details view
Bitmap cover = BitmapUtil.getPicture(media);
@@ -175,6 +191,8 @@ public class MediaItemDetailsFragment extends DetailsFragment implements Playbac
detailsOverview.addAction(new Action(ID_PLAY, getString(R.string.play)));
if (FileUtils.canWrite(media.getUri()))
detailsOverview.addAction(new Action(ID_DL_SUBS, getString(R.string.download_subtitles)));
+ if (mediaList != null && mediaList.contains(media))
+ detailsOverview.addAction(new Action(ID_PLAY_ALL, getString(R.string.play_all)));
}
mRowsAdapter.add(detailsOverview);
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
index be51664..eab682c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
@@ -69,6 +69,8 @@ public abstract class SortedBrowserFragment extends BrowseFragment implements Br
public static final String KEY_URI = "uri";
public static final String SELECTED_ITEM = "selected";
+ public static final String CURRENT_BROWSER_LIST = "CURRENT_BROWSER_LIST";
+
public static final int UPDATE_DISPLAY = 1;
public static final int UPDATE_ITEM = 2;
public static final int HIDE_LOADING = 3;
@@ -78,6 +80,7 @@ public abstract class SortedBrowserFragment extends BrowseFragment implements Br
protected MediaWrapper mItemSelected;
protected Map<String, ListItem> mMediaItemMap = new ArrayMap<>();
SimpleArrayMap<String, Integer> mMediaIndex = new SimpleArrayMap<>();
+ ArrayList<MediaWrapper> mVideosList = new ArrayList();
protected BrowserHandler mHandler = new BrowserHandler(this);
abstract protected void browse();
@@ -105,6 +108,11 @@ public abstract class SortedBrowserFragment extends BrowseFragment implements Br
browse();
}
+ @Override
+ public void onResume() {
+ super.onResume();
+ VLCApplication.storeData(CURRENT_BROWSER_LIST, mVideosList);
+ }
@Override
public void onSaveInstanceState(Bundle outState) {
@@ -163,8 +171,10 @@ public abstract class SortedBrowserFragment extends BrowseFragment implements Br
mMediaItemMap = new TreeMap<>(mMediaItemMap); //sort sections
for (ListItem item : mMediaItemMap.values()) {
Collections.sort(item.mediaList, MediaComparators.byFileType);
+ mVideosList.addAll(item.mediaList);
}
mHandler.sendEmptyMessage(UPDATE_DISPLAY);
+ VLCApplication.storeData(CURRENT_BROWSER_LIST, mVideosList);
}
});
}
More information about the Android
mailing list