use of android.support.design.widget.NavigationView in project cheesesquare by chrisbanes.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
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);
}
use of android.support.design.widget.NavigationView in project SeriesGuide by UweTrottmann.
the class BaseNavDrawerActivity method setupNavDrawer.
/**
* Initializes the navigation drawer. Overriding activities should call this in their {@link
* #onCreate(android.os.Bundle)} after {@link #setContentView(int)}.
*/
public void setupNavDrawer() {
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
actionBarToolbar = (Toolbar) drawerLayout.findViewById(R.id.sgToolbar);
navigationView = (NavigationView) drawerLayout.findViewById(R.id.navigation);
// setup nav drawer account header
View headerView = navigationView.getHeaderView(0);
ButterKnife.findById(headerView, R.id.containerDrawerAccountCloud).setOnClickListener(accountClickListener);
ButterKnife.findById(headerView, R.id.containerDrawerAccountTrakt).setOnClickListener(accountClickListener);
textViewHeaderUserCloud = ButterKnife.findById(headerView, R.id.textViewDrawerUserCloud);
textViewHeaderUserTrakt = ButterKnife.findById(headerView, R.id.textViewDrawerUserTrakt);
// setup nav drawer items
navigationView.inflateMenu(R.menu.menu_drawer);
navigationView.setItemIconTintList(ContextCompat.getColorStateList(this, Utils.resolveAttributeToResourceId(getTheme(), R.attr.sgColorNavDrawerIcon)));
navigationView.setItemTextColor(ContextCompat.getColorStateList(this, Utils.resolveAttributeToResourceId(getTheme(), R.attr.sgColorNavDrawerText)));
navigationView.setItemBackgroundResource(Utils.resolveAttributeToResourceId(getTheme(), R.attr.sgActivatedItemBackgroundDrawer));
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
onNavItemClick(menuItem.getItemId());
return false;
}
});
if (BuildConfig.DEBUG) {
// add debug drawer
View debugLayout = getLayoutInflater().inflate(R.layout.debug_drawer, drawerLayout, true);
DebugView debugView = ButterKnife.findById(debugLayout, R.id.debugView);
ButtonAction buttonClearTraktRefreshToken = new ButtonAction("Clear trakt refresh token", new ButtonAction.Listener() {
@Override
public void onClick() {
TraktOAuthSettings.storeRefreshData(getApplicationContext(), "", 3600);
}
});
ButtonAction buttonInvalidateTraktAccessToken = new ButtonAction("Invalidate trakt access token", new ButtonAction.Listener() {
@Override
public void onClick() {
TraktCredentials.get(getApplicationContext()).storeAccessToken("invalid-token");
}
});
ButtonAction buttonInvalidateTraktRefreshToken = new ButtonAction("Invalidate trakt refresh token", new ButtonAction.Listener() {
@Override
public void onClick() {
TraktOAuthSettings.storeRefreshData(getApplicationContext(), "invalid-token", 3600);
}
});
debugView.modules(new ActionsModule(buttonClearTraktRefreshToken, buttonInvalidateTraktAccessToken, buttonInvalidateTraktRefreshToken), new TimberModule(), new DeviceModule(this));
}
}
use of android.support.design.widget.NavigationView in project Fragmentation by YoKeyword.
the class MainActivity method initView.
private void initView() {
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
// mDrawer.setDrawerListener(toggle);
toggle.syncState();
mNavigationView = (NavigationView) findViewById(R.id.nav_view);
mNavigationView.setNavigationItemSelectedListener(this);
mNavigationView.setCheckedItem(R.id.nav_home);
LinearLayout llNavHeader = (LinearLayout) mNavigationView.getHeaderView(0);
mTvName = (TextView) llNavHeader.findViewById(R.id.tv_name);
mImgNav = (ImageView) llNavHeader.findViewById(R.id.img_nav);
llNavHeader.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDrawer.closeDrawer(GravityCompat.START);
mDrawer.postDelayed(new Runnable() {
@Override
public void run() {
goLogin();
}
}, 250);
}
});
}
use of android.support.design.widget.NavigationView in project MaterialIntroView by iammert.
the class ToolbarMenuItemActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_toolbar);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//User toolbar to access the views
ImageView ivSearch = (ImageView) toolbar.findViewById(R.id.ivToolbarSearch);
mIvShare = (ImageView) toolbar.findViewById(R.id.ivToolbarShare);
mIvAbout = (ImageView) toolbar.findViewById(R.id.ivToolbarAbout);
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);
//show the intro view
showIntro(ivSearch, MENU_SEARCH_ID_TAG, getString(R.string.guide_setup_profile), FocusGravity.CENTER);
}
use of android.support.design.widget.NavigationView in project Timber by naman14.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
sMainActivity = this;
action = getIntent().getAction();
isDarkTheme = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", false);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
navigationMap.put(Constants.NAVIGATE_LIBRARY, navigateLibrary);
navigationMap.put(Constants.NAVIGATE_PLAYLIST, navigatePlaylist);
navigationMap.put(Constants.NAVIGATE_QUEUE, navigateQueue);
navigationMap.put(Constants.NAVIGATE_NOWPLAYING, navigateNowplaying);
navigationMap.put(Constants.NAVIGATE_ALBUM, navigateAlbum);
navigationMap.put(Constants.NAVIGATE_ARTIST, navigateArtist);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
panelLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
navigationView = (NavigationView) findViewById(R.id.nav_view);
View header = navigationView.inflateHeaderView(R.layout.nav_header);
albumart = (ImageView) header.findViewById(R.id.album_art);
songtitle = (TextView) header.findViewById(R.id.song_title);
songartist = (TextView) header.findViewById(R.id.song_artist);
setPanelSlideListeners(panelLayout);
navDrawerRunnable.postDelayed(new Runnable() {
@Override
public void run() {
setupDrawerContent(navigationView);
setupNavigationIcons(navigationView);
}
}, 700);
if (TimberUtils.isMarshmallow()) {
checkPermissionAndThenLoad();
} else {
loadEverything();
}
addBackstackListener();
if (Intent.ACTION_VIEW.equals(action)) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
MusicPlayer.clearQueue();
MusicPlayer.openFile(getIntent().getData().getPath());
MusicPlayer.playOrPause();
navigateNowplaying.run();
}
}, 350);
}
}
Aggregations