Search in sources :

Example 1 with LicensesDialogFragment

use of com.khmelenko.lab.varis.fragment.LicensesDialogFragment in project Varis-Android by dkhmelenko.

the class MainActivity method setupDrawerLayout.

/**
     * Sets up navigation drawer layout
     */
private void setupDrawerLayout() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    final NavigationView view = (NavigationView) findViewById(R.id.navigation_view);
    view.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
            switch(menuItem.getItemId()) {
                case R.id.drawer_login:
                    Intent loginIntent = new Intent(MainActivity.this, AuthActivity.class);
                    startActivityForResult(loginIntent, AUTH_ACTIVITY_CODE);
                    break;
                case R.id.drawer_logout:
                    getPresenter().userLogout();
                    finish();
                    startActivity(getIntent());
                    break;
                case R.id.drawer_licenses:
                    LicensesDialogFragment dialog = LicensesDialogFragment.newInstance();
                    dialog.show(getSupportFragmentManager(), "LicensesDialog");
                    break;
                case R.id.drawer_about:
                    Intent aboutIntent = new Intent(MainActivity.this, AboutActivity.class);
                    startActivity(aboutIntent);
                    break;
            }
            menuItem.setChecked(false);
            mDrawerLayout.closeDrawers();
            return true;
        }
    });
}
Also used : LicensesDialogFragment(com.khmelenko.lab.varis.fragment.LicensesDialogFragment) NavigationView(android.support.design.widget.NavigationView) MenuItem(android.view.MenuItem) Intent(android.content.Intent)

Aggregations

Intent (android.content.Intent)1 NavigationView (android.support.design.widget.NavigationView)1 MenuItem (android.view.MenuItem)1 LicensesDialogFragment (com.khmelenko.lab.varis.fragment.LicensesDialogFragment)1