use of org.videolan.vlc.extensions.api.VLCExtensionItem in project vlc-android by videolan.
the class BrowserProvider method displayExtensionItems.
@Override
public void displayExtensionItems(int extensionId, String title, List<VLCExtensionItem> items, boolean showParams, boolean isRefresh) {
if (showParams && items.size() == 1 && items.get(0).getType() == VLCExtensionItem.TYPE_DIRECTORY) {
sExtensionManagerService.browse(items.get(0).stringId);
return;
}
MediaDescriptionCompat.Builder mediaItem;
VLCExtensionItem extensionItem;
for (int i = 0; i < items.size(); i++) {
extensionItem = items.get(i);
if (extensionItem == null || (extensionItem.getType() != VLCExtensionItem.TYPE_AUDIO && extensionItem.getType() != VLCExtensionItem.TYPE_DIRECTORY))
continue;
mediaItem = new MediaDescriptionCompat.Builder();
Uri coverUri = extensionItem.getImageUri();
if (coverUri == null)
mediaItem.setIconBitmap(DEFAULT_AUDIO_COVER);
else
mediaItem.setIconUri(coverUri);
mediaItem.setTitle(extensionItem.getTitle());
mediaItem.setSubtitle(extensionItem.getSubTitle());
boolean playable = extensionItem.getType() == VLCExtensionItem.TYPE_AUDIO;
if (playable) {
mediaItem.setMediaId(ExtensionsManager.EXTENSION_PREFIX + "_" + String.valueOf(extensionId) + "_" + extensionItem.getLink());
extensionItems.add(new MediaBrowserCompat.MediaItem(mediaItem.build(), MediaBrowserCompat.MediaItem.FLAG_PLAYABLE));
} else {
mediaItem.setMediaId(ExtensionsManager.EXTENSION_PREFIX + "_" + String.valueOf(extensionId) + "_" + extensionItem.stringId);
extensionItems.add(new MediaBrowserCompat.MediaItem(mediaItem.build(), MediaBrowserCompat.MediaItem.FLAG_BROWSABLE));
}
if (i == MAX_EXTENSION_SIZE - 1)
break;
}
extensionLock.release();
}
use of org.videolan.vlc.extensions.api.VLCExtensionItem in project vlc-android by videolan.
the class ExtensionBrowser method onCreateContextMenu.
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
if (menuInfo == null)
return;
ContextMenuRecyclerView.RecyclerContextMenuInfo info = (ContextMenuRecyclerView.RecyclerContextMenuInfo) menuInfo;
VLCExtensionItem item = mAdapter.getItem(info.position);
if (item.type == VLCExtensionItem.TYPE_DIRECTORY)
return;
boolean isVideo = item.type == VLCExtensionItem.TYPE_VIDEO;
getActivity().getMenuInflater().inflate(R.menu.extension_context_menu, menu);
menu.findItem(R.id.extension_item_view_play_audio).setVisible(isVideo);
}
use of org.videolan.vlc.extensions.api.VLCExtensionItem in project vlc-android by GeoffreyMetais.
the class BrowserProvider method displayExtensionItems.
@Override
public void displayExtensionItems(int extensionId, String title, List<VLCExtensionItem> items, boolean showParams, boolean isRefresh) {
if (showParams && items.size() == 1 && items.get(0).getType() == VLCExtensionItem.TYPE_DIRECTORY) {
sExtensionManagerService.browse(items.get(0).stringId);
return;
}
MediaDescriptionCompat.Builder mediaItem;
VLCExtensionItem extensionItem;
for (int i = 0; i < items.size(); i++) {
extensionItem = items.get(i);
if (extensionItem == null || (extensionItem.getType() != VLCExtensionItem.TYPE_AUDIO && extensionItem.getType() != VLCExtensionItem.TYPE_DIRECTORY))
continue;
mediaItem = new MediaDescriptionCompat.Builder();
Uri coverUri = extensionItem.getImageUri();
if (coverUri == null)
mediaItem.setIconBitmap(DEFAULT_AUDIO_COVER);
else
mediaItem.setIconUri(coverUri);
mediaItem.setTitle(extensionItem.getTitle());
mediaItem.setSubtitle(extensionItem.getSubTitle());
boolean playable = extensionItem.getType() == VLCExtensionItem.TYPE_AUDIO;
if (playable) {
mediaItem.setMediaId(ExtensionsManager.EXTENSION_PREFIX + "_" + String.valueOf(extensionId) + "_" + extensionItem.getLink());
extensionItems.add(new MediaBrowserCompat.MediaItem(mediaItem.build(), MediaBrowserCompat.MediaItem.FLAG_PLAYABLE));
} else {
mediaItem.setMediaId(ExtensionsManager.EXTENSION_PREFIX + "_" + String.valueOf(extensionId) + "_" + extensionItem.stringId);
extensionItems.add(new MediaBrowserCompat.MediaItem(mediaItem.build(), MediaBrowserCompat.MediaItem.FLAG_BROWSABLE));
}
if (i == MAX_EXTENSION_SIZE - 1)
break;
}
extensionLock.release();
}
use of org.videolan.vlc.extensions.api.VLCExtensionItem in project vlc-android by videolan.
the class MainActivity method displayExtensionItems.
@Override
public void displayExtensionItems(int extensionId, String title, List<VLCExtensionItem> items, boolean showParams, boolean refresh) {
if (refresh && getCurrentFragment() instanceof ExtensionBrowser) {
ExtensionBrowser browser = (ExtensionBrowser) getCurrentFragment();
browser.doRefresh(title, items);
} else {
ExtensionBrowser fragment = new ExtensionBrowser();
ArrayList<VLCExtensionItem> list = new ArrayList<>(items);
Bundle args = new Bundle();
args.putParcelableArrayList(ExtensionBrowser.KEY_ITEMS_LIST, list);
args.putBoolean(ExtensionBrowser.KEY_SHOW_FAB, showParams);
args.putString(ExtensionBrowser.KEY_TITLE, title);
fragment.setArguments(args);
fragment.setExtensionService(mExtensionManagerService);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
if (!(mCurrentFragment instanceof ExtensionBrowser)) {
// case: non-extension to extension root
if (mCurrentFragment != null)
ft.hide(mCurrentFragment);
ft.add(R.id.fragment_placeholder, fragment, title);
mCurrentFragment = fragment;
} else if (mCurrentFragmentId == extensionId) {
// case: extension root to extension sub dir
ft.hide(mCurrentFragment);
ft.add(R.id.fragment_placeholder, fragment, title);
ft.addToBackStack(getTag(mCurrentFragmentId));
} else {
// case: extension to other extension root
clearBackstackFromClass(ExtensionBrowser.class);
while (getSupportFragmentManager().popBackStackImmediate()) ;
ft.remove(mCurrentFragment);
ft.add(R.id.fragment_placeholder, fragment, title);
mCurrentFragment = fragment;
}
ft.commit();
mNavigationView.getMenu().findItem(extensionId).setCheckable(true);
updateCheckedItem(extensionId);
mCurrentFragmentId = extensionId;
}
}
use of org.videolan.vlc.extensions.api.VLCExtensionItem in project vlc-android by videolan.
the class ExtensionAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final VLCExtensionItem item = getItem(position);
holder.binding.setItem(item);
holder.binding.executePendingBindings();
}
Aggregations