use of android.support.v4.app.ActionBarDrawerToggle in project PhotoNoter by yydcdut.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setSupportActionBar(mToolbar);
mToolbar.setTitle("");
AppCompat.setElevation(mToolbar, getResources().getDimension(R.dimen.ui_elevation));
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
mDrawerLayout.setDrawerListener(toggle);
toggle.syncState();
mNavigationView.setNavigationItemSelectedListener(this);
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
PackageManager pm = getPackageManager();
List<ResolveInfo> info = pm.queryIntentActivities(intent, 0);
List<GalleryApp> galleryAppList = new ArrayList<>(info.size());
for (int i = 0; i < info.size(); i++) {
ActivityInfo activityInfo = info.get(i).activityInfo;
galleryAppList.add(new GalleryApp(activityInfo.loadIcon(getPackageManager()), activityInfo.packageName, activityInfo.loadLabel(getPackageManager()) + ""));
}
for (int i = 0; i < mNavigationView.getChildCount(); i++) {
View view = mNavigationView.getChildAt(i);
if (view instanceof RecyclerView) {
RecyclerView recyclerView = (RecyclerView) view;
mNavigationAdapter = new NavigationAdapter(recyclerView.getAdapter(), galleryAppList, this);
recyclerView.setAdapter(mNavigationAdapter);
}
}
FragmentManager fragmentManager = getSupportFragmentManager();
mMediaPhotoFragment = MediaPhotoFragment.newInstance();
fragmentManager.beginTransaction().replace(R.id.layout_photo, mMediaPhotoFragment).commit();
}
use of android.support.v4.app.ActionBarDrawerToggle in project LollipopDrawerToggle by 03lafaye.
the class ToolbarActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_toolbar);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open, R.string.close);
toggle.setDrawerIndicatorEnabled(true);
drawerLayout.setDrawerListener(toggle);
}
use of android.support.v4.app.ActionBarDrawerToggle in project android-bootstrap by AndroidBootstrap.
the class MainActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
BootstrapApplication.component().inject(this);
if (isTablet()) {
setContentView(R.layout.main_activity_tablet);
} else {
setContentView(R.layout.main_activity);
}
// View injection with Butterknife
ButterKnife.bind(this);
// Set up navigation drawer
title = drawerTitle = getTitle();
if (!isTablet()) {
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerToggle = new ActionBarDrawerToggle(this, /* Host activity */
drawerLayout, /* DrawerLayout object */
R.string.navigation_drawer_open, /* "open drawer" description */
R.string.navigation_drawer_close) {
/* "close drawer" description */
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
getSupportActionBar().setTitle(title);
// creates call to onPrepareOptionsMenu()
invalidateOptionsMenu();
syncState();
}
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
getSupportActionBar().setTitle(drawerTitle);
// creates call to onPrepareOptionsMenu()
invalidateOptionsMenu();
syncState();
}
};
if (!isTablet()) {
drawerToggle.syncState();
}
// Set the drawer toggle as the DrawerListener
drawerLayout.setDrawerListener(drawerToggle);
navigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
// Set up the drawer.
navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
checkAuth();
}
use of android.support.v4.app.ActionBarDrawerToggle in project android-bootstrap by AndroidBootstrap.
the class NavigationDrawerFragment method setUp.
/**
* Users of this fragment must call this method to set up the navigation drawer interactions.
*
* @param fragmentId The android:id of this fragment in its activity's layout.
* @param drawerLayout The DrawerLayout containing this fragment's UI.
*/
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
fragmentContainerView = getActivity().findViewById(fragmentId);
this.drawerLayout = drawerLayout;
// set a custom shadow that overlays the main content when the drawer opens
//drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// set up the drawer's list view with items and click listener
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
// ActionBarDrawerToggle ties together the the proper interactions
// between the navigation drawer and the action bar app icon.
drawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */
NavigationDrawerFragment.this.drawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
R.string.navigation_drawer_close) {
/* "close drawer" description for accessibility */
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (!isAdded()) {
return;
}
// calls onPrepareOptionsMenu()
getActivity().invalidateOptionsMenu();
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (!isAdded()) {
return;
}
if (!userLearnedDrawer) {
// The user manually opened the drawer; store this flag to prevent auto-showing
// the navigation drawer automatically in the future.
userLearnedDrawer = true;
prefs.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
}
// calls onPrepareOptionsMenu()
getActivity().invalidateOptionsMenu();
}
};
// per the navigation drawer design guidelines.
if (!userLearnedDrawer && !fromSavedInstanceState) {
this.drawerLayout.openDrawer(fragmentContainerView);
}
// Defer code dependent on restoration of previous instance state.
this.drawerLayout.post(new Runnable() {
@Override
public void run() {
drawerToggle.syncState();
}
});
this.drawerLayout.setDrawerListener(drawerToggle);
}
use of android.support.v4.app.ActionBarDrawerToggle in project AntennaPod by AntennaPod.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getNoTitleTheme());
super.onCreate(savedInstanceState);
StorageUtils.checkStorageAvailability(this);
setContentView(R.layout.main);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
findViewById(R.id.shadow).setVisibility(View.GONE);
int elevation = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
getSupportActionBar().setElevation(elevation);
}
currentTitle = getTitle();
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);
if (savedInstanceState != null) {
int backstackCount = savedInstanceState.getInt(SAVE_BACKSTACK_COUNT, 0);
drawerToggle.setDrawerIndicatorEnabled(backstackCount == 0);
}
drawerLayout.setDrawerListener(drawerToggle);
final FragmentManager fm = getSupportFragmentManager();
fm.addOnBackStackChangedListener(() -> drawerToggle.setDrawerIndicatorEnabled(fm.getBackStackEntryCount() == 0));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
navAdapter = new NavListAdapter(itemAccess, this);
navList.setAdapter(navAdapter);
navList.setOnItemClickListener(navListClickListener);
navList.setOnItemLongClickListener(newListLongClickListener);
registerForContextMenu(navList);
navAdapter.registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
selectedNavListIndex = getSelectedNavListIndex();
}
});
findViewById(R.id.nav_settings).setOnClickListener(v -> {
drawerLayout.closeDrawer(navDrawer);
startActivity(new Intent(MainActivity.this, PreferenceController.getPreferenceActivity()));
});
FragmentTransaction transaction = fm.beginTransaction();
Fragment mainFragment = fm.findFragmentByTag("main");
if (mainFragment != null) {
transaction.replace(R.id.main_view, mainFragment);
} else {
String lastFragment = getLastNavFragment();
if (ArrayUtils.contains(NAV_DRAWER_TAGS, lastFragment)) {
loadFragment(lastFragment, null);
} else {
try {
loadFeedFragmentById(Integer.parseInt(lastFragment), null);
} catch (NumberFormatException e) {
// it's not a number, this happens if we removed
// a label from the NAV_DRAWER_TAGS
// give them a nice default...
loadFragment(QueueFragment.TAG, null);
}
}
}
externalPlayerFragment = new ExternalPlayerFragment();
transaction.replace(R.id.playerFragment, externalPlayerFragment, ExternalPlayerFragment.TAG);
transaction.commit();
checkFirstLaunch();
}
Aggregations