Search in sources :

Example 1 with VLCExtensionItem

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();
}
Also used : MediaBrowserCompat(android.support.v4.media.MediaBrowserCompat) VLCExtensionItem(org.videolan.vlc.extensions.api.VLCExtensionItem) Uri(android.net.Uri) MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat)

Example 2 with VLCExtensionItem

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);
}
Also used : ContextMenuRecyclerView(org.videolan.vlc.gui.view.ContextMenuRecyclerView) VLCExtensionItem(org.videolan.vlc.extensions.api.VLCExtensionItem)

Example 3 with VLCExtensionItem

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();
}
Also used : MediaBrowserCompat(android.support.v4.media.MediaBrowserCompat) VLCExtensionItem(org.videolan.vlc.extensions.api.VLCExtensionItem) Uri(android.net.Uri) MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat)

Example 4 with VLCExtensionItem

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;
    }
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Bundle(android.os.Bundle) ExtensionBrowser(org.videolan.vlc.gui.browser.ExtensionBrowser) ArrayList(java.util.ArrayList) VLCExtensionItem(org.videolan.vlc.extensions.api.VLCExtensionItem)

Example 5 with VLCExtensionItem

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();
}
Also used : VLCExtensionItem(org.videolan.vlc.extensions.api.VLCExtensionItem)

Aggregations

VLCExtensionItem (org.videolan.vlc.extensions.api.VLCExtensionItem)9 ArrayList (java.util.ArrayList)3 Uri (android.net.Uri)2 MediaBrowserCompat (android.support.v4.media.MediaBrowserCompat)2 MediaDescriptionCompat (android.support.v4.media.MediaDescriptionCompat)2 MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)2 ContextMenuRecyclerView (org.videolan.vlc.gui.view.ContextMenuRecyclerView)2 Bundle (android.os.Bundle)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 ExtensionBrowser (org.videolan.vlc.gui.browser.ExtensionBrowser)1