use of org.videolan.vlc.gui.dialogs.SavePlaylistDialog 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;
}
use of org.videolan.vlc.gui.dialogs.SavePlaylistDialog 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.vlc.gui.dialogs.SavePlaylistDialog in project vlc-android by GeoffreyMetais.
the class BaseBrowserFragment method handleContextItemSelected.
protected boolean handleContextItemSelected(MenuItem item, final int position) {
int id = item.getItemId();
if (!(mAdapter.getItem(position) instanceof MediaWrapper))
return super.onContextItemSelected(item);
final Uri uri = ((MediaWrapper) mAdapter.getItem(position)).getUri();
final MediaWrapper mwFromMl = "file".equals(uri.getScheme()) ? mMediaLibrary.getMedia(uri) : null;
final MediaWrapper mw = mwFromMl != null ? mwFromMl : (MediaWrapper) mAdapter.getItem(position);
switch(id) {
case R.id.directory_view_play_all:
mw.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
playAll(mw);
return true;
case R.id.directory_view_append:
{
MediaUtils.appendMedia(getActivity(), mw);
return true;
}
case R.id.directory_view_delete:
if (checkWritePermission(mw, new Runnable() {
@Override
public void run() {
removeMedia(mw);
}
}))
removeMedia(mw);
return true;
case R.id.directory_view_info:
showMediaInfo(mw);
return true;
case R.id.directory_view_play_audio:
mw.addFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
MediaUtils.openMedia(getActivity(), mw);
return true;
case R.id.directory_view_play_folder:
MediaUtils.openMedia(getActivity(), mw);
return true;
case R.id.directory_view_add_playlist:
FragmentManager fm = getActivity().getSupportFragmentManager();
SavePlaylistDialog savePlaylistDialog = new SavePlaylistDialog();
Bundle infoArgs = new Bundle();
infoArgs.putParcelableArray(SavePlaylistDialog.KEY_NEW_TRACKS, mw.getTracks());
savePlaylistDialog.setArguments(infoArgs);
savePlaylistDialog.show(fm, "fragment_add_to_playlist");
return true;
case R.id.directory_subtitles_download:
MediaUtils.getSubs(getActivity(), mw);
return true;
}
return false;
}
use of org.videolan.vlc.gui.dialogs.SavePlaylistDialog in project vlc-android by videolan.
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) {
mService.append(media);
return true;
} else if (id == R.id.audio_list_browser_insert_next) {
mService.insertNext(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.vlc.gui.dialogs.SavePlaylistDialog in project vlc-android by videolan.
the class BaseBrowserFragment method handleContextItemSelected.
protected boolean handleContextItemSelected(MenuItem item, final int position) {
int id = item.getItemId();
if (!(mAdapter.getItem(position) instanceof MediaWrapper))
return super.onContextItemSelected(item);
final Uri uri = ((MediaWrapper) mAdapter.getItem(position)).getUri();
MediaWrapper mwFromMl = "file".equals(uri.getScheme()) ? mMediaLibrary.getMedia(uri) : null;
final MediaWrapper mw = mwFromMl != null ? mwFromMl : (MediaWrapper) mAdapter.getItem(position);
switch(id) {
case R.id.directory_view_play_all:
mw.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
playAll(mw);
return true;
case R.id.directory_view_append:
{
if (mService != null)
mService.append(mw);
return true;
}
case R.id.directory_view_delete:
if (checkWritePermission(mw, new Runnable() {
@Override
public void run() {
removeMedia(mw);
}
}))
removeMedia(mw);
return true;
case R.id.directory_view_info:
showMediaInfo(mw);
return true;
case R.id.directory_view_play_audio:
if (mService != null) {
mw.addFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
mService.load(mw);
}
return true;
case R.id.directory_view_play_folder:
MediaUtils.openMedia(getActivity(), mw);
return true;
case R.id.directory_view_add_playlist:
FragmentManager fm = getActivity().getSupportFragmentManager();
SavePlaylistDialog savePlaylistDialog = new SavePlaylistDialog();
Bundle infoArgs = new Bundle();
infoArgs.putParcelableArray(SavePlaylistDialog.KEY_NEW_TRACKS, mw.getTracks());
savePlaylistDialog.setArguments(infoArgs);
savePlaylistDialog.show(fm, "fragment_add_to_playlist");
return true;
case R.id.directory_subtitles_download:
MediaUtils.getSubs(getActivity(), mw);
return true;
}
return false;
}
Aggregations