From 9b405b8e1c3c8ccd9b75ff5f3a23b18ceb8842ae Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Wed, 10 Dec 2014 17:20:18 +0800 Subject: Gallery2: Play all video file can pre/next in FileExplorer The initial video can only previous and next in the current directory. List all video file and play it all through pre/next function CRs-Fixed: 704384 Change-Id: Ifd2caac0f2f2df61ee08af82ac7324848807055c --- .../codeaurora/gallery3d/ext/MovieListLoader.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/org/codeaurora/gallery3d/ext/MovieListLoader.java') diff --git a/src/org/codeaurora/gallery3d/ext/MovieListLoader.java b/src/org/codeaurora/gallery3d/ext/MovieListLoader.java index cb3505650..840477ff6 100644 --- a/src/org/codeaurora/gallery3d/ext/MovieListLoader.java +++ b/src/org/codeaurora/gallery3d/ext/MovieListLoader.java @@ -115,6 +115,9 @@ public class MovieListLoader implements IMovieListLoader { //from gallery, gallery3D, videoplayer long curId = Long.parseLong(uri.getPathSegments().get(3)); movieList = fillUriList(null, null, curId, params[0]); + } else if (uristr.toLowerCase().startsWith("file://")) { + long curId = getCursorId(uri); + movieList = fillUriList(null, null, curId, params[0]); } } } else { //get current list @@ -199,5 +202,30 @@ public class MovieListLoader implements IMovieListLoader { } return movieList; } + + private long getCursorId(Uri uri) { + long curId = -1; + Cursor cursor = null; + String data = Uri.decode(uri.toString()); + data = data.replaceAll("'", "''"); + String where = "_data LIKE '%" + data.replaceFirst("file:///", "") + "'"; + try { + cursor = mCr.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, + new String[] { + "_id" + }, where, null, null); + + if (cursor != null && cursor.moveToFirst()) { + curId = cursor.getLong(0); + } + } catch (final SQLiteException e) { + e.printStackTrace(); + } finally { + if (cursor != null) { + cursor.close(); + } + } + return curId; + } } } -- cgit v1.2.3