public void onContextItemSelected(MenuItem item) {
   final Album album =
       (Album)
           mList
               .getAdapter()
               .getItem(
                   ((ThreeLabelsItemView) ((AdapterContextMenuInfo) item.getMenuInfo()).targetView)
                       .position);
   switch (item.getItemId()) {
     case ITEM_CONTEXT_QUEUE:
       mMusicManager.addToPlaylist(
           new QueryResponse(
               mActivity,
               "Adding album \"" + album.name + "\" by " + album.artist + " to playlist...",
               "Error adding album!"),
           album,
           mActivity.getApplicationContext());
       break;
     case ITEM_CONTEXT_PLAY:
       mMusicManager.play(
           new QueryResponse(
               mActivity,
               "Playing album \"" + album.name + "\" by " + album.artist + "...",
               "Error playing album!",
               true),
           album,
           mActivity.getApplicationContext());
       break;
     case ITEM_CONTEXT_INFO:
       DialogFactory.getAlbumDetail(
               mMusicManager, mActivity, album, mActivity.getApplicationContext())
           .show();
       break;
     default:
       return;
   }
 }
 @Override
 public void onOptionsItemSelected(MenuItem item) {
   final SharedPreferences.Editor ed;
   switch (item.getItemId()) {
     case MENU_PLAY_ALL:
       final Artist artist = mArtist;
       final Genre genre = mGenre;
       if (artist != null && genre == null) {
         mMusicManager.play(
             new QueryResponse(
                 mActivity,
                 "Playing all albums by " + artist.name + "...",
                 "Error playing songs!",
                 true),
             genre,
             mActivity.getApplicationContext());
       } else if (genre != null && artist == null) {
         mMusicManager.play(
             new QueryResponse(
                 mActivity,
                 "Playing all albums of genre " + genre.name + "...",
                 "Error playing songs!",
                 true),
             genre,
             mActivity.getApplicationContext());
       } else if (genre != null && artist != null) {
         mMusicManager.play(
             new QueryResponse(
                 mActivity,
                 "Playing all songs of genre " + genre.name + " by " + artist.name + "...",
                 "Error playing songs!",
                 true),
             artist,
             genre,
             mActivity.getApplicationContext());
       }
       break;
     case MENU_SORT_BY_ALBUM_ASC:
       ed = mActivity.getPreferences(Context.MODE_PRIVATE).edit();
       ed.putInt(
           AbstractManager.PREF_SORT_BY_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.ALBUM);
       ed.putString(
           AbstractManager.PREF_SORT_ORDER_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.ORDER_ASC);
       ed.commit();
       fetch();
       break;
     case MENU_SORT_BY_ALBUM_DESC:
       ed = mActivity.getPreferences(Context.MODE_PRIVATE).edit();
       ed.putInt(
           AbstractManager.PREF_SORT_BY_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.ALBUM);
       ed.putString(
           AbstractManager.PREF_SORT_ORDER_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.ORDER_DESC);
       ed.commit();
       fetch();
       break;
     case MENU_SORT_BY_ARTIST_ASC:
       ed = mActivity.getPreferences(Context.MODE_PRIVATE).edit();
       ed.putInt(
           AbstractManager.PREF_SORT_BY_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.ARTIST);
       ed.putString(
           AbstractManager.PREF_SORT_ORDER_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.ORDER_ASC);
       ed.commit();
       fetch();
       break;
     case MENU_SORT_BY_ARTIST_DESC:
       ed = mActivity.getPreferences(Context.MODE_PRIVATE).edit();
       ed.putInt(
           AbstractManager.PREF_SORT_BY_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.ARTIST);
       ed.putString(
           AbstractManager.PREF_SORT_ORDER_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.ORDER_DESC);
       ed.commit();
       fetch();
       break;
     case MENU_SORT_BY_YEAR_ASC:
       ed = mActivity.getPreferences(Context.MODE_PRIVATE).edit();
       ed.putInt(
           AbstractManager.PREF_SORT_BY_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.YEAR);
       ed.putString(
           AbstractManager.PREF_SORT_ORDER_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.ORDER_ASC);
       ed.commit();
       fetch();
       break;
     case MENU_SORT_BY_YEAR_DESC:
       ed = mActivity.getPreferences(Context.MODE_PRIVATE).edit();
       ed.putInt(
           AbstractManager.PREF_SORT_BY_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.YEAR);
       ed.putString(
           AbstractManager.PREF_SORT_ORDER_PREFIX + AbstractManager.PREF_SORT_KEY_ALBUM,
           SortType.ORDER_DESC);
       ed.commit();
       fetch();
       break;
     case MENU_SWITCH_VIEW:
       mCurrentView = (mCurrentView % 2) + 1;
       fetch();
       break;
   }
 }