Search in sources :

Example 1 with MediaBrowserFragment

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

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!VLCInstance.testCompatibleCPU(this)) {
        finish();
        return;
    }
    Permissions.checkReadStoragePermission(this, false);
    /**
     * Start initializing the UI **
     */
    setContentView(R.layout.main);
    mDrawerLayout = (HackyDrawerLayout) findViewById(R.id.root_container);
    setupNavigationView();
    initAudioPlayerContainerActivity();
    if (savedInstanceState != null) {
        final FragmentManager fm = getSupportFragmentManager();
        mCurrentFragment = fm.getFragment(savedInstanceState, "current_fragment");
        // Restore fragments stack
        restoreFragmentsStack(savedInstanceState, fm);
        mCurrentFragmentId = savedInstanceState.getInt("current", mSettings.getInt("fragment_id", R.id.nav_video));
    } else {
        if (getIntent().getBooleanExtra(Constants.EXTRA_UPGRADE, false)) {
            /*
             * The sliding menu is automatically opened when the user closes
             * the info dialog. If (for any reason) the dialog is not shown,
             * open the menu after a short delay.
             */
            mActivityHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mDrawerLayout.openDrawer(mNavigationView);
                }
            }, 500);
        }
        reloadPreferences();
    }
    /* Set up the action bar */
    prepareActionBar();
    /* Set up the sidebar click listener
         * no need to invalidate menu for now */
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            final Fragment current = getCurrentFragment();
            if (current instanceof MediaBrowserFragment)
                ((MediaBrowserFragment) current).setReadyToDisplay(true);
        }

        // Hack to make navigation drawer browsable with DPAD.
        // see https://code.google.com/p/android/issues/detail?id=190975
        // and http://stackoverflow.com/a/34658002/3485324
        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (mNavigationView.requestFocus())
                ((NavigationMenuView) mNavigationView.getFocusedChild()).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        }
    };
    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    /* Reload the latest preferences */
    mScanNeeded = savedInstanceState == null && mSettings.getBoolean("auto_rescan", true);
    mExtensionsManager = ExtensionsManager.getInstance();
    mMediaLibrary = VLCApplication.getMLInstance();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) NavigationMenuView(android.support.design.internal.NavigationMenuView) 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) MediaBrowserFragment(org.videolan.vlc.gui.browser.MediaBrowserFragment) NavigationMenuView(android.support.design.internal.NavigationMenuView)

Example 2 with MediaBrowserFragment

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

the class ContentActivity method makeRoomForSearch.

// Hide options menu items to make room for filter EditText
protected void makeRoomForSearch(Fragment current, boolean hide) {
    final Menu menu = mToolbar.getMenu();
    menu.findItem(R.id.ml_menu_renderers).setVisible(!hide && showRenderers);
    if (current instanceof MediaBrowserFragment) {
        menu.findItem(R.id.ml_menu_sortby).setVisible(!hide && ((MediaBrowserFragment) current).getProvider().canSortByName());
    }
    if (current instanceof VideoGridFragment || current instanceof AudioBrowserFragment) {
        menu.findItem(R.id.ml_menu_last_playlist).setVisible(!hide);
    }
}
Also used : AudioBrowserFragment(org.videolan.vlc.gui.audio.AudioBrowserFragment) Menu(android.view.Menu) MediaBrowserFragment(org.videolan.vlc.gui.browser.MediaBrowserFragment) VideoGridFragment(org.videolan.vlc.gui.video.VideoGridFragment)

Example 3 with MediaBrowserFragment

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

the class MainActivity method restoreFragmentsStack.

private void restoreFragmentsStack(Bundle savedInstanceState, FragmentManager fm) {
    final List<Fragment> fragments = fm.getFragments();
    if (fragments != null) {
        final FragmentTransaction ft = fm.beginTransaction();
        final Fragment displayed = fm.getFragment(savedInstanceState, "current_fragment_visible");
        for (Fragment fragment : fragments) if (fragment != null) {
            if (fragment instanceof ExtensionBrowser) {
                ft.remove(fragment);
            } else if ((fragment instanceof MediaBrowserFragment)) {
                mFragmentsStack.put(fragment.getTag(), new WeakReference<>(fragment));
                if (!TextUtils.equals(fragment.getTag(), displayed.getTag()))
                    ft.hide(fragment);
            }
        }
        ft.commit();
    }
}
Also used : 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) MediaBrowserFragment(org.videolan.vlc.gui.browser.MediaBrowserFragment)

Aggregations

AudioBrowserFragment (org.videolan.vlc.gui.audio.AudioBrowserFragment)3 MediaBrowserFragment (org.videolan.vlc.gui.browser.MediaBrowserFragment)3 VideoGridFragment (org.videolan.vlc.gui.video.VideoGridFragment)3 Fragment (android.support.v4.app.Fragment)2 BaseBrowserFragment (org.videolan.vlc.gui.browser.BaseBrowserFragment)2 FileBrowserFragment (org.videolan.vlc.gui.browser.FileBrowserFragment)2 NetworkBrowserFragment (org.videolan.vlc.gui.browser.NetworkBrowserFragment)2 MRLPanelFragment (org.videolan.vlc.gui.network.MRLPanelFragment)2 PreferencesFragment (org.videolan.vlc.gui.preferences.PreferencesFragment)2 NavigationMenuView (android.support.design.internal.NavigationMenuView)1 NavigationView (android.support.design.widget.NavigationView)1 FragmentManager (android.support.v4.app.FragmentManager)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 Menu (android.view.Menu)1 View (android.view.View)1 ExtensionBrowser (org.videolan.vlc.gui.browser.ExtensionBrowser)1