use of org.videolan.vlc.media.MediaGroup in project vlc-android by GeoffreyMetais.
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 videolan.
the class VideoListAdapter method fillView.
private void fillView(ViewHolder holder, MediaWrapper media) {
String text = "";
String resolution = "";
int max = 0;
int progress = 0;
long seen = 0L;
if (media.getType() == MediaWrapper.TYPE_GROUP) {
MediaGroup mediaGroup = (MediaGroup) media;
final int size = mediaGroup.size();
text = VLCApplication.getAppResources().getQuantityString(R.plurals.videos_quantity, size, size);
} else {
/* Time / Duration */
if (media.getLength() > 0) {
final long lastTime = media.getTime();
if (lastTime > 0) {
text = Tools.getProgressText(media);
max = (int) (media.getLength() / 1000);
progress = (int) (lastTime / 1000);
} else {
text = Tools.millisToText(media.getLength());
}
}
resolution = Tools.getResolution(media);
seen = mIsSeenMediaMarkerVisible ? media.getSeen() : 0L;
}
holder.binding.setVariable(BR.resolution, resolution);
holder.binding.setVariable(BR.time, text);
holder.binding.setVariable(BR.max, max);
holder.binding.setVariable(BR.progress, progress);
holder.binding.setVariable(BR.seen, seen);
}
use of org.videolan.vlc.media.MediaGroup in project vlc-android by videolan.
the class VideoGridFragment method onCreateContextMenu.
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
if (menuInfo == null)
return;
// Do not show the menu of media group.
final ContextMenuRecyclerView.RecyclerContextMenuInfo info = (ContextMenuRecyclerView.RecyclerContextMenuInfo) menuInfo;
final MediaWrapper media = mAdapter.getItem(info.position);
if (media == null)
return;
final MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(media instanceof MediaGroup ? R.menu.video_group_contextual : R.menu.video_list, menu);
if (media instanceof MediaGroup) {
if (!AndroidUtil.isHoneycombOrLater) {
menu.findItem(R.id.video_list_append).setVisible(false);
menu.findItem(R.id.video_group_play).setVisible(false);
}
} else
setContextMenuItems(menu, media);
}
use of org.videolan.vlc.media.MediaGroup in project vlc-android by videolan.
the class VideoGridFragment method updateList.
@MainThread
public void updateList() {
mHandler.sendEmptyMessageDelayed(SET_REFRESHING, 300);
final Context ctx = getActivity();
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
final MediaWrapper[] itemList = mMediaLibrary.getVideos();
final List<MediaWrapper> displayList = new ArrayList<>();
if (mGroup != null) {
for (MediaWrapper item : itemList) {
String title = item.getTitle().substring(item.getTitle().toLowerCase().startsWith("the") ? 4 : 0);
if (mGroup == null || title.toLowerCase().startsWith(mGroup.toLowerCase()))
displayList.add(item);
}
} else {
final SharedPreferences preferences = ctx != null ? PreferenceManager.getDefaultSharedPreferences(ctx) : null;
final int minGroupLengthValue = preferences != null ? Integer.valueOf(preferences.getString("video_min_group_length", "6")) : 6;
for (MediaGroup item : MediaGroup.group(itemList, minGroupLengthValue)) displayList.add(item.getMedia());
}
VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
mAdapter.update(displayList);
}
});
mHandler.sendEmptyMessage(UNSET_REFRESHING);
}
});
}
use of org.videolan.vlc.media.MediaGroup in project vlc-android by GeoffreyMetais.
the class VideoGridFragment method onCreateContextMenu.
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
if (menuInfo == null)
return;
// Do not show the menu of media group.
final ContextMenuRecyclerView.RecyclerContextMenuInfo info = (ContextMenuRecyclerView.RecyclerContextMenuInfo) menuInfo;
final MediaWrapper media = mAdapter.getItem(info.position);
if (media == null)
return;
final MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(media instanceof MediaGroup ? R.menu.video_group_contextual : R.menu.video_list, menu);
if (!(media instanceof MediaGroup))
setContextMenuItems(menu, media);
}
Aggregations