Exemplo n.º 1
0
 @Override
 public void trackChanged(MPDStatus mpdStatus, int oldTrack) {
   // Mark running track...
   for (HashMap<String, Object> song : songlist) {
     if (((Integer) song.get("songid")).intValue() == mpdStatus.getSongId())
       song.put("play", android.R.drawable.ic_media_play);
     else song.put("play", 0);
   }
   ((SimpleAdapter) getListAdapter()).notifyDataSetChanged();
 }
Exemplo n.º 2
0
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   MPDApplication app = (MPDApplication) getApplication();
   AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
   int songId = (Integer) songlist.get(info.position).get("songid");
   switch (item.getItemId()) {
     case R.id.PLCX_SkipToHere:
       // skip to selected Song
       try {
         app.oMPDAsyncHelper.oMPD.skipToId(songId);
       } catch (MPDServerException e) {
       }
       return true;
     case R.id.PLCX_playNext:
       try { // Move song to next in playlist
         MPDStatus status = app.oMPDAsyncHelper.oMPD.getStatus();
         if (info.id < status.getSongPos()) {
           app.oMPDAsyncHelper.oMPD.getPlaylist().move(songId, status.getSongPos());
         } else {
           app.oMPDAsyncHelper.oMPD.getPlaylist().move(songId, status.getSongPos() + 1);
         }
         Tools.notifyUser("Song moved to next in list", this);
       } catch (MPDServerException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
       return true;
     case R.id.PLCX_moveFirst:
       try { // Move song to first in playlist
         app.oMPDAsyncHelper.oMPD.getPlaylist().move(songId, 0);
         Tools.notifyUser("Song moved to first in list", this);
       } catch (MPDServerException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
       return true;
     case R.id.PLCX_moveLast:
       try { // Move song to last in playlist
         MPDStatus status = app.oMPDAsyncHelper.oMPD.getStatus();
         app.oMPDAsyncHelper.oMPD.getPlaylist().move(songId, status.getPlaylistLength() - 1);
         Tools.notifyUser("Song moved to last in list", this);
       } catch (MPDServerException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
       return true;
     case R.id.PLCX_removeFromPlaylist:
       try {
         app.oMPDAsyncHelper.oMPD.getPlaylist().removeById(songId);
         Tools.notifyUser(getResources().getString(R.string.deletedSongFromPlaylist), this);
       } catch (MPDServerException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
       return true;
     default:
       return super.onContextItemSelected(item);
   }
 }