use of android.support.v4.widget.DrawerLayout in project double-espresso by JakeWharton.
the class DrawerActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.drawer_activity);
ListAdapter listAdapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.drawer_row, R.id.drawer_row_name, DRAWER_CONTENTS);
final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
ListView drawerList = (ListView) findViewById(R.id.drawer_list);
drawerList.setAdapter(listAdapter);
final TextView textView = (TextView) findViewById(R.id.drawer_text_view);
drawerList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
textView.setText("You picked: " + DRAWER_CONTENTS[(int) id]);
drawerLayout.closeDrawers();
}
});
// TODO(user): use compat lib for lower API levels
if (android.os.Build.VERSION.SDK_INT >= 11) {
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
}
title = getTitle();
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.nav_drawer_open, R.string.nav_drawer_close) {
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
if (android.os.Build.VERSION.SDK_INT >= 11) {
getActionBar().setTitle(title);
}
}
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
if (android.os.Build.VERSION.SDK_INT >= 11) {
getActionBar().setTitle(title);
}
}
};
drawerLayout.setDrawerListener(drawerToggle);
}
use of android.support.v4.widget.DrawerLayout in project aplicativo by InCasa.
the class HomeActivity method onNavigationItemSelected.
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_sensor) {
Intent intent = new Intent(this, SensorActivity.class);
startActivity(intent);
} else if (id == R.id.nav_rele) {
Intent intent = new Intent(this, ReleActivity.class);
startActivity(intent);
} else if (id == R.id.nav_voz) {
Intent intent = new Intent(this, VozActivity.class);
startActivity(intent);
} else if (id == R.id.nav_config) {
Intent intent = new Intent(this, ConfigActivity.class);
startActivity(intent);
} else if (id == R.id.nav_alarme) {
Intent intent = new Intent(this, AlarmeActivity.class);
startActivity(intent);
} else if (id == R.id.nav_admin) {
Intent intent = new Intent(this, AdminActivity.class);
startActivity(intent);
} else if (id == R.id.nav_dicas) {
Intent intent = new Intent(this, DicasActivity.class);
startActivity(intent);
} else if (id == R.id.nav_logout) {
Intent intent = new Intent(this, LoginActivity.class);
startActivity(intent);
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
use of android.support.v4.widget.DrawerLayout in project Cangol-uiframe by Cangol.
the class Main2Activity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_view);
final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
final ImageView imageView = (ImageView) findViewById(R.id.drawer_indicator);
final Resources resources = getResources();
drawerArrowDrawable = new DrawerArrowDrawable(resources);
drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));
imageView.setImageDrawable(drawerArrowDrawable);
drawer.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
offset = slideOffset;
// 0.
if (slideOffset >= .995) {
flipped = true;
drawerArrowDrawable.setFlip(flipped);
} else if (slideOffset <= .005) {
flipped = false;
drawerArrowDrawable.setFlip(flipped);
}
drawerArrowDrawable.setParameter(offset);
}
});
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (drawer.isDrawerVisible(START)) {
drawer.closeDrawer(START);
} else {
drawer.openDrawer(START);
}
}
});
final TextView styleButton = (TextView) findViewById(R.id.indicator_style);
styleButton.setOnClickListener(new View.OnClickListener() {
boolean rounded = false;
@Override
public void onClick(View v) {
styleButton.setText(//
rounded ? //
resources.getString(R.string.rounded) : resources.getString(R.string.squared));
rounded = !rounded;
drawerArrowDrawable = new DrawerArrowDrawable(resources, rounded);
drawerArrowDrawable.setParameter(offset);
drawerArrowDrawable.setFlip(flipped);
drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));
imageView.setImageDrawable(drawerArrowDrawable);
}
});
}
use of android.support.v4.widget.DrawerLayout in project Reachability by sakebook.
the class NavigationDrawerFragment method setUp.
/**
* Users of this fragment must call this method to set up the navigation drawer interactions.
*
* @param fragmentId The android:id of this fragment in its activity's layout.
* @param drawerLayout The DrawerLayout containing this fragment's UI.
*/
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
mFragmentContainerView = getActivity().findViewById(fragmentId);
mDrawerLayout = drawerLayout;
// 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
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
// ActionBarDrawerToggle ties together the the proper interactions
// between the navigation drawer and the action bar app icon.
mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
R.string.navigation_drawer_close) {
/* "close drawer" description for accessibility */
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (!isAdded()) {
return;
}
// calls onPrepareOptionsMenu()
getActivity().invalidateOptionsMenu();
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (!isAdded()) {
return;
}
if (!mUserLearnedDrawer) {
// The user manually opened the drawer; store this flag to prevent auto-showing
// the navigation drawer automatically in the future.
mUserLearnedDrawer = true;
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
}
// calls onPrepareOptionsMenu()
getActivity().invalidateOptionsMenu();
}
};
// per the navigation drawer design guidelines.
if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
mDrawerLayout.openDrawer(mFragmentContainerView);
}
// Defer code dependent on restoration of previous instance state.
mDrawerLayout.post(new Runnable() {
@Override
public void run() {
mDrawerToggle.syncState();
}
});
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
use of android.support.v4.widget.DrawerLayout in project IITB-App by wncc.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
session = new SessionManager(getApplicationContext());
session.checkLogin();
Toast.makeText(getApplicationContext(), "Log In status: " + session.isLoggedIn(), Toast.LENGTH_LONG).show();
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);
drawer.addDrawerListener(toggle);
toggle.syncState();
FeedFragment feedFragment = new FeedFragment();
updateFragment(feedFragment);
fetchNotifications();
}
Aggregations