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);
}
}
}
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;
}
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;
}
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);
}
}
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);
}
Aggregations