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 FlowingDrawer by mxn21.
the class MenuListFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_menu, container, false);
ivMenuUserProfilePhoto = (ImageView) view.findViewById(R.id.ivMenuUserProfilePhoto);
NavigationView vNavigation = (NavigationView) view.findViewById(R.id.vNavigation);
vNavigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
Toast.makeText(getActivity(), menuItem.getTitle(), Toast.LENGTH_SHORT).show();
return false;
}
});
setupHeader();
return view;
}
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);
}
}
use of android.support.design.widget.NavigationView in project NoteText by ViWu.
the class MainActivity method setUpDrawer.
public void setUpDrawer(Toolbar toolbar) {
//set up drawer
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer != null) {
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);
assert navigationView != null;
navigationView.setNavigationItemSelectedListener((NavigationView.OnNavigationItemSelectedListener) this);
}
Aggregations