use of android.support.v4.app.ActionBarDrawerToggle in project kdeconnect-android by KDE.
the class MaterialActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mNavigationView = (NavigationView) findViewById(R.id.navigation_drawer);
View mDrawerHeader = mNavigationView.getHeaderView(0);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.string.open, /* "open drawer" description */
R.string.close);
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
actionBar.setDisplayHomeAsUpEnabled(true);
mDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerToggle.syncState();
String deviceName = DeviceHelper.getDeviceName(this);
TextView nameView = (TextView) mDrawerHeader.findViewById(R.id.device_name);
nameView.setText(deviceName);
View.OnClickListener renameListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
renameDevice();
}
};
mDrawerHeader.findViewById(R.id.kdeconnect_label).setOnClickListener(renameListener);
mDrawerHeader.findViewById(R.id.device_name).setOnClickListener(renameListener);
mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
String deviceId = mMapMenuToDeviceId.get(menuItem);
onDeviceSelected(deviceId);
mDrawerLayout.closeDrawer(mNavigationView);
return true;
}
});
preferences = getSharedPreferences(STATE_SELECTED_DEVICE, Context.MODE_PRIVATE);
String savedDevice;
String pairStatus = "";
if (getIntent().hasExtra("forceOverview")) {
Log.i("MaterialActivity", "Requested to start main overview");
savedDevice = null;
} else if (getIntent().hasExtra("deviceId")) {
Log.i("MaterialActivity", "Loading selected device from parameter");
savedDevice = getIntent().getStringExtra("deviceId");
if (getIntent().hasExtra(PAIR_REQUEST_STATUS)) {
pairStatus = getIntent().getStringExtra(PAIR_REQUEST_STATUS);
}
} else if (savedInstanceState != null) {
Log.i("MaterialActivity", "Loading selected device from saved activity state");
savedDevice = savedInstanceState.getString(STATE_SELECTED_DEVICE);
} else {
Log.i("MaterialActivity", "Loading selected device from persistent storage");
savedDevice = preferences.getString(STATE_SELECTED_DEVICE, null);
}
//if pairStatus is not empty, then the decision has been made...
if (!pairStatus.equals("")) {
Log.i("MaterialActivity", "pair status is " + pairStatus);
onNewDeviceSelected(savedDevice, pairStatus);
}
onDeviceSelected(savedDevice);
}
use of android.support.v4.app.ActionBarDrawerToggle in project android_frameworks_base by AOSPA.
the class DrawerController method create.
/**
* Returns a controller suitable for {@code Layout}.
*/
static DrawerController create(Activity activity) {
DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);
if (layout == null) {
return new DummyDrawerController();
}
View drawer = activity.findViewById(R.id.drawer_roots);
Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar);
drawer.getLayoutParams().width = calculateDrawerWidth(activity);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(activity, layout, R.drawable.ic_hamburger, R.string.drawer_open, R.string.drawer_close);
return new RuntimeDrawerController(layout, drawer, toggle, toolbar);
}
use of android.support.v4.app.ActionBarDrawerToggle in project easy by MehdiBenmesa.
the class DrawerActivity method onStart.
@Override
protected void onStart() {
super.onStart();
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, 0, 0);
mDrawer.setDrawerListener(mDrawerToggle);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setHomeButtonEnabled(true);
}
}
use of android.support.v4.app.ActionBarDrawerToggle in project YourAppIdea by Michenux.
the class NavigationDrawerFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Activity activity = getActivity();
mDrawerLayoutView = (DrawerLayout) activity.findViewById(mNavConf.getDrawerLayoutViewId());
mDrawerToggle = new ActionBarDrawerToggle(this.getActivity(), mDrawerLayoutView, (Toolbar) activity.findViewById(mNavConf.getToolbarId()), mNavConf.getDrawerOpenDesc(), mNavConf.getDrawerCloseDesc()) {
public void onDrawerClosed(View view) {
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(mTitle);
if (NavigationDrawerFragment.this.mSelectItemOnClosed != null) {
NavigationDrawerFragment.this.deferedOnNavItemSelected();
}
}
public void onDrawerOpened(View drawerView) {
getActivity().setTitle(mDrawerTitle);
}
};
mDrawerLayoutView.setDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
setTitle(mTitle);
}
use of android.support.v4.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();
}
Aggregations