Search in sources :

Example 6 with MediaGroup

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;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaGroup(org.videolan.vlc.media.MediaGroup)

Example 7 with MediaGroup

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);
}
Also used : MediaGroup(org.videolan.vlc.media.MediaGroup)

Example 8 with MediaGroup

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);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) ContextMenuRecyclerView(org.videolan.vlc.gui.view.ContextMenuRecyclerView) MenuInflater(android.view.MenuInflater) MediaGroup(org.videolan.vlc.media.MediaGroup)

Example 9 with MediaGroup

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);
        }
    });
}
Also used : Context(android.content.Context) MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) SharedPreferences(android.content.SharedPreferences) MediaGroup(org.videolan.vlc.media.MediaGroup) List(java.util.List) ArrayList(java.util.ArrayList) MainThread(android.support.annotation.MainThread)

Example 10 with MediaGroup

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);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) ContextMenuRecyclerView(org.videolan.vlc.gui.view.ContextMenuRecyclerView) MenuInflater(android.view.MenuInflater) MediaGroup(org.videolan.vlc.media.MediaGroup)

Aggregations

MediaGroup (org.videolan.vlc.media.MediaGroup)10 MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)9 ArrayList (java.util.ArrayList)5 SharedPreferences (android.content.SharedPreferences)3 Activity (android.app.Activity)2 MenuInflater (android.view.MenuInflater)2 MainActivity (org.videolan.vlc.gui.MainActivity)2 SecondaryActivity (org.videolan.vlc.gui.SecondaryActivity)2 ContextMenuRecyclerView (org.videolan.vlc.gui.view.ContextMenuRecyclerView)2 Context (android.content.Context)1 MainThread (android.support.annotation.MainThread)1 List (java.util.List)1