use of android.support.v7.app.ActionBarDrawerToggle in project crypto-android by lizitca.
the class MenuActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
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 navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
new MenuPresenter(this).start();
}
use of android.support.v7.app.ActionBarDrawerToggle in project ForPDA by RadiationX.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (EmptyActivity.empty(App.get().getPreferences().getString("auth.user.nick", ""))) {
startActivity(new Intent(this, EmptyActivity.class));
finish();
return;
}
Intent intent = getIntent();
if (intent != null) {
checkWebView = intent.getBooleanExtra(CHECK_WEBVIEW, checkWebView);
}
if (checkWebView) {
Observable.fromCallable(() -> App.get().isWebViewFound(this)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(aBoolean -> {
if (!aBoolean) {
startActivity(new Intent(App.getContext(), WebVewNotFoundActivity.class));
finish();
}
});
}
currentThemeIsDark = App.get().isDarkTheme();
setTheme(currentThemeIsDark ? R.style.DarkAppTheme_NoActionBar : R.style.LightAppTheme_NoActionBar);
setContentView(R.layout.activity_main);
DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawerLayout.addDrawerListener(toggle);
toggle.syncState();
/*
* Т.к. 2 вьюхи, делаю цвет в 2 раза прозрачнее, чтобы компенсировать это.
* P.S. Чем больше вьюх в DrawerLayout находятся до NavigationView, тем сильнее будет затенение
* P.S.S. Первая вьюха - контейнер фрагментов, вторая - view_for_measure
* */
drawerLayout.setScrimColor(0x4C000000);
drawers = new Drawers(this, drawerLayout);
drawers.init(savedInstanceState);
drawerHeader = new DrawerHeader(this, drawerLayout);
drawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
}
@Override
public void onDrawerOpened(View drawerView) {
if (drawerView.getId() == R.id.menu_drawer) {
if (App.get().getPreferences().getBoolean("drawers.tooltip.link_open", true)) {
SimpleTooltip tooltip = new SimpleTooltip.Builder(MainActivity.this).anchorView(drawerView.findViewById(R.id.drawer_header_open_link)).text(R.string.tooltip_link).gravity(Gravity.BOTTOM).animated(false).modal(true).transparentOverlay(false).backgroundColor(Color.BLACK).textColor(Color.WHITE).padding((float) App.px16).onDismissListener(simpleTooltip -> tooltips.remove(simpleTooltip)).build();
tooltip.show();
tooltips.add(tooltip);
App.get().getPreferences().edit().putBoolean("drawers.tooltip.link_open", false).apply();
}
}
}
@Override
public void onDrawerClosed(View drawerView) {
if (drawerView.getId() == R.id.menu_drawer) {
if (App.get().getPreferences().getBoolean("drawers.tooltip.tabs_drawer", true)) {
SimpleTooltip tooltip = new SimpleTooltip.Builder(MainActivity.this).anchorView(drawers.getTabDrawer()).text(R.string.tooltip_tabs).gravity(Gravity.START).animated(false).modal(true).transparentOverlay(false).backgroundColor(Color.BLACK).textColor(Color.WHITE).padding((float) App.px16).onDismissListener(simpleTooltip -> tooltips.remove(simpleTooltip)).build();
tooltip.show();
tooltips.add(tooltip);
App.get().getPreferences().edit().putBoolean("drawers.tooltip.tabs_drawer", false).apply();
}
}
}
@Override
public void onDrawerStateChanged(int newState) {
if (newState == DrawerLayout.STATE_DRAGGING) {
TabFragment fragment = TabManager.get().getActive();
if (fragment != null) {
fragment.hidePopupWindows();
}
}
}
});
receiver = new NetworkStateReceiver();
receiver.registerReceiver();
KeyboardUtil keyboardUtil = new KeyboardUtil(this, findViewById(R.id.fragments_container));
keyboardUtil.enable();
final View viewDiff = findViewById(R.id.view_for_measure);
viewDiff.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> measureView(v));
if (Preferences.Notifications.Update.isEnabled(getApplicationContext())) {
new SimpleUpdateChecker().checkFromGitHub(this);
}
checkIntent(getIntent());
}
use of android.support.v7.app.ActionBarDrawerToggle in project Androidified by D3v3sh5ingh.
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);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
});
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 Riksdagskollen by OAndell.
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 = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
navigationView.setItemIconTintList(null);
initPartyFragments();
initMenuOptions();
// Mark News-fragment as selected at startup
navigationView.getMenu().getItem(0).getSubMenu().getItem(0).setChecked(true);
}
use of android.support.v7.app.ActionBarDrawerToggle in project underlx by underlx.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Object conn = getLastCustomNonConfigurationInstance();
if (conn != null && ((LocServiceConnection) conn).getBinder() != null) {
// have the service connection survive through activity configuration changes
// (e.g. screen orientation changes)
mConnection = (LocServiceConnection) conn;
locService = mConnection.getBinder().getService();
locBound = true;
} else if (!locBound) {
startService(new Intent(this, MainService.class));
getApplicationContext().bindService(new Intent(getApplicationContext(), MainService.class), mConnection, Context.BIND_AUTO_CREATE);
}
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) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
if (savedInstanceState == null) {
// show initial fragment
Fragment newFragment = null;
if (getIntent() != null) {
String id = getIntent().getStringExtra(EXTRA_INITIAL_FRAGMENT);
if (id != null) {
newFragment = getNewFragment(pageStringToResourceId(id));
planRouteTo = getIntent().getStringExtra(EXTRA_PLAN_ROUTE_TO_STATION);
}
if (getIntent().getBooleanExtra(EXTRA_FROM_INTRO, false)) {
showTargetPrompt();
}
}
if (newFragment == null) {
newFragment = new HomeFragment();
}
replaceFragment(newFragment, false);
}
IntentFilter filter = new IntentFilter();
filter.addAction(MainService.ACTION_UPDATE_TOPOLOGY_PROGRESS);
filter.addAction(MainService.ACTION_UPDATE_TOPOLOGY_FINISHED);
filter.addAction(MainService.ACTION_TOPOLOGY_UPDATE_AVAILABLE);
filter.addAction(MainService.ACTION_CACHE_EXTRAS_PROGRESS);
filter.addAction(MainService.ACTION_CACHE_EXTRAS_FINISHED);
filter.addAction(FeedbackUtil.ACTION_FEEDBACK_PROVIDED);
bm = LocalBroadcastManager.getInstance(this);
bm.registerReceiver(mBroadcastReceiver, filter);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
SharedPreferences sharedPref = getSharedPreferences("settings", MODE_PRIVATE);
boolean isFirstStart = sharedPref.getBoolean("fuse_first_run", true);
if (isFirstStart) {
// intro will request permission for us
final Intent i = new Intent(MainActivity.this, IntroActivity.class);
runOnUiThread(new Runnable() {
@Override
public void run() {
startActivity(i);
finish();
}
});
} else {
boolean locationEnabled = sharedPref.getBoolean(PreferenceNames.LocationEnable, true);
if (locationEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION }, PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION);
}
}
});
}
}
}
});
// Start the thread
t.start();
}
Aggregations