use of org.videolan.vlc.media.MediaGroup in project vlc-android by videolan.
the class VideoGridFragment method onClick.
@Override
public void onClick(View v, int position, MediaLibraryItem item) {
final MediaWrapper media = (MediaWrapper) item;
if (mActionMode != null) {
item.toggleStateFlag(MediaLibraryItem.FLAG_SELECTED);
mAdapter.updateSelectionCount(item.hasStateFlags(MediaLibraryItem.FLAG_SELECTED));
mAdapter.notifyItemChanged(position, VideoListAdapter.UPDATE_SELECTION);
invalidateActionMode();
return;
}
final Activity activity = getActivity();
if (media instanceof MediaGroup) {
final String title = media.getTitle().substring(media.getTitle().toLowerCase().startsWith("the") ? 4 : 0);
((MainActivity) activity).showSecondaryFragment(SecondaryActivity.VIDEO_GROUP_LIST, title);
} else {
media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
if (settings.getBoolean("force_play_all", false)) {
final List<MediaWrapper> playList = new ArrayList<>();
MediaUtils.openList(activity, playList, mAdapter.getListWithPosition(playList, position));
} else {
playVideo(media, false);
}
}
}
use of org.videolan.vlc.media.MediaGroup in project vlc-android by videolan.
the class VideoGridFragment method handleContextItemSelected.
protected boolean handleContextItemSelected(MenuItem menu, final int position) {
if (position >= mAdapter.getItemCount())
return false;
final MediaWrapper media = mAdapter.getItem(position);
if (media == null)
return false;
switch(menu.getItemId()) {
case R.id.video_list_play_from_start:
playVideo(media, true);
return true;
case R.id.video_list_play_audio:
playAudio(media);
return true;
case R.id.video_list_play_all:
List<MediaWrapper> playList = new ArrayList<>();
MediaUtils.openList(getActivity(), playList, mAdapter.getListWithPosition(playList, position));
return true;
case R.id.video_list_info:
showInfoDialog(media);
return true;
case R.id.video_list_delete:
removeVideo(media);
return true;
case R.id.video_group_play:
MediaUtils.openList(getActivity(), ((MediaGroup) media).getAll(), 0);
return true;
case R.id.video_list_append:
if (media instanceof MediaGroup)
mService.append(((MediaGroup) media).getAll());
else
mService.append(media);
return true;
case R.id.video_download_subtitles:
MediaUtils.getSubs(getActivity(), media);
return true;
}
return false;
}
use of org.videolan.vlc.media.MediaGroup in project vlc-android by videolan.
the class VideoListAdapter method getListWithPosition.
int getListWithPosition(List<MediaWrapper> list, int position) {
MediaWrapper mw;
int offset = 0;
for (int i = 0; i < getItemCount(); ++i) {
mw = getDataset().get(i);
if (mw instanceof MediaGroup) {
for (MediaWrapper item : ((MediaGroup) mw).getAll()) list.add(item);
if (i < position)
offset += ((MediaGroup) mw).size() - 1;
} else
list.add(mw);
}
return position + offset;
}
use of org.videolan.vlc.media.MediaGroup in project vlc-android by GeoffreyMetais.
the class VideoGridFragment method handleContextItemSelected.
protected boolean handleContextItemSelected(MenuItem menu, final int position) {
if (position >= mAdapter.getItemCount())
return false;
final MediaWrapper media = mAdapter.getItem(position);
if (media == null)
return false;
switch(menu.getItemId()) {
case R.id.video_list_play_from_start:
playVideo(media, true);
return true;
case R.id.video_list_play_audio:
playAudio(media);
return true;
case R.id.video_list_play_all:
List<MediaWrapper> playList = new ArrayList<>();
MediaUtils.openList(getActivity(), playList, mAdapter.getListWithPosition(playList, position));
return true;
case R.id.video_list_info:
showInfoDialog(media);
return true;
case R.id.video_list_delete:
removeVideo(media);
return true;
case R.id.video_group_play:
MediaUtils.openList(getActivity(), ((MediaGroup) media).getAll(), 0);
return true;
case R.id.video_list_append:
if (media instanceof MediaGroup)
MediaUtils.appendMedia(getActivity(), ((MediaGroup) media).getAll());
else
MediaUtils.appendMedia(getActivity(), media);
return true;
case R.id.video_download_subtitles:
MediaUtils.getSubs(getActivity(), media);
return true;
}
return false;
}
use of org.videolan.vlc.media.MediaGroup in project vlc-android by GeoffreyMetais.
the class VideoGridFragment method onClick.
@Override
public void onClick(View v, int position, MediaLibraryItem item) {
final MediaWrapper media = (MediaWrapper) item;
if (mActionMode != null) {
item.toggleStateFlag(MediaLibraryItem.FLAG_SELECTED);
mAdapter.updateSelectionCount(item.hasStateFlags(MediaLibraryItem.FLAG_SELECTED));
mAdapter.notifyItemChanged(position, Constants.UPDATE_SELECTION);
invalidateActionMode();
return;
}
final Activity activity = getActivity();
if (media instanceof MediaGroup) {
final String title = media.getTitle().substring(media.getTitle().toLowerCase().startsWith("the") ? 4 : 0);
((MainActivity) activity).getNavigator().showSecondaryFragment(SecondaryActivity.VIDEO_GROUP_LIST, title);
} else {
media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
if (settings.getBoolean("force_play_all", false)) {
final List<MediaWrapper> playList = new ArrayList<>();
MediaUtils.openList(activity, playList, mAdapter.getListWithPosition(playList, position));
} else {
playVideo(media, false);
}
}
}
Aggregations