@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mAlbumsAdapter =
        new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITH_COVER);
    mSongsAdapter =
        new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITH_COVER);

    mAlbumsAdapter.setContextPopupMenuListener(mContextPopupMenuListener);
    mSongsAdapter.setContextPopupMenuListener(mContextPopupMenuListener);

    mAudioController = AudioServiceController.getInstance();
    mMediaLibrary = MediaLibrary.getInstance(getActivity());
  }
Beispiel #2
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   mAdapter =
       new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITHOUT_COVER);
   mAdapter.addAll(MediaLibrary.getInstance().getPlaylistDbItems());
   mTracks = getArguments().getParcelableArrayList(KEY_TRACKS);
 }
  private void updateList() {
    if (mediaList == null) return;

    mAlbumsAdapter.clear();
    mSongsAdapter.clear();

    Collections.sort(mediaList, MediaComparators.byAlbum);
    String lastAlbumName = new String();

    for (int i = 0; i < mediaList.size(); ++i) {
      Media media = mediaList.get(i);
      mAlbumsAdapter.add(media.getAlbum(), null, media);

      if (!lastAlbumName.equals(media.getAlbum())) {
        mSongsAdapter.addSeparator(media.getAlbum());
        lastAlbumName = media.getAlbum();
      }
      mSongsAdapter.add(media.getTitle(), null, media);
    }
  }
Beispiel #4
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   mEditText.setText(mAdapter.getItem(position).mTitle);
 }
 @Override
 public void onItemClick(AdapterView<?> av, View v, int p, long id) {
   ArrayList<String> mediaLocation = mSongsAdapter.getLocations(p);
   mAudioController.load(mediaLocation, 0);
 }
  private boolean handleContextItemSelected(MenuItem item, int position) {
    ContextMenuInfo menuInfo = item.getMenuInfo();

    int startPosition;
    int groupPosition;
    List<String> medias;
    int id = item.getItemId();

    boolean useAllItems = id == R.id.audio_list_browser_play_all;
    boolean append = id == R.id.audio_list_browser_append;

    if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) {
      ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
      groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    } else groupPosition = position;

    if (id == R.id.audio_list_browser_delete) {
      AlertDialog alertDialog =
          CommonDialogs.deleteMedia(
              getActivity(),
              mSongsAdapter.getLocations(groupPosition).get(0),
              new VlcRunnable(mSongsAdapter.getItem(groupPosition)) {
                @Override
                public void run(Object o) {
                  AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem) o;
                  Media media = listItem.mMediaList.get(0);
                  mMediaLibrary.getMediaItems().remove(media);
                  mSongsAdapter.removeMedia(media);
                  mAlbumsAdapter.removeMedia(media);
                  mAudioController.removeLocation(media.getLocation());
                }
              });
      alertDialog.show();
      return true;
    }

    if (id == R.id.audio_list_browser_set_song) {
      AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition).mMediaList.get(0), getActivity());
      return true;
    }

    if (useAllItems) {
      medias = new ArrayList<String>();
      startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
    } else {
      startPosition = 0;
      switch (mTabHost.getCurrentTab()) {
        case 0: // albums
          medias = mAlbumsAdapter.getLocations(groupPosition);
          break;
        case 1: // songs
          medias = mSongsAdapter.getLocations(groupPosition);
          break;
        default:
          return true;
      }
    }

    if (append) mAudioController.append(medias);
    else mAudioController.load(medias, startPosition);

    return super.onContextItemSelected(item);
  }