[Android] Update streams implementation to match new API

Geoffrey Métais git at videolan.org
Thu Jul 12 17:27:49 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jul 12 17:13:13 2018 +0200| [c585b7bc3b763b9ceb64a9e26d27d744048233c2] | committer: Geoffrey Métais

Update streams implementation to match new API

> https://code.videolan.org/videolan/vlc-android/commit/c585b7bc3b763b9ceb64a9e26d27d744048233c2
---

 medialibrary/jni/medialibrary.cpp                      |  2 +-
 .../src/org/videolan/medialibrary/Medialibrary.java    |  7 +++----
 .../src/org/videolan/vlc/gui/network/MRLAdapter.java   | 18 ++++++++----------
 3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index f2a2cc008..12999eaf9 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -872,7 +872,7 @@ static JNINativeMethod methods[] = {
     {"nativeBanFolder", "(Ljava/lang/String;)V", (void*)banFolder },
     {"nativeUnbanFolder", "(Ljava/lang/String;)V", (void*)unbanFolder },
     {"nativeLastMediaPlayed", "()[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)lastMediaPLayed },
-    {"nativeLastStreamsPlayed", "()[Lorg/videolan/medialibrary/media/HistoryItem;", (void*)lastStreamsPlayed },
+    {"nativeLastStreamsPlayed", "()[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)lastStreamsPlayed },
     {"nativeAddToHistory", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)addToHistory },
     {"nativeClearHistory", "()Z", (void*)clearHistory },
     {"nativeGetVideos", "()[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getVideos },
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index daa3dffcd..9258b6ccb 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -25,7 +25,6 @@ import org.videolan.medialibrary.interfaces.MediaUpdatedCb;
 import org.videolan.medialibrary.media.Album;
 import org.videolan.medialibrary.media.Artist;
 import org.videolan.medialibrary.media.Genre;
-import org.videolan.medialibrary.media.HistoryItem;
 import org.videolan.medialibrary.media.MediaSearchAggregate;
 import org.videolan.medialibrary.media.MediaWrapper;
 import org.videolan.medialibrary.media.Playlist;
@@ -311,8 +310,8 @@ public class Medialibrary {
     }
 
     @WorkerThread
-    public HistoryItem[] lastStreamsPlayed() {
-        return mIsInitiated ? nativeLastStreamsPlayed() : new HistoryItem[0];
+    public MediaWrapper[] lastStreamsPlayed() {
+        return mIsInitiated ? nativeLastStreamsPlayed() : EMPTY_COLLECTION;
     }
 
     public boolean clearHistory() {
@@ -706,7 +705,7 @@ public class Medialibrary {
     private native String[] nativeEntryPoints();
     private native boolean nativeRemoveDevice(String uuid);
     private native MediaWrapper[] nativeLastMediaPlayed();
-    private native HistoryItem[] nativeLastStreamsPlayed();
+    private native MediaWrapper[] nativeLastStreamsPlayed();
     private native  boolean nativeAddToHistory(String mrl, String title);
     private native  boolean nativeClearHistory();
     private native MediaWrapper nativeGetMedia(long id);
diff --git a/vlc-android/src/org/videolan/vlc/gui/network/MRLAdapter.java b/vlc-android/src/org/videolan/vlc/gui/network/MRLAdapter.java
index ad57071f2..486b1660e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/network/MRLAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/network/MRLAdapter.java
@@ -27,12 +27,11 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.widget.TextView;
 
-import org.videolan.medialibrary.media.HistoryItem;
 import org.videolan.medialibrary.media.MediaWrapper;
 import org.videolan.vlc.R;
 
 class MRLAdapter extends RecyclerView.Adapter<MRLAdapter.ViewHolder> {
-    private HistoryItem[] mDataset;
+    private MediaWrapper[] mDataset;
     private MediaPlayerController playerController;
 
     interface MediaPlayerController {
@@ -51,7 +50,7 @@ class MRLAdapter extends RecyclerView.Adapter<MRLAdapter.ViewHolder> {
 
         @Override
         public void onClick(View v) {
-            playerController.playMedia(mDataset[getLayoutPosition()].getMedia());
+            playerController.playMedia(mDataset[getLayoutPosition()]);
         }
     }
 
@@ -60,26 +59,25 @@ class MRLAdapter extends RecyclerView.Adapter<MRLAdapter.ViewHolder> {
     }
 
     @Override
-    public MRLAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
-                                                    int viewType) {
-        View v = LayoutInflater.from(parent.getContext())
+    public MRLAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+        final View v = LayoutInflater.from(parent.getContext())
                 .inflate(R.layout.mrl_item, parent, false);
         return new ViewHolder(v);
     }
 
     @Override
     public void onBindViewHolder(final ViewHolder holder, int position) {
-        final HistoryItem item = mDataset[position];
-        holder.uriTv.setText(Uri.decode(item.getMrl()));
+        final MediaWrapper item = mDataset[position];
+        holder.uriTv.setText(Uri.decode(item.getLocation()));
         holder.titleTv.setText(Uri.decode(item.getTitle()));
     }
 
-    public void setList(HistoryItem[] list){
+    public void setList(MediaWrapper[] list){
         mDataset = list;
         notifyDataSetChanged();
     }
 
-    public HistoryItem getItem(int position) {
+    public MediaWrapper getItem(int position) {
         if (position >= getItemCount() || position < 0)
             return null;
         return mDataset[position];



More information about the Android mailing list