use of android.support.v4.widget.DrawerLayout in project IITB-App by wncc.
the class MainActivity method updateNavigationView.
private void updateNavigationView() {
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
View header = navigationView.getHeaderView(0);
header.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle bundle = new Bundle();
bundle.putString(Constants.USER_ID, currentUser.getUserID());
ProfileFragment profileFragment = new ProfileFragment();
profileFragment.setArguments(bundle);
updateFragment(profileFragment);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
}
});
TextView nameTextView = header.findViewById(R.id.user_name_nav_header);
TextView rollNoTextView = header.findViewById(R.id.user_rollno_nav_header);
ImageView profilePictureImageView = header.findViewById(R.id.user_profile_picture_nav_header);
nameTextView.setText(currentUser.getUserName());
rollNoTextView.setText(currentUser.getUserRollNumber());
Picasso.with(this).load(currentUser.getUserProfilePictureUrl()).into(profilePictureImageView);
}
use of android.support.v4.widget.DrawerLayout in project Klyph by jonathangerbaud.
the class KlyphDrawerLayout method setDrawerLockMode.
/**
* Enable or disable interaction with the given drawer.
*
* <p>This allows the application to restrict the user's ability to open or close
* the given drawer. DrawerLayout will still respond to calls to {@link #openDrawer(int)},
* {@link #closeDrawer(int)} and friends if a drawer is locked.</p>
*
* <p>Locking a drawer open or closed will implicitly open or close
* that drawer as appropriate.</p>
*
* @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED},
* {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}.
* @param edgeGravity Gravity.LEFT, RIGHT, START or END.
* Expresses which drawer to change the mode for.
*
* @see #LOCK_MODE_UNLOCKED
* @see #LOCK_MODE_LOCKED_CLOSED
* @see #LOCK_MODE_LOCKED_OPEN
*/
public void setDrawerLockMode(int lockMode, int edgeGravity) {
final int absGrav = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
if (absGrav == Gravity.LEFT) {
mLockModeLeft = lockMode;
} else if (absGrav == Gravity.RIGHT) {
mLockModeRight = lockMode;
}
if (lockMode != LOCK_MODE_UNLOCKED) {
// Cancel interaction in progress
final ViewDragHelper helper = absGrav == Gravity.LEFT ? mLeftDragger : mRightDragger;
helper.cancel();
}
switch(lockMode) {
case LOCK_MODE_LOCKED_OPEN:
final View toOpen = findDrawerWithGravity(absGrav);
if (toOpen != null) {
openDrawer(toOpen);
}
break;
case LOCK_MODE_LOCKED_CLOSED:
final View toClose = findDrawerWithGravity(absGrav);
if (toClose != null) {
closeDrawer(toClose);
}
break;
}
}
use of android.support.v4.widget.DrawerLayout in project Shuttle by timusus.
the class Aesthetic method invalidateStatusBar.
private void invalidateStatusBar(AppCompatActivity activity) {
String key = String.format(KEY_STATUS_BAR_COLOR, key(activity));
final int color = prefs.getInt(key, resolveColor(activity, R.attr.colorPrimaryDark));
ViewGroup rootView = Util.getRootView(activity);
if (rootView instanceof DrawerLayout) {
// Color is set to DrawerLayout, Activity gets transparent status bar
setLightStatusBarCompat(activity, false);
Util.setStatusBarColorCompat(activity, ContextCompat.getColor(activity, android.R.color.transparent));
((DrawerLayout) rootView).setStatusBarBackgroundColor(color);
} else {
Util.setStatusBarColorCompat(activity, color);
}
final int mode = prefs.getInt(KEY_LIGHT_STATUS_MODE, AutoSwitchMode.AUTO);
switch(mode) {
case AutoSwitchMode.OFF:
setLightStatusBarCompat(activity, false);
break;
case AutoSwitchMode.ON:
setLightStatusBarCompat(activity, true);
break;
default:
setLightStatusBarCompat(activity, isColorLight(color));
break;
}
}
use of android.support.v4.widget.DrawerLayout in project AdvancedMaterialDrawer by madcyph3r.
the class MaterialNavigationDrawer method initDrawer.
public void initDrawer() {
if (deviceSupportMultiPane()) {
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, drawerViewGroup);
DrawerLayout.LayoutParams params = new DrawerLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
params.setMargins((int) (320 * displayDensity), 0, 0, 0);
contentViewGroup.setLayoutParams(params);
drawerLayout.setScrimColor(Color.TRANSPARENT);
drawerLayout.openDrawer(drawerViewGroup);
drawerLayout.setMultipaneSupport(true);
// drawerLayout.requestDisallowInterceptTouchEvent(true);
} else {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
// don't use the constructor with toolbar, or onOptionsItemSelected() method will not be called
actionBarToggle = new ActionBarDrawerToggle(this, drawerLayout, /*, toolbar*/
R.string.nothing, R.string.nothing) {
public void onDrawerClosed(View view) {
invalidateOptionsMenu();
drawerTouchLocked = false;
if (drawerStateListener != null)
drawerStateListener.onDrawerClosed(view);
}
public void onDrawerOpened(View drawerView) {
invalidateOptionsMenu();
if (drawerStateListener != null)
drawerStateListener.onDrawerOpened(drawerView);
}
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
// if user wants the sliding arrow it compare
if (slidingDrawerEffect)
super.onDrawerSlide(drawerView, slideOffset);
else
super.onDrawerSlide(drawerView, 0);
if (drawerStateListener != null)
drawerStateListener.onDrawerSlide(drawerView, slideOffset);
}
@Override
public void onDrawerStateChanged(int newState) {
super.onDrawerStateChanged(newState);
if (drawerStateListener != null)
drawerStateListener.onDrawerStateChanged(newState);
}
};
drawerLayout.setDrawerListener(actionBarToggle);
drawerLayout.setMultipaneSupport(false);
}
}
use of android.support.v4.widget.DrawerLayout in project SeeWeather by xcc3641.
the class RxDrawer method close.
public static Observable<Irrelevant> close(final DrawerLayout drawer) {
return Observable.create(emitter -> {
drawer.closeDrawer(GravityCompat.START);
DrawerListener listener = new DrawerLayout.SimpleDrawerListener() {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
if (slideOffset < OFFSET_THRESHOLD) {
emitter.onNext(Irrelevant.INSTANCE);
emitter.onComplete();
drawer.removeDrawerListener(this);
}
}
};
drawer.addDrawerListener(listener);
});
}
Aggregations