use of android.support.v4.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.v4.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.v4.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.v4.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);
}
}
use of android.support.v4.app.ActionBarDrawerToggle in project AntennaPod by AntennaPod.
the class MediaplayerInfoActivity method setupGUI.
@Override
protected void setupGUI() {
super.setupGUI();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
findViewById(R.id.shadow).setVisibility(View.GONE);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appBar);
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
appBarLayout.setElevation(px);
}
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
navList = (ListView) findViewById(R.id.nav_list);
navDrawer = findViewById(R.id.nav_layout);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close);
drawerToggle.setDrawerIndicatorEnabled(false);
drawerLayout.setDrawerListener(drawerToggle);
navAdapter = new NavListAdapter(itemAccess, this);
navList.setAdapter(navAdapter);
navList.setOnItemClickListener((parent, view, position, id) -> {
int viewType = parent.getAdapter().getItemViewType(position);
if (viewType != NavListAdapter.VIEW_TYPE_SECTION_DIVIDER) {
Intent intent = new Intent(MediaplayerInfoActivity.this, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_NAV_TYPE, viewType);
intent.putExtra(MainActivity.EXTRA_NAV_INDEX, position);
startActivity(intent);
}
drawerLayout.closeDrawer(navDrawer);
});
navList.setOnItemLongClickListener((parent, view, position, id) -> {
if (position < navAdapter.getTags().size()) {
showDrawerPreferencesDialog();
return true;
} else {
mPosition = position;
return false;
}
});
registerForContextMenu(navList);
drawerToggle.syncState();
findViewById(R.id.nav_settings).setOnClickListener(v -> {
drawerLayout.closeDrawer(navDrawer);
startActivity(new Intent(MediaplayerInfoActivity.this, PreferenceController.getPreferenceActivity()));
});
butPlaybackSpeed = (Button) findViewById(R.id.butPlaybackSpeed);
butCastDisconnect = (ImageButton) findViewById(R.id.butCastDisconnect);
pager = (ViewPager) findViewById(R.id.pager);
pagerAdapter = new MediaplayerInfoPagerAdapter(getSupportFragmentManager(), media);
pagerAdapter.setController(controller);
pager.setAdapter(pagerAdapter);
CirclePageIndicator pageIndicator = (CirclePageIndicator) findViewById(R.id.page_indicator);
pageIndicator.setViewPager(pager);
loadLastFragment();
pager.onSaveInstanceState();
}
Aggregations