use of de.geeksfactory.opacclient.ui.AccountSwitcherNavigationView in project opacclient by opacapp.
the class OpacActivity method setupDrawer.
protected void setupDrawer() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawerLayout != null) {
hasDrawer = true;
drawerLayout.setStatusBarBackground(R.color.primary_red_dark);
drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.LEFT);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {
/**
* Called when a drawer has settled in a completely closed
* state.
*/
@Override
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
getSupportActionBar().setTitle(title);
}
/**
* Called when a drawer has settled in a completely open state.
*/
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
getSupportActionBar().setTitle(app.getResources().getString(R.string.app_name));
if (getCurrentFocus() != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
}
};
// Set the drawer toggle as the DrawerListener
drawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
drawerToggle.onDrawerSlide(drawerView, slideOffset);
}
@Override
public void onDrawerOpened(final View drawerView) {
drawerToggle.onDrawerOpened(drawerView);
}
@Override
public void onDrawerClosed(View drawerView) {
drawerToggle.onDrawerClosed(drawerView);
setAccountSwitcherVisible(false);
}
@Override
public void onDrawerStateChanged(int newState) {
drawerToggle.onDrawerStateChanged(newState);
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
drawer = (AccountSwitcherNavigationView) findViewById(R.id.navdrawer);
drawer.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem item) {
selectItem(item);
return true;
}
});
if (!sp.getBoolean("version2.0.0-introduced", false) && app.getSlidingMenuEnabled()) {
final Handler handler = new Handler();
// Just show the menu to explain that is there if people start
// version 2 for the first time.
// We need a handler because if we just put this in onCreate
// nothing
// happens. I don't have any idea, why.
handler.postDelayed(new Runnable() {
@Override
public void run() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(OpacActivity.this);
drawerLayout.openDrawer(drawer);
sp.edit().putBoolean("version2.0.0-introduced", true).apply();
}
}, 500);
}
}
}
Aggregations