summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRohit Yengisetty <rohit@cyngn.com>2015-02-18 09:58:59 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2015-02-19 21:39:52 -0800
commit81ec8183e775a2dac75ebcdbcc9bda66d1bcd0ee (patch)
tree002d1f1c74ccbb18b25ee99c67536c46e36db7f5 /src
parent481dea8bcca3426d9580d5c5d3935e4bb7fa59ac (diff)
downloadandroid_packages_apps_Gallery2-81ec8183e775a2dac75ebcdbcc9bda66d1bcd0ee.zip
android_packages_apps_Gallery2-81ec8183e775a2dac75ebcdbcc9bda66d1bcd0ee.tar.gz
android_packages_apps_Gallery2-81ec8183e775a2dac75ebcdbcc9bda66d1bcd0ee.tar.bz2
Gallery2 - Add support to pass in a playlist along with video to play
Change-Id: I9d14dc8801f82f4e343917e094b05251f49d4152 (cherry picked from commit 6df83bf3723bbee27f5a7a9deaa218e2abedf607)
Diffstat (limited to 'src')
-rw-r--r--src/org/codeaurora/gallery3d/ext/IMovieListLoader.java3
-rw-r--r--src/org/codeaurora/gallery3d/ext/MovieListLoader.java44
2 files changed, 43 insertions, 4 deletions
diff --git a/src/org/codeaurora/gallery3d/ext/IMovieListLoader.java b/src/org/codeaurora/gallery3d/ext/IMovieListLoader.java
index db4c713..fe59998 100644
--- a/src/org/codeaurora/gallery3d/ext/IMovieListLoader.java
+++ b/src/org/codeaurora/gallery3d/ext/IMovieListLoader.java
@@ -1,5 +1,6 @@
package org.codeaurora.gallery3d.ext;
+import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -35,7 +36,7 @@ public interface IMovieListLoader {
* @param l
* @param item
*/
- void fillVideoList(Context context, Intent intent, LoaderListener l, IMovieItem item);
+ void fillVideoList(Activity context, Intent intent, LoaderListener l, IMovieItem item);
/**
* enable video list or not.
* @param intent
diff --git a/src/org/codeaurora/gallery3d/ext/MovieListLoader.java b/src/org/codeaurora/gallery3d/ext/MovieListLoader.java
index 840477f..94e6afd 100644
--- a/src/org/codeaurora/gallery3d/ext/MovieListLoader.java
+++ b/src/org/codeaurora/gallery3d/ext/MovieListLoader.java
@@ -1,5 +1,6 @@
package org.codeaurora.gallery3d.ext;
+import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
@@ -12,6 +13,9 @@ import android.provider.MediaStore;
import android.provider.OpenableColumns;
import android.util.Log;
+import java.io.File;
+import java.util.ArrayList;
+
/**
* Movie list loader class. It will load videos from MediaProvider database.
* If MoviePlayer starting activity doesn't set any thing, default OrderBy will be used.
@@ -24,7 +28,41 @@ public class MovieListLoader implements IMovieListLoader {
private MovieListFetcherTask mListTask;
@Override
- public void fillVideoList(Context context, Intent intent, LoaderListener l, IMovieItem item) {
+ public void fillVideoList(Activity activity, Intent intent, final LoaderListener l,
+ IMovieItem currentMovieItem) {
+
+ // determine if a video playlist has been passed in through the intent
+ // if a playlist does exist, use that
+ ArrayList<Uri> uris = intent.getParcelableArrayListExtra("EXTRA_FILE_LIST");
+ if (uris != null) {
+ final MovieList movieList = new MovieList();
+ ContentResolver cr = activity.getContentResolver();
+
+ for(Uri uri : uris) {
+ // add currentMovieItem in its proper place in the video playlist
+ // 'Next' and 'Previous' functionality in MovieListHooker is dependent on reference
+ // matching currentMovieItem
+ if (currentMovieItem.getOriginalUri().equals(uri)) {
+ movieList.add(currentMovieItem);
+ continue;
+ }
+
+ File videoFile = new File(uri.getPath());
+ movieList.add(new MovieItem(uri, cr.getType(uri), videoFile.getName()));
+ }
+
+ // notify callback on main thread
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ l.onListLoaded(movieList);
+ }
+ });
+
+ return;
+ }
+
+ // proceed with creating a playlist if one isn't found
boolean fetechAll = false;
if (intent.hasExtra(EXTRA_ALL_VIDEO_FOLDER)) {
fetechAll = intent.getBooleanExtra(EXTRA_ALL_VIDEO_FOLDER, false);
@@ -35,8 +73,8 @@ public class MovieListLoader implements IMovieListLoader {
orderBy = intent.getStringExtra(EXTRA_ORDERBY);
}
cancelList();
- mListTask = new MovieListFetcherTask(context, fetechAll, l, orderBy);
- mListTask.execute(item);
+ mListTask = new MovieListFetcherTask(activity, fetechAll, l, orderBy);
+ mListTask.execute(currentMovieItem);
if (LOG) {
Log.v(TAG, "fillVideoList() fetechAll=" + fetechAll + ", orderBy=" + orderBy);
}