Search in sources :

Example 11 with MediaLibraryItem

use of org.videolan.medialibrary.media.MediaLibraryItem in project vlc-android by videolan.

the class AudioBrowserFragment method setContextMenuItems.

protected void setContextMenuItems(Menu menu, int position) {
    final int pos = mViewPager.getCurrentItem();
    if (pos != MODE_SONG) {
        menu.setGroupVisible(R.id.songs_view_only, false);
        menu.setGroupVisible(R.id.phone_only, false);
    }
    if (pos == MODE_ARTIST || pos == MODE_GENRE || pos == MODE_ALBUM)
        menu.findItem(R.id.audio_list_browser_play).setVisible(true);
    if (pos != MODE_SONG && pos != MODE_PLAYLIST)
        menu.findItem(R.id.audio_list_browser_delete).setVisible(false);
    else {
        final MenuItem item = menu.findItem(R.id.audio_list_browser_delete);
        AudioBrowserAdapter adapter = pos == MODE_SONG ? mSongsAdapter : mPlaylistAdapter;
        MediaLibraryItem mediaItem = adapter.getItem(position);
        if (pos == MODE_PLAYLIST)
            item.setVisible(true);
        else {
            String location = ((MediaWrapper) mediaItem).getLocation();
            item.setVisible(FileUtils.canWrite(location));
        }
    }
    if (!AndroidDevices.isPhone)
        menu.setGroupVisible(R.id.phone_only, false);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) MenuItem(android.view.MenuItem)

Example 12 with MediaLibraryItem

use of org.videolan.medialibrary.media.MediaLibraryItem in project vlc-android by videolan.

the class CardPresenter method onBindViewHolder.

@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, final Object item) {
    ViewHolder holder = ((ViewHolder) viewHolder);
    if (item instanceof MediaWrapper) {
        final MediaWrapper mediaWrapper = (MediaWrapper) item;
        holder.mCardView.setTitleText(mediaWrapper.getTitle());
        holder.mCardView.setContentText(mediaWrapper.getDescription());
        if (mediaWrapper.getType() == MediaWrapper.TYPE_GROUP)
            holder.updateCardViewImage(ContextCompat.getDrawable(mContext, R.drawable.ic_video_collection_big));
        else {
            holder.updateCardViewImage(mediaWrapper);
            if (mIsSeenMediaMarkerVisible && mediaWrapper.getType() == MediaWrapper.TYPE_VIDEO && mediaWrapper.getSeen() > 0L)
                holder.mCardView.setBadgeImage(ContextCompat.getDrawable(mContext, R.drawable.ic_seen_tv_normal));
        }
        holder.view.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
                TvUtil.showMediaDetail(v.getContext(), mediaWrapper);
                return true;
            }
        });
    } else if (item instanceof MediaLibraryItem) {
        MediaLibraryItem mediaLibraryItem = (MediaLibraryItem) item;
        holder.mCardView.setTitleText(mediaLibraryItem.getTitle());
        holder.mCardView.setContentText(mediaLibraryItem.getDescription());
        holder.updateCardViewImage(mediaLibraryItem);
    } else if (item instanceof SimpleCard) {
        SimpleCard card = (SimpleCard) item;
        Bitmap image = card.getImage();
        holder.mCardView.setTitleText(card.getName());
        holder.mCardView.setContentText(card.getDescription());
        holder.updateCardViewImage(image != null ? new BitmapDrawable(mRes, image) : ContextCompat.getDrawable(mContext, card.getImageId()));
    } else if (item instanceof String) {
        holder.mCardView.setTitleText((String) item);
        holder.mCardView.setContentText("");
        holder.updateCardViewImage(sDefaultCardImage);
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Bitmap(android.graphics.Bitmap) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageCardView(android.support.v17.leanback.widget.ImageCardView) ImageView(android.widget.ImageView) View(android.view.View)

Example 13 with MediaLibraryItem

use of org.videolan.medialibrary.media.MediaLibraryItem in project vlc-android by GeoffreyMetais.

the class AudioAlbumsSongsFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    RecyclerView.RecycledViewPool rvp = new RecyclerView.RecycledViewPool();
    for (ContextMenuRecyclerView rv : mLists) {
        rv.setLayoutManager(new LinearLayoutManager(view.getContext()));
        final LinearLayoutManager llm = new LinearLayoutManager(getActivity());
        llm.setRecycleChildrenOnDetach(true);
        rv.setLayoutManager(llm);
        rv.setRecycledViewPool(rvp);
    }
    mFabPlay.setImageResource(R.drawable.ic_fab_play);
    mTabLayout.addOnTabSelectedListener(this);
    albumProvider.getSections().observe(this, new Observer<List<MediaLibraryItem>>() {

        @Override
        public void onChanged(@Nullable List<MediaLibraryItem> albums) {
            if (albums != null)
                mAlbumsAdapter.update(albums);
        }
    });
    tracksProvider.getSections().observe(this, new Observer<List<MediaLibraryItem>>() {

        @Override
        public void onChanged(@Nullable List<MediaLibraryItem> tracks) {
            if (tracks != null)
                mSongsAdapter.update(tracks);
        }
    });
}
Also used : ContextMenuRecyclerView(org.videolan.vlc.gui.view.ContextMenuRecyclerView) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) ContextMenuRecyclerView(org.videolan.vlc.gui.view.ContextMenuRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) ArrayList(java.util.ArrayList) List(java.util.List) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 14 with MediaLibraryItem

use of org.videolan.medialibrary.media.MediaLibraryItem in project vlc-android by GeoffreyMetais.

the class AudioAlbumsSongsFragment method setContextMenuItems.

protected void setContextMenuItems(Menu menu, int position) {
    if (mViewPager.getCurrentItem() != MODE_SONG) {
        menu.setGroupVisible(R.id.songs_view_only, false);
        menu.setGroupVisible(R.id.phone_only, false);
    }
    if (!AndroidDevices.isPhone)
        menu.setGroupVisible(R.id.phone_only, false);
    menu.findItem(R.id.audio_list_browser_play).setVisible(true);
    // Hide delete if we cannot
    final AudioBrowserAdapter adapter = mViewPager.getCurrentItem() == MODE_ALBUM ? mAlbumsAdapter : mSongsAdapter;
    final MediaLibraryItem mediaItem = adapter.getItem(position);
    String location = mediaItem instanceof MediaWrapper ? ((MediaWrapper) mediaItem).getLocation() : null;
    menu.findItem(R.id.audio_list_browser_delete).setVisible(location != null && FileUtils.canWrite(location));
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem)

Example 15 with MediaLibraryItem

use of org.videolan.medialibrary.media.MediaLibraryItem in project vlc-android by GeoffreyMetais.

the class AudioBrowserAdapter method remove.

public void remove(final MediaLibraryItem... items) {
    final List<MediaLibraryItem> referenceList = peekLast();
    if (referenceList.isEmpty())
        return;
    final List<MediaLibraryItem> dataList = new ArrayList<>(referenceList);
    for (MediaLibraryItem item : items) dataList.remove(item);
    update(dataList);
}
Also used : MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) ArrayList(java.util.ArrayList)

Aggregations

MediaLibraryItem (org.videolan.medialibrary.media.MediaLibraryItem)46 ArrayList (java.util.ArrayList)25 MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)23 Bitmap (android.graphics.Bitmap)8 BitmapDrawable (android.graphics.drawable.BitmapDrawable)8 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)8 List (java.util.List)7 View (android.view.View)6 RecyclerView (android.support.v7.widget.RecyclerView)5 TextView (android.widget.TextView)4 Playlist (org.videolan.medialibrary.media.Playlist)4 Bundle (android.os.Bundle)3 LinkedList (java.util.LinkedList)3 Storage (org.videolan.medialibrary.media.Storage)3 ContextMenuRecyclerView (org.videolan.vlc.gui.view.ContextMenuRecyclerView)3 PackageManager (android.content.pm.PackageManager)2 Resources (android.content.res.Resources)2 WorkerThread (android.support.annotation.WorkerThread)2 TextInputLayout (android.support.design.widget.TextInputLayout)2 ImageCardView (android.support.v17.leanback.widget.ImageCardView)2