use of android.support.v7.app.ActionBarDrawerToggle in project NoteText by ViWu.
the class MainActivity method setUpDrawer.
public void setUpDrawer(Toolbar toolbar) {
//set up drawer
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer != null) {
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);
assert navigationView != null;
navigationView.setNavigationItemSelectedListener((NavigationView.OnNavigationItemSelectedListener) this);
}
use of android.support.v7.app.ActionBarDrawerToggle in project wh-app-android by WhiteHouse.
the class MainActivity method createDrawerToggle.
private void createDrawerToggle() {
mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, 0, 0) {
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
mDrawerVisible = true;
if (mDrawerLayoutCallbacks != null) {
mDrawerLayoutCallbacks.onDrawerOpened();
}
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
mDrawerVisible = false;
if (mDrawerLayoutCallbacks != null) {
mDrawerLayoutCallbacks.onDrawerClosed();
}
}
};
mActionBarDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);
}
use of android.support.v7.app.ActionBarDrawerToggle in project Rocket.Chat.Android by RocketChat.
the class MainActivity method setupSidebar.
private void setupSidebar() {
SlidingPaneLayout pane = (SlidingPaneLayout) findViewById(R.id.sliding_pane);
if (pane == null) {
return;
}
final SlidingPaneLayout subPane = (SlidingPaneLayout) findViewById(R.id.sub_sliding_pane);
pane.setPanelSlideListener(new SlidingPaneLayout.SimplePanelSlideListener() {
@Override
public void onPanelClosed(View panel) {
super.onPanelClosed(panel);
if (subPane != null) {
subPane.closePane();
}
}
});
final DrawerArrowDrawable drawerArrowDrawable = new DrawerArrowDrawable(this);
Toolbar toolbar = (Toolbar) findViewById(R.id.activity_main_toolbar);
toolbar.setNavigationIcon(drawerArrowDrawable);
toolbar.setNavigationOnClickListener(view -> {
if (pane.isSlideable() && !pane.isOpen()) {
pane.openPane();
}
});
//ref: ActionBarDrawerToggle#setProgress
pane.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
drawerArrowDrawable.setProgress(slideOffset);
}
@Override
public void onPanelOpened(View panel) {
drawerArrowDrawable.setVerticalMirror(true);
}
@Override
public void onPanelClosed(View panel) {
drawerArrowDrawable.setVerticalMirror(false);
}
});
}
use of android.support.v7.app.ActionBarDrawerToggle in project RSAndroidApp by RailwayStations.
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);
BaseApplication baseApplication = (BaseApplication) getApplication();
dbAdapter = baseApplication.getDbAdapter();
firstAppStart = baseApplication.getFirstAppStart();
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + getString(R.string.fab_email)));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.fab_subject));
startActivity(Intent.createChooser(emailIntent, getString(R.string.fab_chooser_title)));
}
});
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) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
handleGalleryNavItem();
View header = navigationView.getHeaderView(0);
TextView tvUpdate = (TextView) header.findViewById(R.id.tvUpdate);
if (firstAppStart == false) {
Intent introSliderIntent = new Intent(MainActivity.this, IntroSliderActivity.class);
startActivity(introSliderIntent);
finish();
}
try {
lastUpdateDate = loadUpdateDateFromFile("updatedate.txt");
} catch (Exception e) {
Log.e(TAG, "Cannot load last update", e);
}
if (!lastUpdateDate.equals("")) {
tvUpdate.setText("Letzte Aktualisierung am: " + lastUpdateDate);
} else {
disableNavItem();
tvUpdate.setText(R.string.no_stations_in_database);
}
cursor = dbAdapter.getStationsList(false);
customAdapter = new CustomAdapter(this, cursor, 0);
ListView listView = (ListView) findViewById(R.id.lstStations);
assert listView != null;
listView.setAdapter(customAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> listview, View view, int position, long id) {
Bahnhof bahnhof = dbAdapter.fetchBahnhofByRowId(id);
Class cls = DetailsActivity.class;
Intent intentDetails = new Intent(MainActivity.this, cls);
intentDetails.putExtra(DetailsActivity.EXTRA_BAHNHOF, bahnhof);
startActivity(intentDetails);
finish();
}
});
// Initialize FirebaseAuth
mFirebaseAuth = FirebaseAuth.getInstance();
Intent searchIntent = getIntent();
if (Intent.ACTION_SEARCH.equals(searchIntent.getAction())) {
String query = searchIntent.getStringExtra(SearchManager.QUERY);
Toast.makeText(MainActivity.this, query, Toast.LENGTH_SHORT).show();
}
bindToStatus();
}
use of android.support.v7.app.ActionBarDrawerToggle in project Aegis by Decad3nce.
the class AegisActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final SharedPreferences preferences = getSharedPreferences(PREFERENCES_AEGIS, MODE_PRIVATE);
mVersion = preferences.getString(PREFERENCES_AEGIS_VERSION, "35");
FragmentManager fragmentManager = getFragmentManager();
setContentView(R.layout.drawer_layout);
final ActionBar bar = getActionBar();
bar.setDisplayShowHomeEnabled(true);
bar.setHomeButtonEnabled(true);
bar.setDisplayHomeAsUpEnabled(true);
Fragment fragment = new SMSAlarmFragment();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
mTitle = mDrawerTitle = getTitle();
mMenuTitles = getMenuTitles();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
public void onDrawerClosed(View view) {
((BaseAdapter) mDrawerList.getAdapter()).notifyDataSetChanged();
invalidateOptionsMenu();
getActionBar().setTitle(mTitle);
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle("Menu");
((BaseAdapter) mDrawerList.getAdapter()).notifyDataSetChanged();
Utils.hideItem(R.id.alarm_menu_settings, thisMenu);
Utils.hideItem(R.id.lock_menu_settings, thisMenu);
Utils.hideItem(R.id.locate_menu_settings, thisMenu);
Utils.hideItem(R.id.wipe_menu_settings, thisMenu);
Utils.hideItem(R.id.data_menu_settings, thisMenu);
Utils.showItem(R.id.action_help, thisMenu);
}
};
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
mDrawerList.setAdapter(new DrawerLayoutAdapter(this, R.layout.drawer_list_item, new ArrayList(Arrays.asList(mMenuTitles))));
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
mDrawerLayout.setDrawerListener(mDrawerToggle);
int versionCode = 0;
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
versionCode = packageInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
//shwat
}
if (savedInstanceState == null) {
if (versionCode > Integer.parseInt(mVersion)) {
mVersion = String.valueOf(versionCode);
WebView webView = new WebView(this);
webView.loadUrl("file:///android_asset/changelog.html");
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setView(webView);
dialog.setPositiveButton("Dismiss", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
SharedPreferences.Editor editor = preferences.edit();
// value to store
editor.putString(PREFERENCES_AEGIS_VERSION, mVersion);
editor.commit();
dialog.dismiss();
}
});
dialog.show();
} else {
selectItem(0);
}
} else {
selectItem(mIndex);
}
}
Aggregations