Search in sources :

Example 1 with NavigationMenuView

use of android.support.design.internal.NavigationMenuView 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 NavigationMenuView

use of android.support.design.internal.NavigationMenuView in project Dxditor by kimi2009.

the class MainActivity method setNavigationMenuLineStyle.

/**
 * 给 NavigationView 的Menu的分割线 设置高度和颜色
 *
 * @param navigationView
 * @param color
 * @param height
 */
public static void setNavigationMenuLineStyle(NavigationView navigationView, @ColorInt final int color, final int height) {
    try {
        Field fieldByPressenter = navigationView.getClass().getDeclaredField("mPresenter");
        fieldByPressenter.setAccessible(true);
        NavigationMenuPresenter menuPresenter = (NavigationMenuPresenter) fieldByPressenter.get(navigationView);
        Field fieldByMenuView = menuPresenter.getClass().getDeclaredField("mMenuView");
        fieldByMenuView.setAccessible(true);
        final NavigationMenuView mMenuView = (NavigationMenuView) fieldByMenuView.get(menuPresenter);
        mMenuView.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() {

            @Override
            public void onChildViewAttachedToWindow(View view) {
                RecyclerView.ViewHolder viewHolder = mMenuView.getChildViewHolder(view);
                if (viewHolder != null && "SeparatorViewHolder".equals(viewHolder.getClass().getSimpleName()) && viewHolder.itemView != null) {
                    if (viewHolder.itemView instanceof FrameLayout) {
                        FrameLayout frameLayout = (FrameLayout) viewHolder.itemView;
                        View line = frameLayout.getChildAt(0);
                        line.setBackgroundColor(color);
                        line.getLayoutParams().height = height;
                        line.setLayoutParams(line.getLayoutParams());
                    }
                }
            }

            @Override
            public void onChildViewDetachedFromWindow(View view) {
            }
        });
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) FrameLayout(android.widget.FrameLayout) NavigationMenuPresenter(android.support.design.internal.NavigationMenuPresenter) RecyclerView(android.support.v7.widget.RecyclerView) NavigationView(android.support.design.widget.NavigationView) IMainpageView(itor.topnetwork.com.dxditor.view.IMainpageView) View(android.view.View) WebView(android.webkit.WebView) NavigationMenuView(android.support.design.internal.NavigationMenuView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) RadarView(itor.topnetwork.com.dxditor.myview.RadarView) RaderView(itor.topnetwork.com.dxditor.myview.RaderView) NavigationMenuView(android.support.design.internal.NavigationMenuView)

Aggregations

NavigationMenuView (android.support.design.internal.NavigationMenuView)2 NavigationView (android.support.design.widget.NavigationView)2 View (android.view.View)2 NavigationMenuPresenter (android.support.design.internal.NavigationMenuPresenter)1 Fragment (android.support.v4.app.Fragment)1 FragmentManager (android.support.v4.app.FragmentManager)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 RecyclerView (android.support.v7.widget.RecyclerView)1 WebView (android.webkit.WebView)1 FrameLayout (android.widget.FrameLayout)1 TextView (android.widget.TextView)1 RadarView (itor.topnetwork.com.dxditor.myview.RadarView)1 RaderView (itor.topnetwork.com.dxditor.myview.RaderView)1 IMainpageView (itor.topnetwork.com.dxditor.view.IMainpageView)1 Field (java.lang.reflect.Field)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