android.support.design.widget.NavigationView Java Examples

The following examples show how to use android.support.design.widget.NavigationView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From kute with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.landing);

    // Set a Toolbar to replace the ActionBar.
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Find our drawer view
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    // Find our drawer view
    nvDrawer = (NavigationView) findViewById(R.id.nvView);
    // Setup drawer view
    setupDrawerContent(nvDrawer);



}
 
Example #2
Source File: MainActivity.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void initView(Bundle savedInstanceState) {
    mDrawerLayout.addDrawerListener(this);
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            mDrawerLayout.closeDrawers();
            return mMenuEditor.onOptionsItemSelected(item);
        }
    });
    View tab = findViewById(R.id.img_tab);
    if (tab != null) {
        tab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                insertTab(v);
            }
        });
    }
    mCompileProgress = findViewById(R.id.compile_progress);
}
 
Example #3
Source File: GeometryDescartesActivity.java    From ncalc with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_geometry_descartes);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    mPager = (ViewPager) findViewById(R.id.viewpager);
    mPager.setOffscreenPageLimit(mCount);
    PagerApdater mAdapter = new PagerApdater(getSupportFragmentManager(), this);
    mPager.setAdapter(mAdapter);
    mPager.addOnPageChangeListener(this);

    mTab = (TabLayout) findViewById(R.id.tab);
    mTab.setupWithViewPager(mPager, true);
}
 
Example #4
Source File: BreadcrumbActivity.java    From BreadcrumbToolbar with Apache License 2.0 6 votes vote down vote up
private void bindViews() {
    // Bind toolbar
    toolbar = (BreadcrumbToolbar) findViewById(R.id.toolbar);
    // We can't use setSupportActionBar()
    toolbar.setBreadcrumbToolbarListener(this);
    toolbar.setTitle(R.string.app_name);
    // Set animated drawer icon to toolbar
    DrawerArrowDrawable drawerArrow = new DrawerArrowDrawable(this);
    drawerArrow.setColor(ContextCompat.getColor(this, android.R.color.white));
    toolbar.setNavigationIcon(drawerArrow);
    getSupportFragmentManager().addOnBackStackChangedListener(this);

    // Bind drawer and toggle button
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    bindDrawerToggle();
    NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setCheckedItem(R.id.nav_home);

    // Bind FAB
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(this::openBreadCrumbFragment);
}
 
Example #5
Source File: BaseDrawerActivity.java    From OpenHub with GNU General Public License v3.0 6 votes vote down vote up
private void initStartDrawerView() {
    if (navViewStart == null) return;
    if (startDrawerEnable) {
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout,
                toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        toggle.syncState();
        navViewStart.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                return BaseDrawerActivity.this.onNavigationItemSelected(item, true);
            }
        });
    } else {
        drawerLayout.removeView(navViewStart);
    }
}
 
Example #6
Source File: gifa.java    From stynico with MIT License 6 votes vote down vote up
public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);	
        setContentView(R.layout.apktoolmain);

	StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
	NavigationView navigationView = (NavigationView) findViewById(R.id.nv_main_navigation);
        navigationView.setNavigationItemSelectedListener(this);

	toolbar = (android.support.v7.widget.Toolbar)
	    findViewById(R.id.toolbar);
//		初始化Toolbar控件
	setSupportActionBar(toolbar);
//		用Toolbar取代ActionBar
	//toolbar.setTitleTextColor(getResources().getColor(R.color.text_font_white));//标题颜色
	//toolbar.setSubtitleTextColor(getResources().getColor(R.color.text_font_white));//副标题颜色

    }
 
Example #7
Source File: DebugActivity.java    From android-robocar with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_debug);
  ButterKnife.bind(this);

  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);

  FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
  fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
          .setAction("Action", null).show();
    }
  });

  initNavigationDrawer();

  NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
  navigationView.setNavigationItemSelectedListener(this);

  // Local web server
  setupWebServer();
}
 
Example #8
Source File: MainActivity.java    From XKik with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main); // main activity
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // toolbar
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    getSupportFragmentManager().beginTransaction().replace(R.id.contentframe, new main_fragment()).commit();

    Settings.verifyStoragePermissions(this); // make sure we can access settings


    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
            .build();
    ImageLoader.getInstance().init(config);
}
 
Example #9
Source File: HomeActivity.java    From MousePaint with MIT License 6 votes vote down vote up
private void init() {
    view_hide.setOnClickListener(this);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationIcon(R.drawable.ic_menu);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    if (mNavigationView != null) {
        setupDrawerContent(mNavigationView);
        mNavigationView.setCheckedItem(R.id.nav_home);
    }

    mHomeFragment = HomeFragment.newInstance();
    switchFragment(TAG_HOME, mHomeFragment);

    setupRecyclerView();

    mIntent = new Intent();

    handFabPathAndSearch();
}
 
Example #10
Source File: HomescreenNew.java    From Hillffair17 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    initCollapsingToolbar();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    
    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, 0, 0);
    actionBarDrawerToggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    pref = new SharedPref(this);

    if(new Connection(this).isInternet()){
        profileBasicInfo(pref.getUserId());
    }

}
 
Example #11
Source File: BaseActivity.java    From privacy-friendly-food-tracker with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if(getSupportActionBar() == null) {
        setSupportActionBar(toolbar);
    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();

    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);

    selectNavigationItem(getNavigationDrawerID());

    View mainContent = findViewById(R.id.main_content);
    if (mainContent != null) {
        mainContent.setAlpha(0);
        mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
    }
}
 
Example #12
Source File: NavigationViewActivity.java    From Android_Blog_Demos with Apache License 2.0 6 votes vote down vote up
private void setupDrawerContent(NavigationView navigationView)
    {
        navigationView.setNavigationItemSelectedListener(

                new NavigationView.OnNavigationItemSelectedListener()
                {

                    private MenuItem mPreMenuItem;

                    @Override
                    public boolean onNavigationItemSelected(MenuItem menuItem)
                    {
//                        if (mPreMenuItem != null) mPreMenuItem.setChecked(false);
                        menuItem.setChecked(true);
//                        mDrawerLayout.closeDrawers();
//                        mPreMenuItem = menuItem;
                        return true;
                    }
                });
    }
 
Example #13
Source File: MainActivity.java    From RetroFacebook with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.inject(this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Here's a Snackbar", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}
 
Example #14
Source File: TasksActivity.java    From mobius-android-sample with Apache License 2.0 6 votes vote down vote up
private void setupDrawerContent(NavigationView navigationView) {
  navigationView.setNavigationItemSelectedListener(
      menuItem -> {
        switch (menuItem.getItemId()) {
          case R.id.list_navigation_menu_item:
            // Do nothing, we're already on that screen
            break;
          case R.id.statistics_navigation_menu_item:
            Intent intent = new Intent(TasksActivity.this, StatisticsActivity.class);
            startActivity(intent);
            break;
          default:
            break;
        }
        // Close the navigation drawer when an item is selected.
        menuItem.setChecked(true);
        mDrawerLayout.closeDrawers();
        return true;
      });
}
 
Example #15
Source File: StatisticsActivity.java    From android-espresso-revealed with Apache License 2.0 6 votes vote down vote up
private void setupDrawerContent(NavigationView navigationView) {
    navigationView.setNavigationItemSelectedListener(
            new NavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(MenuItem menuItem) {
                    switch (menuItem.getItemId()) {
                        case R.id.list_navigation_menu_item:
                            NavUtils.navigateUpFromSameTask(StatisticsActivity.this);
                            break;
                        case R.id.statistics_navigation_menu_item:
                            // Do nothing, we're already on that screen
                            break;
                        case R.id.settings_navigation_menu_item:
                            Intent aboutIntent =
                                    new Intent(StatisticsActivity.this, SettingsActivity.class);
                            startActivity(aboutIntent);
                        default:
                            break;
                    }
                    // Close the navigation drawer when an item is selected.
                    menuItem.setChecked(true);
                    mDrawerLayout.closeDrawers();
                    return true;
                }
            });
}
 
Example #16
Source File: MainActivity.java    From TimeTable with GNU General Public License v3.0 6 votes vote down vote up
private void initAll() {
    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    PreferenceManager.setDefaultValues(this, R.xml.settings, false);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = findViewById(R.id.drawer_layout);

    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    setupFragments();
    setupCustomDialog();
    setupSevenDaysPref();

    if(switchSevenDays) changeFragments(true);

    setDailyAlarm();
}
 
Example #17
Source File: MainActivity.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_navigation);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();
        Log.e("aa","bbb");


        ((BottomNavigationView)findViewById(R.id.navigation)).setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
//        mActivityDelegate = new ActivityGroupDelegate(this,savedInstanceState);
        switchToActivity("com.taobao.firstbundle.FirstBundleActivity");
    }
 
Example #18
Source File: NotesActivity.java    From androidtestdebug with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notes);


    // Set up the toolbar.
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    // Set up the navigation drawer.
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackground(R.color.colorPrimaryDark);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }

    if (null == savedInstanceState) {
        initFragment(NotesFragment.newInstance());
    }
}
 
Example #19
Source File: MainActivity.java    From ClipPathLayout with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    mContainer = findViewById(R.id.fragment_container);
    RandomTransitionPathGenerator generator =
            new RandomTransitionPathGenerator(new CirclePathGenerator());
    generator.add(new OvalPathGenerator());
    generator.add(new RhombusPathGenerator());
    mTransitionAdapter = new TransitionAdapter(generator);
    mTransitionAdapter.setImmediately(true);
    mContainer.setAdapter(mTransitionAdapter);
    switchFragment(new ScrollTransitionFragment(), false);
}
 
Example #20
Source File: MainActivity.java    From android-atleap with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);


    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.activity_main_drawer_open, R.string.activity_main_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);
}
 
Example #21
Source File: BaseActivity.java    From YalpStore with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    NavigationView navigationView = findViewById(R.id.nav_view);
    if (null == navigationView) {
        return;
    }
    TextView userNameView = navigationView.getHeaderView(0).findViewById(R.id.username);
    TextView deviceView = navigationView.getHeaderView(0).findViewById(R.id.device);
    if (null == userNameView || null == deviceView) {
        return;
    }
    String currentUserName = null == YalpStoreApplication.user.getUserName()
        ? ""
        : YalpStoreApplication.user.getUserName()
    ;
    String currentDeviceName = null == YalpStoreApplication.user.getDeviceDefinitionDisplayName()
        ? ""
        : YalpStoreApplication.user.getDeviceDefinitionDisplayName()
    ;
    if (!currentUserName.equals(userNameView.getText().toString())
        || !currentDeviceName.equals(deviceView.getText().toString())
    ) {
        redrawAccounts();
    }
}
 
Example #22
Source File: MainActivity.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
 
Example #23
Source File: HomeActivity.java    From SensorsAndAi with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate ( savedInstanceState );
    setContentView ( R.layout.activity_home );
    Toolbar toolbar = (Toolbar) findViewById ( R.id.toolbar );
    setSupportActionBar ( toolbar );



    DrawerLayout drawer = (DrawerLayout) findViewById ( R.id.drawer_layout );
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle (
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close );
    drawer.addDrawerListener ( toggle );
    toggle.syncState ();

    NavigationView navigationView = (NavigationView) findViewById ( R.id.nav_view );
    navigationView.setNavigationItemSelectedListener ( this );
}
 
Example #24
Source File: StatisticsActivity.java    From android-espresso-revealed with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.statistics_act);

    // Set up the toolbar.
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    ab.setTitle(R.string.statistics_title);
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    // Set up the navigation drawer.
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackground(R.color.colorPrimaryDark);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }

    StatisticsFragment statisticsFragment = (StatisticsFragment) getSupportFragmentManager()
            .findFragmentById(R.id.contentFrame);
    if (statisticsFragment == null) {
        statisticsFragment = StatisticsFragment.newInstance();
        ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),
                statisticsFragment, R.id.contentFrame);
    }

    new StatisticsPresenter(
            Injection.provideTasksRepository(getApplicationContext()), statisticsFragment);
}
 
Example #25
Source File: TasksActivity.java    From android-espresso-revealed with Apache License 2.0 5 votes vote down vote up
private void setupDrawerContent(NavigationView navigationView) {
    navigationView.setNavigationItemSelectedListener(
            new NavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(MenuItem menuItem) {
                    switch (menuItem.getItemId()) {
                        case R.id.list_navigation_menu_item:
                            // Do nothing, we're already on that screen
                            break;
                        case R.id.statistics_navigation_menu_item:
                            Intent statisticsIntent =
                                    new Intent(TasksActivity.this, StatisticsActivity.class);
                            startActivity(statisticsIntent);
                            break;
                        case R.id.settings_navigation_menu_item:
                            Intent aboutIntent =
                                    new Intent(TasksActivity.this, SettingsActivity.class);
                            startActivity(aboutIntent);
                        default:
                            break;
                    }
                    // Close the navigation drawer when an item is selected.
                    menuItem.setChecked(true);
                    mDrawerLayout.closeDrawers();
                    return true;
                }
            });
}
 
Example #26
Source File: MainActivity.java    From CourierApplication with Mozilla Public License 2.0 5 votes vote down vote up
private void setupDrawerContent(NavigationView navigationView) {
    navigationView.setNavigationItemSelectedListener(
            new NavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                    selectDrawerItem(item);
                    return true;
                }
            }
    );
}
 
Example #27
Source File: NavigationViewActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
private void setupDrawerLayout() {
    mLeftNavigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override public boolean onNavigationItemSelected(MenuItem menuItem) {
            Snackbar.make(mContentView, menuItem.getTitle() + " pressed", Snackbar.LENGTH_LONG).show();
            menuItem.setChecked(true);
            mRootDL.closeDrawers();
            return true;
        }
    });
}
 
Example #28
Source File: BaseActivity.java    From mConference-Framework with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_base);

    drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer_layout);
    navigationView = (NavigationView) findViewById(R.id.nav_view);
    frameLayout = (FrameLayout) findViewById(R.id.nav_content_frame);
    navImage = (ImageView) navigationView.getHeaderView(0).findViewById(R.id.nav_header_image);
}
 
Example #29
Source File: TheHubActivity.java    From ToDay with MIT License 5 votes vote down vote up
private void generateDrawerGreeting(NavigationView view) {
    View header=view.getHeaderView(0);
    TextView greeting = (TextView) header.findViewById(R.id.ndrawer_date_greeting);
    String[] array = this.getResources().getStringArray(R.array.drawer_greeting);

    switch(Calendar.getInstance().get(Calendar.DAY_OF_WEEK)){
        case Calendar.MONDAY:
            greeting.setText(array[0]);
            break;

        case Calendar.TUESDAY:
            greeting.setText(array[1]);
            break;

        case Calendar.WEDNESDAY:
            greeting.setText(array[2]);
            break;
        case Calendar.THURSDAY:
            greeting.setText(array[3]);
            break;
        case Calendar.FRIDAY:
            greeting.setText(array[4]);
            break;
        case Calendar.SATURDAY:
            greeting.setText(array[5]);
            break;

        case Calendar.SUNDAY:
            greeting.setText(array[6]);
            break;

        default:
            greeting.setText(array[7]);
            break;

    }

}
 
Example #30
Source File: HomescreenNew.java    From Nimbus with GNU General Public License v3.0 5 votes vote down vote up
public void init() {
    toolbar = (Toolbar) findViewById(R.id.home_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("Nimbus 2k18");

    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    navigationView = (NavigationView) findViewById(R.id.nvView);

    navHeader = navigationView.getHeaderView(0);
    txtName = (TextView) navHeader.findViewById(R.id.name);
    txtSubName = (TextView) navHeader.findViewById(R.id.subname);
    imgNavHeaderBg = (ImageView) navHeader.findViewById(R.id.img_header_bg);
    imgProfile = (ImageView) navHeader.findViewById(R.id.img_profile);


    viewPager = (ViewPager) findViewById(R.id.main_view_pager);

    quiz_layout = (LinearLayout) findViewById(R.id.quiz_layout);
    gallery_layout = (LinearLayout) findViewById(R.id.gallery_layout);
    map_layout = (LinearLayout) findViewById(R.id.map_layout);
    newsfeed_layout = (LinearLayout) findViewById(R.id.newsfeed_layout);
    coreteam_layout = (LinearLayout) findViewById(R.id.coreteam_layout);
    aboutnimbus_layout = (LinearLayout) findViewById(R.id.aboutnimbus_layout);
    teams_layout = (LinearLayout) findViewById(R.id.teams_layout);
    feedback_layout = (LinearLayout) findViewById(R.id.feedback_layout);
    contributor_layout = (LinearLayout) findViewById(R.id.contributor_layout);
    sponsor_layout = (LinearLayout) findViewById(R.id.sponsor_layout);
    workshop_layout = (LinearLayout) findViewById(R.id.workshop_layout);
    bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation);

}