use of android.support.v4.app.ActionBarDrawerToggle in project cardslib by gabrielemariotti.
the class LPreviewUtilsBase method setupDrawerToggle.
//----------------------------------------------------------------------------
// Navigation Drawer
//----------------------------------------------------------------------------
public ActionBarDrawerToggle setupDrawerToggle(DrawerLayout drawerLayout, final DrawerLayout.DrawerListener drawerListener) {
mDrawerToggle = new ActionBarDrawerToggle(mActivity, /* host Activity */
drawerLayout, /* DrawerLayout object */
mActionBarToolbar, /* nav drawer icon to replace 'Up' caret */
R.string.app_name, /* "open drawer" description */
R.string.app_name);
drawerLayout.setDrawerListener(mDrawerToggle);
return mDrawerToggle;
}
use of android.support.v4.app.ActionBarDrawerToggle in project fresco by facebook.
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);
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);
if (savedInstanceState == null) {
int selectedItem = PreferenceManager.getDefaultSharedPreferences(this).getInt(KEY_SELECTED_NAVDRAWER_ITEM_ID, INITIAL_NAVDRAWER_ITEM_ID);
handleNavigationItemClick(selectedItem);
navigationView.setCheckedItem(selectedItem);
}
}
use of android.support.v4.app.ActionBarDrawerToggle in project android-seed by freezy.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar) findViewById(R.id.toolbar);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
if (toolbar != null) {
toolbar.setTitle(R.string.app_name);
setSupportActionBar(toolbar);
}
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
}
};
drawerLayout.setDrawerListener(drawerToggle);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
}
}
use of android.support.v4.app.ActionBarDrawerToggle in project flexbox-layout by google.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initializeStringResources();
mFlexboxLayout = (FlexboxLayout) findViewById(R.id.flexbox_layout);
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
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 (drawer != null) {
drawer.addDrawerListener(toggle);
}
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
if (navigationView != null) {
navigationView.setNavigationItemSelectedListener(this);
Menu navigationMenu = navigationView.getMenu();
initializeFlexDirectionSpinner(navigationMenu);
initializeFlexWrapSpinner(navigationMenu);
initializeJustifyContentSpinner(navigationMenu);
initializeAlignItemsSpinner(navigationMenu);
initializeAlignContentSpinner(navigationMenu);
}
if (savedInstanceState != null) {
ArrayList<FlexItem> flexItems = savedInstanceState.getParcelableArrayList(FLEX_ITEMS_KEY);
assert flexItems != null;
mFlexboxLayout.removeAllViews();
for (int i = 0; i < flexItems.size(); i++) {
FlexItem flexItem = flexItems.get(i);
FlexboxLayout.LayoutParams lp = flexItem.toLayoutParams(this);
TextView textView = createBaseFlexItemTextView(i);
ViewCompat.setPaddingRelative(textView, flexItem.paddingStart, flexItem.paddingTop, flexItem.paddingEnd, flexItem.paddingBottom);
textView.setLayoutParams(lp);
mFlexboxLayout.addView(textView);
}
}
for (int i = 0; i < mFlexboxLayout.getChildCount(); i++) {
mFlexboxLayout.getChildAt(i).setOnClickListener(new FlexItemClickListener(i));
}
FloatingActionButton addFab = (FloatingActionButton) findViewById(R.id.add_fab);
if (addFab != null) {
addFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int viewIndex = mFlexboxLayout.getChildCount();
// index starts from 0. New View's index is N if N views ([0, 1, 2, ... N-1])
// exist.
TextView textView = createBaseFlexItemTextView(viewIndex);
textView.setLayoutParams(createDefaultLayoutParams());
textView.setOnClickListener(new FlexItemClickListener(viewIndex));
mFlexboxLayout.addView(textView);
}
});
}
FloatingActionButton removeFab = (FloatingActionButton) findViewById(R.id.remove_fab);
if (removeFab != null) {
removeFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mFlexboxLayout.getChildCount() == 0) {
return;
}
mFlexboxLayout.removeViewAt(mFlexboxLayout.getChildCount() - 1);
}
});
}
}
use of android.support.v4.app.ActionBarDrawerToggle in project OkVolley by googolmo.
the class DrawerFragment 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.drawer_open, /* "open drawer" description for accessibility */
R.string.drawer_close) {
/* "close drawer" description for accessibility */
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (!isAdded()) {
return;
}
// calls onPrepareOptionsMenu()
getActivity().supportInvalidateOptionsMenu();
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (!isAdded()) {
return;
}
// calls onPrepareOptionsMenu()
getActivity().supportInvalidateOptionsMenu();
}
};
// Defer code dependent on restoration of previous instance state.
mDrawerLayout.post(new Runnable() {
@Override
public void run() {
mDrawerToggle.syncState();
}
});
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
Aggregations