use of android.support.design.widget.NavigationView 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.design.widget.NavigationView in project flexbox-layout by google.
the class MainActivityTest method testFlexWrapSpinner.
@Test
@SuppressWarnings("unchecked")
@FlakyTest
public void testFlexWrapSpinner() {
MainActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
assertNotNull(flexboxLayout);
NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
assertNotNull(navigationView);
Menu menu = navigationView.getMenu();
final Spinner spinner = (Spinner) MenuItemCompat.getActionView(menu.findItem(R.id.menu_item_flex_wrap));
ArrayAdapter<CharSequence> spinnerAdapter = (ArrayAdapter<CharSequence>) spinner.getAdapter();
final int wrapReversePosition = spinnerAdapter.getPosition(activity.getString(R.string.wrap_reverse));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(wrapReversePosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP_REVERSE));
final int noWrapPosition = spinnerAdapter.getPosition(activity.getString(R.string.nowrap));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(noWrapPosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_NOWRAP));
}
use of android.support.design.widget.NavigationView in project flexbox-layout by google.
the class MainActivityTest method testJustifyContentSpinner.
@Test
@SuppressWarnings("unchecked")
@FlakyTest
public void testJustifyContentSpinner() {
MainActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
assertNotNull(flexboxLayout);
NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
assertNotNull(navigationView);
Menu menu = navigationView.getMenu();
final Spinner spinner = (Spinner) MenuItemCompat.getActionView(menu.findItem(R.id.menu_item_justify_content));
ArrayAdapter<CharSequence> spinnerAdapter = (ArrayAdapter<CharSequence>) spinner.getAdapter();
final int spaceBetweenPosition = spinnerAdapter.getPosition(activity.getString(R.string.space_between));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(spaceBetweenPosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_SPACE_BETWEEN));
final int centerPosition = spinnerAdapter.getPosition(activity.getString(R.string.center));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(centerPosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_CENTER));
}
use of android.support.design.widget.NavigationView in project flexbox-layout by google.
the class MainActivityTest method testAlignItemsSpinner.
@Test
@SuppressWarnings("unchecked")
@FlakyTest
public void testAlignItemsSpinner() {
MainActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
assertNotNull(flexboxLayout);
NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
assertNotNull(navigationView);
Menu menu = navigationView.getMenu();
final Spinner spinner = (Spinner) MenuItemCompat.getActionView(menu.findItem(R.id.menu_item_align_items));
ArrayAdapter<CharSequence> spinnerAdapter = (ArrayAdapter<CharSequence>) spinner.getAdapter();
final int baselinePosition = spinnerAdapter.getPosition(activity.getString(R.string.baseline));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(baselinePosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_BASELINE));
final int flexEndPosition = spinnerAdapter.getPosition(activity.getString(R.string.flex_end));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(flexEndPosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_FLEX_END));
}
use of android.support.design.widget.NavigationView 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);
}
Aggregations