use of android.support.v7.app.ActionBarDrawerToggle in project android-diplicity by zond.
the class GameActivity method draw.
public void draw() {
setTitle(gameTitle());
setContentView(R.layout.activity_game);
if (game == null) {
App.firebaseCrashReport("Drawing null game");
Toast.makeText(this, R.string.unknown_error, Toast.LENGTH_SHORT).show();
return;
}
flickFrameLayout = (FlickFrameLayout) findViewById(R.id.game_content);
flickFrameLayout.gameActivity = this;
findViewById(R.id.flick_frame_background).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
flickFrameLayout.onTouchEvent(motionEvent);
return true;
}
});
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(new DrawerLayout.DrawerListener() {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
toggle.onDrawerSlide(drawerView, slideOffset);
}
@Override
public void onDrawerOpened(View drawerView) {
((TextView) findViewById(R.id.nav_title)).setText(gameTitle());
toggle.onDrawerOpened(drawerView);
}
@Override
public void onDrawerClosed(View drawerView) {
toggle.onDrawerClosed(drawerView);
}
@Override
public void onDrawerStateChanged(int newState) {
toggle.onDrawerStateChanged(newState);
}
});
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
navigationView = (NavigationView) findViewById(R.id.nav_view);
Menu nav_Menu = navigationView.getMenu();
if (!game.Started) {
nav_Menu.findItem(R.id.nav_orders).setVisible(false);
nav_Menu.findItem(R.id.nav_phases).setVisible(false);
nav_Menu.findItem(R.id.nav_press).setVisible(false);
nav_Menu.findItem(R.id.nav_phase_settings).setVisible(false);
nav_Menu.findItem(R.id.nav_game_settings).setVisible(false);
}
if (phaseMeta == null || !phaseMeta.Resolved) {
nav_Menu.findItem(R.id.nav_phase_result).setVisible(false);
}
if (!game.Finished) {
nav_Menu.findItem(R.id.nav_game_result).setVisible(false);
}
if (currentView == 0) {
currentView = R.id.nav_map;
}
navigateTo(currentView);
}
use of android.support.v7.app.ActionBarDrawerToggle in project Gladys-Android-App by LeptitGeek.
the class MainActivity method initialdeclarations.
public void initialdeclarations() {
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = 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 = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
View header = navigationView.getHeaderView(0);
user = header.findViewById(R.id.user);
FloatingActionButton fab_scroll_up = findViewById(R.id.fab_scroll_up);
fab_scroll_up.animate().translationY(fab_scroll_up.getHeight() + 400).setInterpolator(new LinearInterpolator()).start();
}
use of android.support.v7.app.ActionBarDrawerToggle in project SpaghettiCodeHQ by CMPUT301W18T16.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.drawer_layout);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
oldTaskList = (ListView) findViewById(R.id.myTaskView);
Button addButton = (Button) findViewById(R.id.add1);
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(), AddTaskActivity.class);
startActivity(intent);
}
});
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.v7.app.ActionBarDrawerToggle in project SpaghettiCodeHQ by CMPUT301W18T16.
the class TaskActivity2 method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// assumption, this is the background view
setContentView(R.layout.task2);
EditText bodyText = (EditText) findViewById(R.id.body);
Button clearButton = (Button) findViewById(R.id.clear);
Button addButton = (Button) findViewById(R.id.add);
final ListView taskListView = (ListView) findViewById(R.id.TaskList);
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();
NavigationView navView = (NavigationView) findViewById(R.id.nav_view);
navView.setNavigationItemSelectedListener(this);
// listen to item clicks
adapter = new ArrayAdapter<Task>(TaskActivity2.this, android.R.layout.activity_list_item, taskList);
taskListView.setAdapter(adapter);
taskListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Task task = (Task) taskListView.getAdapter().getItem(position);
Intent intent = new Intent(TaskActivity2.this, SingleTaskActivity.class);
startActivityForResult(intent, 0);
}
});
taskListView.setAdapter(adapter);
}
use of android.support.v7.app.ActionBarDrawerToggle in project Weather-Station by Kresshy.
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, // 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().supportInvalidateOptionsMenu();
}
@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().supportInvalidateOptionsMenu();
}
};
// 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);
}
Aggregations