Search in sources :

Example 1 with Album

use of org.videolan.medialibrary.media.Album in project vlc-android by videolan.

the class AudioAlbumsSongsFragment method handleContextItemSelected.

protected boolean handleContextItemSelected(MenuItem item, final int position) {
    int startPosition;
    MediaWrapper[] medias;
    int id = item.getItemId();
    final AudioBrowserAdapter adapter = mViewPager.getCurrentItem() == MODE_ALBUM ? mAlbumsAdapter : mSongsAdapter;
    final MediaLibraryItem mediaItem = adapter.getItem(position);
    boolean useAllItems = id == R.id.audio_list_browser_play_all;
    boolean append = id == R.id.audio_list_browser_append;
    boolean insert_next = id == R.id.audio_list_browser_insert_next;
    if (id == R.id.audio_list_browser_delete) {
        adapter.remove(mediaItem);
        final Runnable cancel = new Runnable() {

            @Override
            public void run() {
                adapter.addItems(mediaItem);
            }
        };
        UiTools.snackerWithCancel(mViewPager, getString(R.string.file_deleted), new Runnable() {

            @Override
            public void run() {
                deleteMedia(mediaItem, true, cancel);
            }
        }, cancel);
        return true;
    }
    if (id == R.id.audio_list_browser_set_song) {
        AudioUtil.setRingtone((MediaWrapper) mediaItem, getActivity());
        return true;
    }
    if (id == R.id.audio_view_info) {
        showInfoDialog((MediaWrapper) mediaItem);
        return true;
    }
    if (id == R.id.audio_view_add_playlist) {
        FragmentManager fm = getActivity().getSupportFragmentManager();
        SavePlaylistDialog savePlaylistDialog = new SavePlaylistDialog();
        Bundle args = new Bundle();
        args.putParcelableArray(SavePlaylistDialog.KEY_NEW_TRACKS, mediaItem.getTracks());
        savePlaylistDialog.setArguments(args);
        savePlaylistDialog.show(fm, "fragment_add_to_playlist");
        return true;
    }
    if (useAllItems) {
        List<MediaLibraryItem> items = new ArrayList<>();
        startPosition = mSongsAdapter.getListWithPosition(items, position);
        medias = items.toArray(new MediaWrapper[items.size()]);
    } else {
        startPosition = 0;
        if (mediaItem instanceof Album)
            medias = mediaItem.getTracks();
        else
            medias = new MediaWrapper[] { (MediaWrapper) mediaItem };
    }
    if (mService != null) {
        if (append)
            mService.append(medias);
        else if (insert_next)
            mService.insertNext(medias);
        else
            mService.load(medias, startPosition);
        return true;
    }
    return false;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Album(org.videolan.medialibrary.media.Album) SavePlaylistDialog(org.videolan.vlc.gui.dialogs.SavePlaylistDialog) FragmentManager(android.support.v4.app.FragmentManager)

Example 2 with Album

use of org.videolan.medialibrary.media.Album in project vlc-android by videolan.

the class AudioAlbumsSongsFragment method onClick.

@Override
public void onClick(View v, int position, MediaLibraryItem item) {
    if (mActionMode != null) {
        super.onClick(v, position, item);
        return;
    }
    if (item instanceof Album) {
        Intent i = new Intent(getActivity(), PlaylistActivity.class);
        i.putExtra(AudioBrowserFragment.TAG_ITEM, item);
        startActivity(i);
    } else
        MediaUtils.openMedia(v.getContext(), (MediaWrapper) item);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Album(org.videolan.medialibrary.media.Album) Intent(android.content.Intent)

Example 3 with Album

use of org.videolan.medialibrary.media.Album in project vlc-android by GeoffreyMetais.

the class AudioAlbumsSongsFragment method onClick.

@Override
public void onClick(View v, int position, MediaLibraryItem item) {
    if (mActionMode != null) {
        super.onClick(v, position, item);
        return;
    }
    if (item instanceof Album) {
        final Intent i = new Intent(getActivity(), PlaylistActivity.class);
        i.putExtra(AudioBrowserFragment.TAG_ITEM, item);
        startActivity(i);
    } else
        MediaUtils.openMedia(v.getContext(), (MediaWrapper) item);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Album(org.videolan.medialibrary.media.Album) Intent(android.content.Intent)

Example 4 with Album

use of org.videolan.medialibrary.media.Album in project vlc-android by GeoffreyMetais.

the class AudioAlbumsSongsFragment method handleContextItemSelected.

protected boolean handleContextItemSelected(MenuItem item, final int position) {
    int startPosition;
    MediaWrapper[] medias;
    int id = item.getItemId();
    final AudioBrowserAdapter adapter = mViewPager.getCurrentItem() == MODE_ALBUM ? mAlbumsAdapter : mSongsAdapter;
    final MediaLibraryItem mediaItem = adapter.getItem(position);
    boolean useAllItems = id == R.id.audio_list_browser_play_all;
    boolean append = id == R.id.audio_list_browser_append;
    boolean insert_next = id == R.id.audio_list_browser_insert_next;
    if (id == R.id.audio_list_browser_delete) {
        adapter.remove(mediaItem);
        final Runnable cancel = new Runnable() {

            @Override
            public void run() {
                adapter.addItems(mediaItem);
            }
        };
        UiTools.snackerWithCancel(mViewPager, getString(R.string.file_deleted), new Runnable() {

            @Override
            public void run() {
                deleteMedia(mediaItem, true, cancel);
            }
        }, cancel);
        return true;
    }
    if (id == R.id.audio_list_browser_set_song) {
        AudioUtil.setRingtone((MediaWrapper) mediaItem, getActivity());
        return true;
    }
    if (id == R.id.audio_view_info) {
        showInfoDialog((MediaWrapper) mediaItem);
        return true;
    }
    if (id == R.id.audio_view_add_playlist) {
        final FragmentManager fm = getActivity().getSupportFragmentManager();
        SavePlaylistDialog savePlaylistDialog = new SavePlaylistDialog();
        final Bundle args = new Bundle();
        args.putParcelableArray(SavePlaylistDialog.KEY_NEW_TRACKS, mediaItem.getTracks());
        savePlaylistDialog.setArguments(args);
        savePlaylistDialog.show(fm, "fragment_add_to_playlist");
        return true;
    }
    if (useAllItems) {
        final List<MediaLibraryItem> items = new ArrayList<>();
        startPosition = mSongsAdapter.getListWithPosition(items, position);
        medias = items.toArray(new MediaWrapper[items.size()]);
    } else {
        startPosition = 0;
        if (mediaItem instanceof Album)
            medias = mediaItem.getTracks();
        else
            medias = new MediaWrapper[] { (MediaWrapper) mediaItem };
    }
    if (append)
        MediaUtils.appendMedia(getActivity(), medias);
    else if (insert_next)
        MediaUtils.insertNext(getActivity(), medias);
    else
        MediaUtils.openArray(getActivity(), medias, startPosition);
    return true;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Album(org.videolan.medialibrary.media.Album) SavePlaylistDialog(org.videolan.vlc.gui.dialogs.SavePlaylistDialog) FragmentManager(android.support.v4.app.FragmentManager)

Aggregations

Album (org.videolan.medialibrary.media.Album)4 MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)4 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 FragmentManager (android.support.v4.app.FragmentManager)2 ArrayList (java.util.ArrayList)2 MediaLibraryItem (org.videolan.medialibrary.media.MediaLibraryItem)2 SavePlaylistDialog (org.videolan.vlc.gui.dialogs.SavePlaylistDialog)2