use of android.support.v4.widget.DrawerLayout in project RxBinding by JakeWharton.
the class RxDrawerLayoutTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
drawerLayout = new DrawerLayout(this);
drawerLayout.setId(android.R.id.primary);
FrameLayout main = new FrameLayout(this);
LayoutParams mainParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
drawerLayout.addView(main, mainParams);
FrameLayout drawer = new FrameLayout(this);
drawer.setBackgroundColor(Color.WHITE);
LayoutParams drawerParams = new LayoutParams(300, MATCH_PARENT, RIGHT);
drawerLayout.addView(drawer, drawerParams);
setContentView(drawerLayout);
}
use of android.support.v4.widget.DrawerLayout in project u2020 by JakeWharton.
the class DebugDrawerLayout 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(@LockMode int lockMode, @EdgeGravity int edgeGravity) {
final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
if (absGravity == Gravity.LEFT) {
mLockModeLeft = lockMode;
} else if (absGravity == Gravity.RIGHT) {
mLockModeRight = lockMode;
}
if (lockMode != LOCK_MODE_UNLOCKED) {
// Cancel interaction in progress
final ViewDragHelper helper = absGravity == Gravity.LEFT ? mLeftDragger : mRightDragger;
helper.cancel();
}
switch(lockMode) {
case LOCK_MODE_LOCKED_OPEN:
final View toOpen = findDrawerWithGravity(absGravity);
if (toOpen != null) {
openDrawer(toOpen);
}
break;
case LOCK_MODE_LOCKED_CLOSED:
final View toClose = findDrawerWithGravity(absGravity);
if (toClose != null) {
closeDrawer(toClose);
}
break;
}
}
use of android.support.v4.widget.DrawerLayout in project Gadgetbridge by Freeyourgadget.
the class ControlCenterv2 method onNavigationItemSelected.
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
switch(item.getItemId()) {
case R.id.action_settings:
Intent settingsIntent = new Intent(this, SettingsActivity.class);
startActivity(settingsIntent);
return true;
case R.id.action_debug:
Intent debugIntent = new Intent(this, DebugActivity.class);
startActivity(debugIntent);
return true;
case R.id.action_db_management:
Intent dbIntent = new Intent(this, DbManagementActivity.class);
startActivity(dbIntent);
return true;
case R.id.action_quit:
GBApplication.quit();
return true;
case R.id.external_changelog:
ChangeLog cl = new ChangeLog(this);
cl.getFullLogDialog().show();
return true;
}
return true;
}
use of android.support.v4.widget.DrawerLayout in project platform_frameworks_base by android.
the class DrawerController method create.
/**
* Returns a controller suitable for {@code Layout}.
*/
static DrawerController create(Activity activity) {
DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);
if (layout == null) {
return new DummyDrawerController();
}
View drawer = activity.findViewById(R.id.drawer_roots);
Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar);
drawer.getLayoutParams().width = calculateDrawerWidth(activity);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(activity, layout, R.drawable.ic_hamburger, R.string.drawer_open, R.string.drawer_close);
return new RuntimeDrawerController(layout, drawer, toggle, toolbar);
}
use of android.support.v4.widget.DrawerLayout in project AndResGuard by shwenzhang.
the class MainActivity method onNavigationItemSelected.
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_camera) {
// Handle the camera action
} else if (id == R.id.nav_gallery) {
} else if (id == R.id.nav_slideshow) {
} else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
Aggregations