Search in sources :

Example 76 with DrawerLayout

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);
}
Also used : LayoutParams(android.support.v4.widget.DrawerLayout.LayoutParams) FrameLayout(android.widget.FrameLayout) DrawerLayout(android.support.v4.widget.DrawerLayout)

Example 77 with 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;
    }
}
Also used : ViewDragHelper(android.support.v4.widget.ViewDragHelper) View(android.view.View) Paint(android.graphics.Paint)

Example 78 with DrawerLayout

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;
}
Also used : Intent(android.content.Intent) ChangeLog(de.cketti.library.changelog.ChangeLog) DrawerLayout(android.support.v4.widget.DrawerLayout)

Example 79 with DrawerLayout

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);
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) View(android.view.View) Toolbar(android.widget.Toolbar)

Example 80 with DrawerLayout

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;
}
Also used : DrawerLayout(android.support.v4.widget.DrawerLayout)

Aggregations

DrawerLayout (android.support.v4.widget.DrawerLayout)63 View (android.view.View)59 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)33 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)22 AdapterView (android.widget.AdapterView)22 NavigationView (android.support.design.widget.NavigationView)21 ListView (android.widget.ListView)21 Intent (android.content.Intent)19 Toolbar (android.support.v7.widget.Toolbar)19 TextView (android.widget.TextView)15 ImageView (android.widget.ImageView)12 ActionBar (android.support.v7.app.ActionBar)9 SharedPreferences (android.content.SharedPreferences)8 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 ViewPager (android.support.v4.view.ViewPager)6 SuppressLint (android.annotation.SuppressLint)5 TabLayout (android.support.design.widget.TabLayout)5 ArrayList (java.util.ArrayList)5 ActionBar (android.app.ActionBar)4 TypedArray (android.content.res.TypedArray)4