[Android] Pass subs path in extra and fix subspicker adapter
Geoffrey Métais
git at videolan.org
Thu Feb 16 18:22:44 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 16 18:21:56 2017 +0100| [41dc902b761f445814e035e2a78709ed84c8a2f9] | committer: Geoffrey Métais
Pass subs path in extra and fix subspicker adapter
> https://code.videolan.org/videolan/vlc-android/commit/41dc902b761f445814e035e2a78709ed84c8a2f9
---
.../org/videolan/vlc/gui/browser/FilePickerAdapter.java | 10 ----------
.../videolan/vlc/gui/browser/FilePickerFragment.java | 17 +++++++++++++++--
.../org/videolan/vlc/gui/video/VideoPlayerActivity.java | 12 ++++++------
3 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java
index 72af3d8..03579ca 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java
@@ -23,8 +23,6 @@
package org.videolan.vlc.gui.browser;
-import android.view.View;
-
import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.medialibrary.media.MediaWrapper;
@@ -56,12 +54,4 @@ public class FilePickerAdapter extends BaseBrowserAdapter {
private boolean filter(MediaWrapper mediaWrapper) {
return mediaWrapper.getType() == MediaWrapper.TYPE_DIR || mediaWrapper.getType() == MediaWrapper.TYPE_SUBTITLE;
}
-
- protected void openMediaFromView(MediaViewHolder holder, View v) {
- final MediaWrapper media = (MediaWrapper) getItem(holder.getAdapterPosition());
- if (media.getType() == MediaWrapper.TYPE_DIR)
- fragment.browse(media, holder.getAdapterPosition(), true);
- else
- ((FilePickerFragment)fragment).pickFile(media);
- }
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
index 8708506..7ffdeb5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
@@ -32,8 +32,9 @@ import android.text.TextUtils;
import android.view.View;
import org.videolan.libvlc.util.MediaBrowser;
-import org.videolan.vlc.R;
+import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.medialibrary.media.MediaWrapper;
+import org.videolan.vlc.R;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.FileUtils;
import org.videolan.vlc.util.Strings;
@@ -41,6 +42,8 @@ import org.videolan.vlc.util.VLCInstance;
public class FilePickerFragment extends FileBrowserFragment {
+ public static final String EXTRA_MRL = "sub_mrl";
+
private static String[] rootDirectories = AndroidDevices.getMediaDirectories();
@Override
@@ -77,8 +80,18 @@ public class FilePickerFragment extends FileBrowserFragment {
getActivity().setTitle(getTitle());
}
+ public void onClick(View v, int position, MediaLibraryItem item) {
+ final MediaWrapper media = (MediaWrapper) item;
+ if (media.getType() == MediaWrapper.TYPE_DIR)
+ browse(media, position, true);
+ else
+ pickFile(media);
+
+ }
void pickFile(MediaWrapper mw){
- getActivity().setResult(Activity.RESULT_OK, new Intent(Intent.ACTION_PICK, mw.getUri()));
+ Intent i = new Intent(Intent.ACTION_PICK);
+ i.putExtra(EXTRA_MRL, mw.getLocation());
+ getActivity().setResult(Activity.RESULT_OK, i);
getActivity().finish();
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index d8a876d..1a1753b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -112,6 +112,7 @@ import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.gui.PlaybackServiceActivity;
import org.videolan.vlc.gui.audio.PlaylistAdapter;
import org.videolan.vlc.gui.browser.FilePickerActivity;
+import org.videolan.vlc.gui.browser.FilePickerFragment;
import org.videolan.vlc.gui.dialogs.AdvOptionsDialog;
import org.videolan.vlc.gui.helpers.OnRepeatListener;
import org.videolan.vlc.gui.helpers.SwipeDragItemTouchHelperCallback;
@@ -945,17 +946,16 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
if(data == null) return;
- if(data.getData() == null)
- Log.d(TAG, "Subtitle selection dialog was cancelled");
- else {
- mService.addSubtitleTrack(data.getData(), true);
+ if(data.hasExtra(FilePickerFragment.EXTRA_MRL)) {
+ mService.addSubtitleTrack(Uri.parse(data.getStringExtra(FilePickerFragment.EXTRA_MRL)), true);
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
- MediaDatabase.getInstance().saveSlave(mService.getCurrentMediaLocation(), Media.Slave.Type.Subtitle, 2, data.getDataString());
+ MediaDatabase.getInstance().saveSlave(mService.getCurrentMediaLocation(), Media.Slave.Type.Subtitle, 2, data.getStringExtra(FilePickerFragment.EXTRA_MRL));
}
});
- }
+ } else
+ Log.d(TAG, "Subtitle selection dialog was cancelled");
}
public static void start(Context context, Uri uri) {
More information about the Android
mailing list