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