use of android.support.v4.widget.DrawerLayout in project MaterialIntroView by iammert.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (savedInstanceState == null)
getSupportFragmentManager().beginTransaction().add(R.id.container, new MainFragment()).commit();
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);
}
use of android.support.v4.widget.DrawerLayout in project iosched by google.
the class AppNavigationViewAsDrawerImpl method setUpView.
@Override
public void setUpView() {
mHandler = new Handler();
mDrawerLayout = (DrawerLayout) mActivity.findViewById(R.id.drawer_layout);
if (mDrawerLayout == null) {
return;
}
// setup the status bar color to be colorPrimaryDark from the theme
mDrawerLayout.setStatusBarBackgroundColor(UIUtils.getThemeColor(mActivity, R.attr.colorPrimaryDark, R.color.theme_primary_dark));
mNavigationView = (NavigationView) mActivity.findViewById(R.id.nav_view);
if (mSelfItem == NavigationModel.NavigationItemEnum.INVALID) {
// do not show a nav drawer
mDrawerLayout = null;
return;
}
mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
@Override
public void onDrawerClosed(View drawerView) {
// run deferred action, if we have one
if (mDeferredOnDrawerClosedRunnable != null) {
mDeferredOnDrawerClosedRunnable.run();
mDeferredOnDrawerClosedRunnable = null;
}
mNavigationDrawerStateListener.onNavDrawerStateChanged(false, false);
}
@Override
public void onDrawerOpened(View drawerView) {
mNavigationDrawerStateListener.onNavDrawerStateChanged(true, false);
}
@Override
public void onDrawerStateChanged(int newState) {
mNavigationDrawerStateListener.onNavDrawerStateChanged(isNavDrawerOpen(), newState != DrawerLayout.STATE_IDLE);
}
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
mNavigationDrawerStateListener.onNavDrawerSlide(slideOffset);
}
});
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// navigation drawer open. But just the first time.
if (!SettingsUtils.isFirstRunProcessComplete(mActivity)) {
// first run of the app starts with the nav drawer open
SettingsUtils.markFirstRunProcessesDone(mActivity, true);
mDrawerLayout.openDrawer(GravityCompat.START);
}
setupAccountBox();
}
use of android.support.v4.widget.DrawerLayout in project material-design-data by Luosunce.
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.mipmap.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.viewpage);
if (viewPager != null) {
setupViewPager(viewPager);
}
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Snackbar.make(v, "Here's a Snackbar", Snackbar.LENGTH_LONG).setAction("Action", new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Toast comes out", Toast.LENGTH_SHORT).show();
}
}).show();
}
});
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}
use of android.support.v4.widget.DrawerLayout in project FadingActionBar-Native by ManuelPeinado.
the class NavigationDrawerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_navigation_drawer);
mTitle = mDrawerTitle = getTitle();
mCityNames = getResources().getStringArray(R.array.drawer_items);
TypedArray typedArray = getResources().obtainTypedArray(R.array.city_images);
mCityImages = new int[typedArray.length()];
for (int i = 0; i < typedArray.length(); ++i) {
mCityImages[i] = typedArray.getResourceId(i, 0);
}
typedArray.recycle();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// set up the drawer's list view with items and click listener
mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mCityNames));
mDrawerList.setOnItemClickListener(this);
// enable ActionBar app icon to behave as action to toggle nav drawer
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
// ActionBarDrawerToggle ties together the the proper interactions
// between the sliding drawer and the action bar app icon
mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
R.string.drawer_open, /* "open drawer" description for accessibility */
R.string.drawer_close) {
/* "close drawer" description for accessibility */
public void onDrawerClosed(View view) {
getActionBar().setTitle(mTitle);
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
if (savedInstanceState == null) {
selectItem(0);
}
}
use of android.support.v4.widget.DrawerLayout in project material by rey5137.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dl_navigator = (DrawerLayout) findViewById(R.id.main_dl);
fl_drawer = (FrameLayout) findViewById(R.id.main_fl_drawer);
lv_drawer = (ListView) findViewById(R.id.main_lv_drawer);
mToolbar = (Toolbar) findViewById(R.id.main_toolbar);
vp = (CustomViewPager) findViewById(R.id.main_vp);
tiv = (TabIndicatorView) findViewById(R.id.main_tiv);
mSnackBar = (SnackBar) findViewById(R.id.main_sn);
mToolbarManager = new ToolbarManager(getDelegate(), mToolbar, R.id.tb_group_main, R.style.ToolbarRippleStyle, R.anim.abc_fade_in, R.anim.abc_fade_out);
mToolbarManager.setNavigationManager(new ToolbarManager.ThemableNavigationManager(R.array.navigation_drawer, getSupportFragmentManager(), mToolbar, dl_navigator) {
@Override
public void onNavigationClick() {
// if (mToolbarManager.getCurrentGroup() != R.id.tb_group_main)
// mToolbarManager.setCurrentGroup(R.id.tb_group_main);
// else
// dl_navigator.openDrawer(GravityCompat.START);
mToolbarManager.setNavigationVisisble(false, true);
}
@Override
public boolean isBackState() {
return super.isBackState() || mToolbarManager.getCurrentGroup() != R.id.tb_group_main;
}
@Override
protected boolean shouldSyncDrawerSlidingProgress() {
return super.shouldSyncDrawerSlidingProgress() && mToolbarManager.getCurrentGroup() == R.id.tb_group_main;
}
});
mToolbarManager.registerOnToolbarGroupChangedListener(this);
mDrawerAdapter = new DrawerAdapter(this);
lv_drawer.setAdapter(mDrawerAdapter);
mPagerAdapter = new PagerAdapter(getSupportFragmentManager(), mItems);
vp.setAdapter(mPagerAdapter);
tiv.setTabIndicatorFactory(new TabIndicatorView.ViewPagerIndicatorFactory(vp));
vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
mDrawerAdapter.setSelected(mItems[position]);
mSnackBar.dismiss();
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mDrawerAdapter.setSelected(Tab.PROGRESS);
vp.setCurrentItem(0);
ViewUtil.setBackground(getWindow().getDecorView(), new ThemeDrawable(R.array.bg_window));
ViewUtil.setBackground(mToolbar, new ThemeDrawable(R.array.bg_toolbar));
}
Aggregations