Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remove from playlist #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
Expand Down Expand Up @@ -329,10 +330,10 @@ public void onItemChanged(ICurrentlyPlaying newItem) {
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
// be aware that this must be explicitly called by your activity!
/* final OneHolder<PlaylistItem>holder = (OneHolder<PlaylistItem>)((AdapterContextMenuInfo)menuInfo).targetView.getTag();
menu.setHeaderTitle(holder.holderItem.filename);
final PlaylistItem playlistItem = (PlaylistItem)(mList.getAdapter().getItem(((AdapterContextMenuInfo)menuInfo).position));
menu.setHeaderTitle(playlistItem.filename);
menu.add(0, ITEM_CONTEXT_PLAY, 1, "Play");
menu.add(0, ITEM_CONTEXT_REMOVE, 2, "Remove");*/
menu.add(0, ITEM_CONTEXT_REMOVE, 2, "Remove");
}

public void onContextItemSelected(MenuItem item) {
Expand All @@ -352,12 +353,26 @@ public void onContextItemSelected(MenuItem item) {
case ITEM_CONTEXT_REMOVE:
switch (mPlayListId) {
case MUSIC_PLAYLIST_ID:
mMusicManager.removeFromPlaylist(new DataResponse<Boolean>(), playlistItem.path, mActivity.getApplicationContext());
mMusicManager.removeFromPlaylist(new DataResponse<Boolean>(){
public void run() {
if (value == false) {
Toast.makeText(mActivity.getApplicationContext(), "Failed to remove song!", Toast.LENGTH_SHORT).show();
}
updatePlaylist();
}
}, playlistItem.path, mActivity.getApplicationContext());
break;
case VIDEO_PLAYLIST_ID:
mVideoManager.removeFromPlaylist(new DataResponse<Boolean>(), playlistItem.path, mActivity.getApplicationContext());
mVideoManager.removeFromPlaylist(new DataResponse<Boolean>(){
public void run() {
if (value == false) {
Toast.makeText(mActivity.getApplicationContext(), "Failed to remove video!", Toast.LENGTH_SHORT).show();
}
updatePlaylist();
}
}, playlistItem.path, mActivity.getApplicationContext());
break;
}
}
break;
default:
return;
Expand Down
4 changes: 2 additions & 2 deletions src/org/xbmc/httpapi/client/MusicClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public boolean setPlaylistPosition(INotifiableManager manager, int position) {
* @return True on success, false otherwise.
*/
public boolean removeFromPlaylist(INotifiableManager manager, int position) {
return mConnection.getBoolean(manager, "RemoveFromPlaylist", PLAYLIST_ID + ";" + position);
return mConnection.getBoolean(manager, "RemoveFromPlaylist", position + ";" + PLAYLIST_ID);
}

/**
Expand All @@ -161,7 +161,7 @@ public boolean removeFromPlaylist(INotifiableManager manager, int position) {
* @return True on success, false otherwise.
*/
public boolean removeFromPlaylist(INotifiableManager manager, String path) {
return mConnection.getBoolean(manager, "RemoveFromPlaylist", PLAYLIST_ID + ";" + path);
return mConnection.getBoolean(manager, "RemoveFromPlaylist", path + ";" + PLAYLIST_ID);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/org/xbmc/httpapi/client/VideoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,6 @@ public ArrayList<String> getPlaylist(INotifiableManager manager) {
* @return True on success, false otherwise.
*/
public boolean removeFromPlaylist(INotifiableManager manager, String path) {
return mConnection.getBoolean(manager, "RemoveFromPlaylist", PLAYLIST_ID + ";" + path);
return mConnection.getBoolean(manager, "RemoveFromPlaylist", path + ";" + PLAYLIST_ID);
}
}