Commit 55287184 authored by Adrien Maglo's avatar Adrien Maglo

AudioService: update the playlist when a media file has been removed

parent 31831bf9
......@@ -166,6 +166,17 @@ public class MediaList {
signal_list_event(EventHandler.CustomMediaListItemDeleted, position, uri);
}
public void remove(String location) {
for (int i = 0; i < mInternalList.size(); ++i) {
String uri = mInternalList.get(i).m.getLocation();
if (uri.equals(location)) {
mInternalList.remove(i);
signal_list_event(EventHandler.CustomMediaListItemDeleted, i, uri);
i--;
}
}
}
public int size() {
return mInternalList.size();
}
......
......@@ -1229,6 +1229,11 @@ public class AudioService extends Service {
mLibVLC.getMediaList().remove(position);
}
@Override
public void removeLocation(String location) {
mLibVLC.getMediaList().remove(location);
}
@Override
public List<String> getMediaLocations() {
ArrayList<String> medias = new ArrayList<String>();
......
......@@ -261,6 +261,12 @@ public class AudioServiceController implements IAudioPlayerControl {
new Object[] { position } );
}
public void removeLocation(String location) {
remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "removeLocation",
new Class<?>[] { String.class },
new Object[] { location } );
}
@SuppressWarnings("unchecked")
public List<String> getMediaLocations() {
List<String> def = new ArrayList<String>();
......
......@@ -263,6 +263,7 @@ public class AudioAlbumsSongsFragment extends SherlockFragment {
mMediaLibrary.getMediaItems().remove(media);
mSongsAdapter.removeMedia(media);
mAlbumsAdapter.removeMedia(media);
mAudioController.removeLocation(media.getLocation());
}
});
alertDialog.show();
......
......@@ -255,7 +255,9 @@ public class AudioBrowserFragment extends SherlockFragment {
@Override
public void run(Object o) {
AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem)o;
mMediaLibrary.getMediaItems().remove(listItem.mMediaList.get(0));
Media media = listItem.mMediaList.get(0);
mMediaLibrary.getMediaItems().remove(media);
mAudioController.removeLocation(media.getLocation());
updateLists();
}
});
......
......@@ -99,6 +99,8 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
private Thumbnailer mThumbnailer;
private VideoGridAnimator mAnimator;
private AudioServiceController mAudioController;
/* All subclasses of Fragment must include a public empty constructor. */
public VideoGridFragment() { }
......@@ -106,6 +108,8 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAudioController = AudioServiceController.getInstance();
mVideoAdapter = new VideoListAdapter(getActivity(), this);
mMediaLibrary = MediaLibrary.getInstance(getActivity());
setListAdapter(mVideoAdapter);
......@@ -270,7 +274,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
}
protected void playAudio(Media media) {
AudioServiceController.getInstance().load(media.getLocation(), true);
mAudioController.load(media.getLocation(), true);
}
private boolean handleContextItemSelected(MenuItem menu, int position) {
......@@ -301,6 +305,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
Media media = (Media) o;
mMediaLibrary.getMediaItems().remove(media);
mVideoAdapter.remove(media);
mAudioController.removeLocation(media.getLocation());
}
});
alertDialog.show();
......
......@@ -33,6 +33,7 @@ interface IAudioService {
void append(in List<String> mediaPathList);
void moveItem(int positionStart, int positionEnd);
void remove(int position);
void removeLocation(String location);
List<String> getMediaLocations();
String getCurrentMediaLocation();
boolean isPlaying();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment