Search in sources :

Example 1 with ExtensionBrowser

use of org.videolan.vlc.gui.browser.ExtensionBrowser in project vlc-android by videolan.

the class MainActivity method showFragment.

public void showFragment(int id) {
    final FragmentManager fm = getSupportFragmentManager();
    final String tag = getTag(id);
    // Get new fragment
    Fragment fragment = null;
    final WeakReference<Fragment> wr = mFragmentsStack.get(tag);
    final boolean add = wr == null || (fragment = wr.get()) == null;
    if (add) {
        fragment = getNewFragment(id);
        mFragmentsStack.put(tag, new WeakReference<>(fragment));
    }
    if (mCurrentFragment != null)
        if (mCurrentFragment instanceof ExtensionBrowser)
            fm.beginTransaction().remove(mCurrentFragment).commit();
        else {
            if (mCurrentFragment instanceof BaseBrowserFragment && !((BaseBrowserFragment) getCurrentFragment()).isRootDirectory())
                fm.popBackStackImmediate("root", FragmentManager.POP_BACK_STACK_INCLUSIVE);
            fm.beginTransaction().hide(mCurrentFragment).commit();
        }
    final FragmentTransaction ft = fm.beginTransaction();
    if (add)
        ft.add(R.id.fragment_placeholder, fragment, tag);
    else
        ft.show(fragment);
    ft.commit();
    updateCheckedItem(id);
    mCurrentFragment = fragment;
    mCurrentFragmentId = id;
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) BaseBrowserFragment(org.videolan.vlc.gui.browser.BaseBrowserFragment) FragmentTransaction(android.support.v4.app.FragmentTransaction) ExtensionBrowser(org.videolan.vlc.gui.browser.ExtensionBrowser) FileBrowserFragment(org.videolan.vlc.gui.browser.FileBrowserFragment) MediaBrowserFragment(org.videolan.vlc.gui.browser.MediaBrowserFragment) PreferencesFragment(org.videolan.vlc.gui.preferences.PreferencesFragment) VideoGridFragment(org.videolan.vlc.gui.video.VideoGridFragment) AudioBrowserFragment(org.videolan.vlc.gui.audio.AudioBrowserFragment) Fragment(android.support.v4.app.Fragment) NetworkBrowserFragment(org.videolan.vlc.gui.browser.NetworkBrowserFragment) MRLPanelFragment(org.videolan.vlc.gui.network.MRLPanelFragment) BaseBrowserFragment(org.videolan.vlc.gui.browser.BaseBrowserFragment)

Example 2 with ExtensionBrowser

use of org.videolan.vlc.gui.browser.ExtensionBrowser in project vlc-android by videolan.

the class MainActivity method onBackPressed.

@Override
public void onBackPressed() {
    /* Close the menu first */
    if (mDrawerLayout.isDrawerOpen(mNavigationView)) {
        mDrawerLayout.closeDrawer(mNavigationView);
        return;
    }
    /* Close playlist search if open or Slide down the audio player if it is shown entirely. */
    if (isAudioPlayerReady() && (mAudioPlayer.clearSearch() || slideDownAudioPlayer()))
        return;
    // If it's the directory view, a "backpressed" action shows a parent.
    final Fragment fragment = getCurrentFragment();
    if (fragment instanceof BaseBrowserFragment && ((BaseBrowserFragment) fragment).goBack()) {
        return;
    } else if (fragment instanceof ExtensionBrowser) {
        ((ExtensionBrowser) fragment).goBack();
        return;
    }
    if (AndroidUtil.isNougatOrLater && isInMultiWindowMode()) {
        UiTools.confirmExit(this);
        return;
    }
    finish();
}
Also used : BaseBrowserFragment(org.videolan.vlc.gui.browser.BaseBrowserFragment) ExtensionBrowser(org.videolan.vlc.gui.browser.ExtensionBrowser) FileBrowserFragment(org.videolan.vlc.gui.browser.FileBrowserFragment) MediaBrowserFragment(org.videolan.vlc.gui.browser.MediaBrowserFragment) PreferencesFragment(org.videolan.vlc.gui.preferences.PreferencesFragment) VideoGridFragment(org.videolan.vlc.gui.video.VideoGridFragment) AudioBrowserFragment(org.videolan.vlc.gui.audio.AudioBrowserFragment) Fragment(android.support.v4.app.Fragment) NetworkBrowserFragment(org.videolan.vlc.gui.browser.NetworkBrowserFragment) MRLPanelFragment(org.videolan.vlc.gui.network.MRLPanelFragment) BaseBrowserFragment(org.videolan.vlc.gui.browser.BaseBrowserFragment)

Example 3 with ExtensionBrowser

use of org.videolan.vlc.gui.browser.ExtensionBrowser in project vlc-android by videolan.

the class ContentActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    mMenu = menu;
    if (getSupportFragmentManager().findFragmentById(R.id.fragment_placeholder) instanceof AboutFragment)
        return true;
    getMenuInflater().inflate(R.menu.activity_option, menu);
    if (getCurrentFragment() instanceof ExtensionBrowser) {
        menu.findItem(R.id.ml_menu_last_playlist).setVisible(false);
        menu.findItem(R.id.ml_menu_sortby).setVisible(false);
    }
    if (getCurrentFragment() instanceof Filterable) {
        MenuItem searchItem = menu.findItem(R.id.ml_menu_filter);
        mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
        mSearchView.setQueryHint(getString(R.string.search_list_hint));
        mSearchView.setOnQueryTextListener(this);
        MenuItemCompat.setOnActionExpandListener(searchItem, this);
    } else
        menu.findItem(R.id.ml_menu_filter).setVisible(false);
    menu.findItem(R.id.ml_menu_renderers).setVisible(showRenderers);
    menu.findItem(R.id.ml_menu_renderers).setIcon(RendererDelegate.INSTANCE.getSelectedRenderer() == null ? R.drawable.ic_am_renderer_normal_w : R.drawable.ic_am_renderer_on_w);
    return super.onCreateOptionsMenu(menu);
}
Also used : Filterable(org.videolan.vlc.interfaces.Filterable) ExtensionBrowser(org.videolan.vlc.gui.browser.ExtensionBrowser) MenuItem(android.view.MenuItem)

Example 4 with ExtensionBrowser

use of org.videolan.vlc.gui.browser.ExtensionBrowser in project vlc-android by GeoffreyMetais.

the class ContentActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (getSupportFragmentManager().findFragmentById(R.id.fragment_placeholder) instanceof AboutFragment)
        return true;
    getMenuInflater().inflate(R.menu.activity_option, menu);
    if (getCurrentFragment() instanceof ExtensionBrowser) {
        menu.findItem(R.id.ml_menu_last_playlist).setVisible(false);
        menu.findItem(R.id.ml_menu_sortby).setVisible(false);
    }
    if (getCurrentFragment() instanceof Filterable) {
        final MenuItem searchItem = menu.findItem(R.id.ml_menu_filter);
        mSearchView = (SearchView) searchItem.getActionView();
        mSearchView.setQueryHint(getString(R.string.search_list_hint));
        mSearchView.setOnQueryTextListener(this);
        searchItem.setOnActionExpandListener(this);
    } else
        menu.findItem(R.id.ml_menu_filter).setVisible(false);
    menu.findItem(R.id.ml_menu_renderers).setVisible(showRenderers);
    menu.findItem(R.id.ml_menu_renderers).setIcon(!RendererDelegate.INSTANCE.hasRenderer() ? R.drawable.ic_am_renderer_normal_w : R.drawable.ic_am_renderer_on_w);
    return super.onCreateOptionsMenu(menu);
}
Also used : Filterable(org.videolan.vlc.interfaces.Filterable) ExtensionBrowser(org.videolan.vlc.gui.browser.ExtensionBrowser) MenuItem(android.view.MenuItem)

Example 5 with ExtensionBrowser

use of org.videolan.vlc.gui.browser.ExtensionBrowser 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)

Aggregations

ExtensionBrowser (org.videolan.vlc.gui.browser.ExtensionBrowser)8 Fragment (android.support.v4.app.Fragment)5 AudioBrowserFragment (org.videolan.vlc.gui.audio.AudioBrowserFragment)5 BaseBrowserFragment (org.videolan.vlc.gui.browser.BaseBrowserFragment)5 PreferencesFragment (org.videolan.vlc.gui.preferences.PreferencesFragment)5 VideoGridFragment (org.videolan.vlc.gui.video.VideoGridFragment)5 FragmentTransaction (android.support.v4.app.FragmentTransaction)3 FileBrowserFragment (org.videolan.vlc.gui.browser.FileBrowserFragment)3 MediaBrowserFragment (org.videolan.vlc.gui.browser.MediaBrowserFragment)3 NetworkBrowserFragment (org.videolan.vlc.gui.browser.NetworkBrowserFragment)3 MRLPanelFragment (org.videolan.vlc.gui.network.MRLPanelFragment)3 MenuItem (android.view.MenuItem)2 Filterable (org.videolan.vlc.interfaces.Filterable)2 Bundle (android.os.Bundle)1 FragmentManager (android.support.v4.app.FragmentManager)1 ArrayList (java.util.ArrayList)1 VLCExtensionItem (org.videolan.vlc.extensions.api.VLCExtensionItem)1