Search in sources :

Example 1 with BaseBrowserFragment

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

Example 2 with BaseBrowserFragment

use of org.videolan.vlc.gui.browser.BaseBrowserFragment 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 3 with BaseBrowserFragment

use of org.videolan.vlc.gui.browser.BaseBrowserFragment 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 4 with BaseBrowserFragment

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

the class MainActivity method onBackPressed.

@Override
public void onBackPressed() {
    /* Close the menu first */
    if (mDrawerLayout.isDrawerOpen(mNavigationView)) {
        closeDrawer();
        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) 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) BaseBrowserFragment(org.videolan.vlc.gui.browser.BaseBrowserFragment)

Aggregations

Fragment (android.support.v4.app.Fragment)4 AudioBrowserFragment (org.videolan.vlc.gui.audio.AudioBrowserFragment)4 BaseBrowserFragment (org.videolan.vlc.gui.browser.BaseBrowserFragment)4 PreferencesFragment (org.videolan.vlc.gui.preferences.PreferencesFragment)4 VideoGridFragment (org.videolan.vlc.gui.video.VideoGridFragment)4 ExtensionBrowser (org.videolan.vlc.gui.browser.ExtensionBrowser)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 Intent (android.content.Intent)1 FragmentManager (android.support.v4.app.FragmentManager)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1