Search in sources :

Example 46 with MediaWrapper

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

the class HistoryFragment method onDestroyActionMode.

@Override
public void onDestroyActionMode(ActionMode mode) {
    mActionMode = null;
    int index = -1;
    for (MediaWrapper media : mProvider.getDataset().getValue()) {
        ++index;
        if (media.hasStateFlags(MediaLibraryItem.FLAG_SELECTED)) {
            media.removeStateFlags(MediaLibraryItem.FLAG_SELECTED);
            mHistoryAdapter.notifyItemChanged(index, media);
        }
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Example 47 with MediaWrapper

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

the class PlaylistActivity method handleContextItemSelected.

protected boolean handleContextItemSelected(MenuItem item, final int position) {
    int id = item.getItemId();
    final MediaWrapper media = (MediaWrapper) mAdapter.getItem(position);
    if (id == R.id.audio_list_browser_set_song) {
        AudioUtil.setRingtone(media, this);
        return true;
    } else if (id == R.id.audio_list_browser_append) {
        MediaUtils.appendMedia(this, media);
        return true;
    } else if (id == R.id.audio_list_browser_insert_next) {
        MediaUtils.insertNext(this, media);
        return true;
    } else if (id == R.id.audio_list_browser_delete) {
        mAdapter.remove(media);
        final Runnable cancel = new Runnable() {

            @Override
            public void run() {
                mAdapter.addItems(media);
            }
        };
        UiTools.snackerWithCancel(mBinding.getRoot(), getString(R.string.file_deleted), new Runnable() {

            @Override
            public void run() {
                if (mIsPlaylist)
                    ((Playlist) mPlaylist).remove(media.getId());
                else
                    deleteMedia(media, cancel);
            }
        }, cancel);
        return true;
    } else if (id == R.id.audio_view_info) {
        showInfoDialog(media);
        return true;
    } else if (id == R.id.audio_view_add_playlist) {
        FragmentManager fm = getSupportFragmentManager();
        SavePlaylistDialog savePlaylistDialog = new SavePlaylistDialog();
        Bundle args = new Bundle();
        args.putParcelableArray(SavePlaylistDialog.KEY_NEW_TRACKS, media.getTracks());
        savePlaylistDialog.setArguments(args);
        savePlaylistDialog.show(fm, "fragment_add_to_playlist");
        return true;
    }
    return false;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) FragmentManager(android.support.v4.app.FragmentManager) Bundle(android.os.Bundle) SavePlaylistDialog(org.videolan.vlc.gui.dialogs.SavePlaylistDialog)

Example 48 with MediaWrapper

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

the class PlaylistActivity method onActionItemClicked.

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    List<MediaLibraryItem> list = mAdapter.getSelection();
    List<MediaWrapper> tracks = new ArrayList<>();
    for (MediaLibraryItem mediaItem : list) tracks.addAll(Arrays.asList(mediaItem.getTracks()));
    if (item.getItemId() == R.id.action_mode_audio_playlist_up) {
        Toast.makeText(this, "UP !", Toast.LENGTH_SHORT).show();
        return true;
    }
    if (item.getItemId() == R.id.action_mode_audio_playlist_down) {
        Toast.makeText(this, "DOWN !", Toast.LENGTH_SHORT).show();
        return true;
    }
    stopActionMode();
    switch(item.getItemId()) {
        case R.id.action_mode_audio_play:
            MediaUtils.openList(this, tracks, 0);
            break;
        case R.id.action_mode_audio_append:
            MediaUtils.appendMedia(this, tracks);
            break;
        case R.id.action_mode_audio_add_playlist:
            UiTools.addToPlaylist(this, tracks);
            break;
        case R.id.action_mode_audio_info:
            showInfoDialog((MediaWrapper) list.get(0));
            break;
        case R.id.action_mode_audio_set_song:
            AudioUtil.setRingtone((MediaWrapper) list.get(0), this);
            break;
        case R.id.action_mode_audio_delete:
            removeFromPlaylist(tracks);
            break;
        default:
            return false;
    }
    return true;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) ArrayList(java.util.ArrayList)

Example 49 with MediaWrapper

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

the class BaseBrowserFragment method onClick.

public void onClick(View v, int position, MediaLibraryItem item) {
    final MediaWrapper mediaWrapper = (MediaWrapper) item;
    if (mActionMode != null) {
        if (mediaWrapper.getType() == MediaWrapper.TYPE_AUDIO || mediaWrapper.getType() == MediaWrapper.TYPE_VIDEO || mediaWrapper.getType() == MediaWrapper.TYPE_DIR) {
            item.toggleStateFlag(MediaLibraryItem.FLAG_SELECTED);
            mAdapter.updateSelectionCount(mediaWrapper.hasStateFlags(MediaLibraryItem.FLAG_SELECTED));
            mAdapter.notifyItemChanged(position, item);
            invalidateActionMode();
        }
    } else {
        mediaWrapper.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
        if (mediaWrapper.getType() == MediaWrapper.TYPE_DIR)
            browse(mediaWrapper, true);
        else
            MediaUtils.openMedia(v.getContext(), mediaWrapper);
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Example 50 with MediaWrapper

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

the class BaseBrowserFragment method inflate.

@Override
protected void inflate(Menu menu, int position) {
    final MediaWrapper mw = (MediaWrapper) mAdapter.getItem(position);
    if (mw == null)
        return;
    final int type = mw.getType();
    final MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(type == MediaWrapper.TYPE_DIR ? R.menu.directory_view_dir : R.menu.directory_view_file, menu);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MenuInflater(android.view.MenuInflater)

Aggregations

MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)157 ArrayList (java.util.ArrayList)36 MediaLibraryItem (org.videolan.medialibrary.media.MediaLibraryItem)23 Bitmap (android.graphics.Bitmap)18 Intent (android.content.Intent)16 Uri (android.net.Uri)15 List (java.util.List)11 Bundle (android.os.Bundle)10 Context (android.content.Context)9 MediaGroup (org.videolan.vlc.media.MediaGroup)9 PendingIntent (android.app.PendingIntent)8 View (android.view.View)8 TargetApi (android.annotation.TargetApi)6 Cursor (android.database.Cursor)6 FragmentManager (android.support.v4.app.FragmentManager)6 File (java.io.File)6 LinkedList (java.util.LinkedList)6 Medialibrary (org.videolan.medialibrary.Medialibrary)6 SavePlaylistDialog (org.videolan.vlc.gui.dialogs.SavePlaylistDialog)6 SharedPreferences (android.content.SharedPreferences)5