[Android] Remove useless list

Geoffrey Métais git at videolan.org
Thu May 21 18:36:18 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu May 21 18:36:01 2015 +0200| [80f6cbabdcf029980387c6b8bb6d75e3400a7992] | committer: Geoffrey Métais

Remove useless list

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=80f6cbabdcf029980387c6b8bb6d75e3400a7992
---

 .../org/videolan/vlc/gui/audio/AudioPlayer.java    |    6 ++--
 .../vlc/gui/audio/AudioPlaylistAdapter.java        |   33 +++-----------------
 2 files changed, 8 insertions(+), 31 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index 069728d..6b23f57 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -27,6 +27,7 @@ import android.content.SharedPreferences;
 import android.media.AudioManager;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Parcelable;
 import android.preference.PreferenceManager;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentActivity;
@@ -67,6 +68,7 @@ import org.videolan.vlc.util.Strings;
 import org.videolan.vlc.util.Util;
 import org.videolan.vlc.widget.AudioMediaSwitcher.AudioMediaSwitcherListener;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class AudioPlayer extends Fragment implements IAudioPlayer, View.OnClickListener {
@@ -229,7 +231,7 @@ public class AudioPlayer extends Fragment implements IAudioPlayer, View.OnClickL
         mSongsList.setOnItemClickListener(new OnItemClickListener() {
             @Override
             public void onItemClick(AdapterView<?> av, View v, int p, long id) {
-                mAudioController.load(mSongsListAdapter.getItems(), p);
+                mAudioController.playIndex(p);
             }
         });
         mSongsList.setOnItemLongClickListener(new OnItemLongClickListener() {
@@ -608,7 +610,7 @@ public class AudioPlayer extends Fragment implements IAudioPlayer, View.OnClickL
                 FragmentManager fm = getActivity().getSupportFragmentManager();
                 SavePlaylist savePlaylistDialog = new SavePlaylist();
                 Bundle args = new Bundle();
-                args.putParcelableArrayList(SavePlaylist.KEY_TRACKS, mSongsListAdapter.getItems());
+                args.putParcelableArrayList(SavePlaylist.KEY_TRACKS, (ArrayList<MediaWrapper>) mAudioController.getMedias());
                 savePlaylistDialog.setArguments(args);
                 savePlaylistDialog.show(fm, "fragment_save_playlist");
                 break;
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
index 740e6ee..8963f3b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
@@ -47,7 +47,6 @@ import java.util.List;
 
 public class AudioPlaylistAdapter extends ArrayAdapter<MediaWrapper> {
 
-    private ArrayList<MediaWrapper> mMediaList;
     private int mCurrentIndex;
     private Context mContext;
     private int mAlignMode;
@@ -55,30 +54,11 @@ public class AudioPlaylistAdapter extends ArrayAdapter<MediaWrapper> {
     public AudioPlaylistAdapter(Context context) {
         super(context, 0);
         mContext = context;
-        mMediaList = new ArrayList<MediaWrapper>();
         mCurrentIndex = -1;
         SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
         mAlignMode = Integer.valueOf(preferences.getString("audio_title_alignment", "0"));
     }
 
-    @Override
-    public void add(MediaWrapper m) {
-        mMediaList.add(m);
-        super.add(m);
-    }
-
-    @Override
-    public void remove(MediaWrapper m) {
-        mMediaList.remove(m);
-        super.remove(m);
-    }
-
-    @Override
-    public void clear() {
-        mMediaList.clear();
-        super.clear();
-    }
-
     public void setCurrentIndex(int currentIndex) {
         mCurrentIndex = currentIndex;
     }
@@ -161,23 +141,18 @@ public class AudioPlaylistAdapter extends ArrayAdapter<MediaWrapper> {
 
     public List<String> getLocation(int position) {
         List<String> locations = new ArrayList<String>();
-        if (position >= 0 && position < mMediaList.size())
-            locations.add(mMediaList.get(position).getLocation());
+        if (position >= 0 && position < getCount())
+            locations.add(getItem(position).getLocation());
         return locations;
     }
 
     public List<String> getLocations() {
         List<String> locations = new ArrayList<String>();
-        for (int i = 0; i < mMediaList.size(); i++) {
-            locations.add(mMediaList.get(i).getLocation());
-        }
+        for (int i = 0 ; i < getCount() ; ++i)
+            locations.add(getItem(i).getLocation());
         return locations;
     }
 
-    public ArrayList<MediaWrapper> getItems(){
-        return mMediaList;
-    }
-
     static class ViewHolder {
         int position;
         TextView title;



More information about the Android mailing list