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