use of android.support.v7.app.ActionBarDrawerToggle in project SightRemote by TebbeUbben.
the class SightActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getRootLayout());
setupToolbar();
drawerLayout = findViewById(R.id.drawer_layout);
navigationView = findViewById(R.id.navigation_view);
contentFrame = findViewById(R.id.content_frame);
if (useNavigationDrawer() && drawerLayout != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.open_navigation, R.string.close_navigation);
drawerLayout.addDrawerListener(actionBarDrawerToggle);
navigationView.setNavigationItemSelectedListener(this);
if (getSelectedNavItemID() != 0)
navigationView.getMenu().findItem(getSelectedNavItemID()).setChecked(true);
} else if (drawerLayout != null)
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
hideOverlay();
sightServiceConnector = new SightServiceConnector(this);
sightServiceConnector.setConnectionCallback(connectionCallback);
sightServiceConnector.addStatusCallback(statusCallback);
}
use of android.support.v7.app.ActionBarDrawerToggle in project Auto.js by hyb1996.
the class MainActivity method setUpToolbar.
private void setUpToolbar() {
Toolbar toolbar = $(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle(R.string._app_name);
ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.text_drawer_open, R.string.text_drawer_close);
drawerToggle.syncState();
mDrawerLayout.addDrawerListener(drawerToggle);
}
use of android.support.v7.app.ActionBarDrawerToggle in project cuddly-octo-fortnight by prpr894.
the class MainActivity method initView.
private void initView() {
mToolbar = findViewById(R.id.toolbar_main);
mToolbar.setTitle("直播");
mCustomDrawerLayout = findViewById(R.id.drawer);
// 注意此段顺序
setSupportActionBar(mToolbar);
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
// 不能挪走,应在上面两行的下面
ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, mCustomDrawerLayout, mToolbar, 0, 0);
mCustomDrawerLayout.addDrawerListener(drawerToggle);
drawerToggle.syncState();
mNavigationView = findViewById(R.id.navigation);
mNavigationView.setNavigationItemSelectedListener(this);
// 开启彩色图标
mNavigationView.setItemIconTintList(null);
// 初始化一些东西
mNavigationView.setCheckedItem(R.id.s_live);
switchPage(0);
mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_settings:
AlertDialog.Builder builder;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
builder = new AlertDialog.Builder(MainActivity.this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(MainActivity.this);
}
builder.setCancelable(false);
builder.setTitle("警告");
builder.setMessage("清空数据不可恢复,确定清空收藏吗?");
builder.setPositiveButton("清空", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
LiveRoomItemDataBeanDao beanDao = MyApp.getInstance().getDaoSession().getLiveRoomItemDataBeanDao();
beanDao.deleteAll();
MyToast.successBig("清除成功");
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
break;
}
return true;
}
});
}
use of android.support.v7.app.ActionBarDrawerToggle in project malp by gateship-one.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// restore drag state
if (savedInstanceState != null) {
mSavedNowPlayingDragStatus = DRAG_STATUS.values()[savedInstanceState.getInt(MAINACTIVITY_SAVED_INSTANCE_NOW_PLAYING_DRAG_STATUS)];
mSavedNowPlayingViewSwitcherStatus = VIEW_SWITCHER_STATUS.values()[savedInstanceState.getInt(MAINACTIVITY_SAVED_INSTANCE_NOW_PLAYING_VIEW_SWITCHER_CURRENT_VIEW)];
}
setContentView(R.layout.activity_main);
// restore elevation behaviour as pre 24 support lib
AppBarLayout layout = findViewById(R.id.appbar);
layout.setStateListAnimator(null);
ViewCompat.setElevation(layout, 0);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// enable back navigation
final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
DrawerLayout drawer = findViewById(R.id.drawer_layout);
if (drawer != null) {
mDrawerToggle = new ActionBarDrawerToggle(this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
}
int navId = getDefaultViewID();
NavigationView navigationView = findViewById(R.id.nav_view);
if (navigationView != null) {
navigationView.setNavigationItemSelectedListener(this);
navigationView.setCheckedItem(navId);
}
mFAB = findViewById(R.id.andrompd_play_button);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
mUseArtistSort = sharedPref.getBoolean(getString(R.string.pref_use_artist_sort_key), getResources().getBoolean(R.bool.pref_use_artist_sort_default));
registerForContextMenu(findViewById(R.id.main_listview));
if (MPDProfileManager.getInstance(this).getProfiles().size() == 0) {
navId = R.id.nav_profiles;
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getResources().getString(R.string.welcome_dialog_title));
builder.setMessage(getResources().getString(R.string.welcome_dialog_text));
builder.setPositiveButton(R.string.dialog_action_ok, (dialog, id) -> {
});
AlertDialog dialog = builder.create();
dialog.show();
}
if (findViewById(R.id.fragment_container) != null) {
if (savedInstanceState != null) {
return;
}
Fragment fragment = null;
if (navId == R.id.nav_library) {
fragment = new MyMusicTabsFragment();
MyMusicTabsFragment.DEFAULTTAB defaultTab = getDefaultTab();
Bundle args = new Bundle();
args.putInt(MyMusicTabsFragment.MY_MUSIC_REQUESTED_TAB, defaultTab.ordinal());
fragment.setArguments(args);
} else if (navId == R.id.nav_saved_playlists) {
fragment = new SavedPlaylistsFragment();
} else if (navId == R.id.nav_files) {
fragment = new FilesFragment();
} else if (navId == R.id.nav_profiles) {
fragment = new ProfilesFragment();
}
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, fragment);
transaction.commit();
}
}
use of android.support.v7.app.ActionBarDrawerToggle in project androidApp by InspectorIncognito.
the class NavigationDrawerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
currentDrawerPosition = getStartPosition();
setContentView(R.layout.navigation_drawer);
ViewStub stub = findViewById(R.id.layout_stub);
stub.setLayoutResource(getLayoutResourceId());
stub.inflate();
drawerLayout = findViewById(R.id.drawer_layout);
drawerToggle = new ActionBarDrawerToggle(// host Activity
this, // DrawerLayout object
drawerLayout, // "open drawer" description
R.string.drawer_open, // "close drawer" description
R.string.drawer_close) {
public void onDrawerOpened(View drawerView) {
checkIfSessionChanged();
super.onDrawerOpened(drawerView);
}
};
navigationView = findViewById(R.id.nav_view);
if (!TranSappApplication.isDev()) {
MenuItem item = navigationView.getMenu().findItem(R.id.navigation_item_dev_settings);
item.setVisible(false);
}
assert navigationView != null;
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
menuItem.setChecked(true);
switch(menuItem.getItemId()) {
case R.id.navigation_item_account:
if (0 != currentDrawerPosition) {
openActivity(AccountActivity.class);
}
return true;
case R.id.navigation_item_map:
if (1 != currentDrawerPosition) {
openActivity(MainActivity.class);
}
return true;
case R.id.navigation_item_favourite:
openActivity(FavouriteActivity.class);
return true;
case R.id.navigation_item_router:
openActivity(RouterActivity.class);
return true;
case R.id.navigation_item_search:
openActivity(SearchActivity.class);
return true;
case R.id.navigation_item_dev_settings:
openActivity(SettingsActivity.class);
return true;
case R.id.navigation_item_onboarding:
openActivity(OnboardingActivity.class);
return true;
case R.id.navigation_item_rate:
goToUrl("https://play.google.com/store/apps/details?id=cl.smartcities.isci.transportinspector&hl=es");
return true;
default:
return true;
}
}
});
drawerLayout.addDrawerListener(drawerToggle);
assert getSupportActionBar() != null;
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
boolean isFirstTime = TranSappApplication.getAppSharedPreferences().getBoolean(getString(R.string.is_first_time), true);
boolean isFirstTimeLogging = TranSappApplication.getAppSharedPreferences().getBoolean(getString(R.string.first_time_logging_in), true);
if (isFirstTimeLogging) {
TranSappApplication.getAppSharedPreferences().edit().putBoolean(getString(R.string.first_time_logging_in), false).apply();
showLoginDialog();
}
if (isFirstTime) {
TranSappApplication.getAppSharedPreferences().edit().putBoolean(getString(R.string.is_first_time), false).apply();
if (!isFirstTimeLogging) {
drawerLayout.openDrawer(GravityCompat.START);
}
}
this.loggedIn = TranSappAccountManager.isLoggedIn();
hideFeaturesIfNotDEV();
handleLoginStatus();
}
Aggregations