Search in sources :

Example 1 with MRLPanelFragment

use of org.videolan.vlc.gui.network.MRLPanelFragment in project vlc-android by videolan.

the class MainActivity method onNavigationItemSelected.

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // This should not happen
    if (item == null)
        return false;
    int id = item.getItemId();
    final Fragment current = getCurrentFragment();
    if (item.getGroupId() == R.id.extensions_group) {
        if (mCurrentFragmentId == id) {
            clearBackstackFromClass(ExtensionBrowser.class);
            mDrawerLayout.closeDrawer(mNavigationView);
            return false;
        } else
            mExtensionManagerService.openExtension(id);
    } else {
        if (mExtensionServiceConnection != null)
            mExtensionManagerService.disconnect();
        if (current == null) {
            mDrawerLayout.closeDrawer(mNavigationView);
            return false;
        }
        if (mCurrentFragmentId == id) {
            // Go back at root level of current browser
            if (current instanceof BaseBrowserFragment && !((BaseBrowserFragment) current).isRootDirectory()) {
                getSupportFragmentManager().popBackStackImmediate(getTag(id), FragmentManager.POP_BACK_STACK_INCLUSIVE);
            } else {
                mDrawerLayout.closeDrawer(mNavigationView);
                return false;
            }
        } else
            switch(id) {
                case R.id.nav_about:
                    showSecondaryFragment(SecondaryActivity.ABOUT);
                    break;
                case R.id.nav_settings:
                    startActivityForResult(new Intent(this, PreferencesActivity.class), ACTIVITY_RESULT_PREFERENCES);
                    break;
                case R.id.nav_mrl:
                    new MRLPanelFragment().show(getSupportFragmentManager(), "fragment_mrl");
                    break;
                case R.id.nav_directories:
                    if (TextUtils.equals(BuildConfig.FLAVOR_target, "chrome")) {
                        final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                        intent.setType("audio/* video/*");
                        startActivityForResult(intent, ACTIVITY_RESULT_OPEN);
                        mDrawerLayout.closeDrawer(mNavigationView);
                        return true;
                    }
                default:
                    /* Slide down the audio player */
                    slideDownAudioPlayer();
                    /* Switch the fragment */
                    showFragment(id);
            }
    }
    mDrawerLayout.closeDrawer(mNavigationView);
    return true;
}
Also used : BaseBrowserFragment(org.videolan.vlc.gui.browser.BaseBrowserFragment) MRLPanelFragment(org.videolan.vlc.gui.network.MRLPanelFragment) Intent(android.content.Intent) 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)

Aggregations

Intent (android.content.Intent)1 Fragment (android.support.v4.app.Fragment)1 AudioBrowserFragment (org.videolan.vlc.gui.audio.AudioBrowserFragment)1 BaseBrowserFragment (org.videolan.vlc.gui.browser.BaseBrowserFragment)1 FileBrowserFragment (org.videolan.vlc.gui.browser.FileBrowserFragment)1 MediaBrowserFragment (org.videolan.vlc.gui.browser.MediaBrowserFragment)1 NetworkBrowserFragment (org.videolan.vlc.gui.browser.NetworkBrowserFragment)1 MRLPanelFragment (org.videolan.vlc.gui.network.MRLPanelFragment)1 PreferencesFragment (org.videolan.vlc.gui.preferences.PreferencesFragment)1 VideoGridFragment (org.videolan.vlc.gui.video.VideoGridFragment)1