use of android.support.design.widget.NavigationView in project SuperToasts by JohnPersano.
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);
final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
final ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
// Stop animating the navigation icon
super.onDrawerSlide(drawerView, 0);
}
};
drawerLayout.addDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.syncState();
final NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
navigationView.setNavigationItemSelectedListener(this);
navigationView.setCheckedItem(R.id.navigation_drawer_supertoast);
// setCheckedItem() does not actually call the associated listener
if (savedInstanceState == null)
this.onNavigationItemSelected(navigationView.getMenu().getItem(0));
}
use of android.support.design.widget.NavigationView in project XposedInstaller by rovo89.
the class WelcomeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ThemeUtil.setTheme(this);
setContentView(R.layout.activity_welcome);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
assert mNavigationView != null;
mNavigationView.setNavigationItemSelectedListener(this);
ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
// this disables the arrow @ completed state
super.onDrawerSlide(drawerView, 0);
}
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
// this disables the animation
super.onDrawerSlide(drawerView, 0);
}
};
mDrawerLayout.addDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
mSelectedId = mNavigationView.getMenu().getItem(prefs.getInt("default_view", 0)).getItemId();
mSelectedId = savedInstanceState == null ? mSelectedId : savedInstanceState.getInt(SELECTED_ITEM_ID);
mPrevSelectedId = mSelectedId;
mNavigationView.getMenu().findItem(mSelectedId).setChecked(true);
if (savedInstanceState == null) {
mDrawerHandler.removeCallbacksAndMessages(null);
mDrawerHandler.postDelayed(new Runnable() {
@Override
public void run() {
navigate(mSelectedId);
}
}, 250);
boolean openDrawer = prefs.getBoolean("open_drawer", false);
if (openDrawer)
mDrawerLayout.openDrawer(GravityCompat.START);
else
mDrawerLayout.closeDrawers();
}
Bundle extras = getIntent().getExtras();
if (extras != null) {
int value = extras.getInt("fragment", prefs.getInt("default_view", 0));
switchFragment(value);
}
mRepoLoader = RepoLoader.getInstance();
ModuleUtil.getInstance().addListener(this);
mRepoLoader.addListener(this);
notifyDataSetChanged();
}
use of android.support.design.widget.NavigationView in project chefly_android by chef-ly.
the class RecipeListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recipe_list);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
//Initialize recipe lists
serverRecipes = new RecipeList();
favoriteRecipes = new RecipeList();
//Start AsyncTaskLoader to get FavoriteRecipes
Credentials cred = CredentialsManager.getCredentials(getApplicationContext());
String t = cred.getAccessToken();
Log.d(TAG, "Token -> " + t);
if (t != null) {
RequestMethod requestPackageFavs = new RequestMethod();
requestPackageFavs.setEndPoint(urlFavsString);
requestPackageFavs.setMethod("GET");
requestPackageFavs.setHeader("Authorization", "Bearer " + t);
Bundle bundlefavs = new Bundle();
bundlefavs.putParcelable("requestPackage", requestPackageFavs);
getSupportLoaderManager().initLoader(FAVORTIESID, bundlefavs, this).forceLoad();
} else {
Toast.makeText(this, "Could not retrieve favorites, token is null", Toast.LENGTH_SHORT).show();
}
// PageViewer
pager = (ViewPager) findViewById(R.id.viewpager);
Bundle serv = new Bundle();
serv.putString("title", "Recipes");
serv.putString("pageNum", "1");
serv.putString("search", "");
server = new ListViewFragment();
server.setArguments(serv);
Bundle f = new Bundle();
f.putString("title", "Favorites");
f.putString("pageNum", "2");
f.putString("search", "");
favs = new ListViewFragment();
favs.setArguments(f);
ListViewFragment[] frags = { server, favs };
pager.setAdapter(new RecipeListPagerAdapter(getSupportFragmentManager(), frags));
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
//Log.d(TAG, "Position -> " + position);
if (position == 1) {
favoritesHeader.setPaintFlags(favoritesHeader.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
recipesHeader.setPaintFlags(0);
// ingredientsHeader.setPaintFlags(0);
} else {
recipesHeader.setPaintFlags(recipesHeader.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
favoritesHeader.setPaintFlags(0);
// ingredientsHeader.setPaintFlags(0);
}
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
// Header links
// ingredientsHeader = (TextView) findViewById(R.id.ingredientsHeader);
favoritesHeader = (TextView) findViewById(R.id.favortiesHeader);
recipesHeader = (TextView) findViewById(R.id.recipesHeader);
View.OnClickListener headerListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (v.getId() == favoritesHeader.getId()) {
favoritesHeader.setPaintFlags(favoritesHeader.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
recipesHeader.setPaintFlags(0);
// ingredientsHeader.setPaintFlags(0);
pager.setCurrentItem(1);
} else {
recipesHeader.setPaintFlags(recipesHeader.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
favoritesHeader.setPaintFlags(0);
// ingredientsHeader.setPaintFlags(0);
pager.setCurrentItem(0);
}
}
};
// ingredientsHeader.setOnClickListener(headerListener);
favoritesHeader.setOnClickListener(headerListener);
recipesHeader.setOnClickListener(headerListener);
//Tool/Appbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Navigation Drawer
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.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
use of android.support.design.widget.NavigationView in project dobby-android by InceptAi.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
((DobbyApplication) getApplication()).getProdComponent().inject(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
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);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
drawer.addDrawerListener(toggle);
} else {
drawer.setDrawerListener(toggle);
}
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
dobbyAi.setResponseCallback(this);
handler = new Handler(this);
setupChatFragment();
//requestPermissions();
}
use of android.support.design.widget.NavigationView in project Varis-Android by dkhmelenko.
the class MainActivity method setupDrawerLayout.
/**
* Sets up navigation drawer layout
*/
private void setupDrawerLayout() {
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout.addDrawerListener(mDrawerToggle);
final NavigationView view = (NavigationView) findViewById(R.id.navigation_view);
view.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch(menuItem.getItemId()) {
case R.id.drawer_login:
Intent loginIntent = new Intent(MainActivity.this, AuthActivity.class);
startActivityForResult(loginIntent, AUTH_ACTIVITY_CODE);
break;
case R.id.drawer_logout:
getPresenter().userLogout();
finish();
startActivity(getIntent());
break;
case R.id.drawer_licenses:
LicensesDialogFragment dialog = LicensesDialogFragment.newInstance();
dialog.show(getSupportFragmentManager(), "LicensesDialog");
break;
case R.id.drawer_about:
Intent aboutIntent = new Intent(MainActivity.this, AboutActivity.class);
startActivity(aboutIntent);
break;
}
menuItem.setChecked(false);
mDrawerLayout.closeDrawers();
return true;
}
});
}
Aggregations