private void onAlbumSelected(MusicDirectory.Entry album, boolean autoplay) {
   Intent intent = new Intent(SearchActivity.this, SelectAlbumActivity.class);
   intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, album.getId());
   intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, album.getTitle());
   intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, autoplay);
   Util.startActivityWithoutTransition(SearchActivity.this, intent);
 }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    MusicDirectory.Entry entry = getItem(position);

    if (entry.isDirectory()) {
      AlbumView view;

      if (convertView != null && convertView instanceof AlbumView) {
        view = (AlbumView) convertView;
      } else {
        view = new AlbumView(activity);
      }

      view.setAlbum(entry, imageLoader);
      return view;

    } else {
      SongView view;

      if (convertView != null && convertView instanceof SongView) {
        view = (SongView) convertView;
      } else {
        view = new SongView(activity);
      }

      view.setSong(entry, checkable);
      return view;
    }
  }
  @Override
  public boolean onContextItemSelected(MenuItem menuItem) {
    AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
    Object selectedItem = list.getItemAtPosition(info.position);

    Artist artist = selectedItem instanceof Artist ? (Artist) selectedItem : null;
    MusicDirectory.Entry entry =
        selectedItem instanceof MusicDirectory.Entry ? (MusicDirectory.Entry) selectedItem : null;
    String id = artist != null ? artist.getId() : entry.getId();

    switch (menuItem.getItemId()) {
      case R.id.album_menu_play_now:
        downloadRecursively(id, false, false, true);
        break;
      case R.id.album_menu_play_last:
        downloadRecursively(id, false, true, false);
        break;
      case R.id.album_menu_pin:
        downloadRecursively(id, true, true, false);
        break;
      case R.id.song_menu_play_now:
        onSongSelected(entry, false, false, true, false);
        break;
      case R.id.song_menu_play_next:
        onSongSelected(entry, false, true, false, true);
        break;
      case R.id.song_menu_play_last:
        onSongSelected(entry, false, true, false, false);
        break;
      default:
        return super.onContextItemSelected(menuItem);
    }

    return true;
  }
 private void onVideoSelected(MusicDirectory.Entry entry) {
   Intent intent = new Intent(Intent.ACTION_VIEW);
   intent.setData(
       Uri.parse(MusicServiceFactory.getMusicService(this).getVideoUrl(this, entry.getId())));
   startActivity(intent);
 }