Search in sources :

Example 51 with DrawerLayout

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);
}
Also used : NavigationView(android.support.design.widget.NavigationView) Bundle(android.os.Bundle) TextView(android.widget.TextView) ProfileFragment(in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment) ImageView(android.widget.ImageView) DrawerLayout(android.support.v4.widget.DrawerLayout) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 52 with DrawerLayout

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

Example 53 with DrawerLayout

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

Example 54 with DrawerLayout

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);
    }
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint)

Example 55 with DrawerLayout

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

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