Search in sources :

Example 46 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project double-espresso by JakeWharton.

the class DrawerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.drawer_activity);
    ListAdapter listAdapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.drawer_row, R.id.drawer_row_name, DRAWER_CONTENTS);
    final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ListView drawerList = (ListView) findViewById(R.id.drawer_list);
    drawerList.setAdapter(listAdapter);
    final TextView textView = (TextView) findViewById(R.id.drawer_text_view);
    drawerList.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            textView.setText("You picked: " + DRAWER_CONTENTS[(int) id]);
            drawerLayout.closeDrawers();
        }
    });
    // TODO(user): use compat lib for lower API levels
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        getActionBar().setDisplayHomeAsUpEnabled(true);
        getActionBar().setHomeButtonEnabled(true);
    }
    title = getTitle();
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.nav_drawer_open, R.string.nav_drawer_close) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            if (android.os.Build.VERSION.SDK_INT >= 11) {
                getActionBar().setTitle(title);
            }
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            if (android.os.Build.VERSION.SDK_INT >= 11) {
                getActionBar().setTitle(title);
            }
        }
    };
    drawerLayout.setDrawerListener(drawerToggle);
}
Also used : ListView(android.widget.ListView) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) TextView(android.widget.TextView) DrawerLayout(android.support.v4.widget.DrawerLayout) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListAdapter(android.widget.ListAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 47 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project aplicativo by InCasa.

the class HomeActivity 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_sensor) {
        Intent intent = new Intent(this, SensorActivity.class);
        startActivity(intent);
    } else if (id == R.id.nav_rele) {
        Intent intent = new Intent(this, ReleActivity.class);
        startActivity(intent);
    } else if (id == R.id.nav_voz) {
        Intent intent = new Intent(this, VozActivity.class);
        startActivity(intent);
    } else if (id == R.id.nav_config) {
        Intent intent = new Intent(this, ConfigActivity.class);
        startActivity(intent);
    } else if (id == R.id.nav_alarme) {
        Intent intent = new Intent(this, AlarmeActivity.class);
        startActivity(intent);
    } else if (id == R.id.nav_admin) {
        Intent intent = new Intent(this, AdminActivity.class);
        startActivity(intent);
    } else if (id == R.id.nav_dicas) {
        Intent intent = new Intent(this, DicasActivity.class);
        startActivity(intent);
    } else if (id == R.id.nav_logout) {
        Intent intent = new Intent(this, LoginActivity.class);
        startActivity(intent);
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
Also used : Intent(android.content.Intent) DrawerLayout(android.support.v4.widget.DrawerLayout)

Example 48 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project Cangol-uiframe by Cangol.

the class Main2Activity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_view);
    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ImageView imageView = (ImageView) findViewById(R.id.drawer_indicator);
    final Resources resources = getResources();
    drawerArrowDrawable = new DrawerArrowDrawable(resources);
    drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));
    imageView.setImageDrawable(drawerArrowDrawable);
    drawer.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            offset = slideOffset;
            // 0.
            if (slideOffset >= .995) {
                flipped = true;
                drawerArrowDrawable.setFlip(flipped);
            } else if (slideOffset <= .005) {
                flipped = false;
                drawerArrowDrawable.setFlip(flipped);
            }
            drawerArrowDrawable.setParameter(offset);
        }
    });
    imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (drawer.isDrawerVisible(START)) {
                drawer.closeDrawer(START);
            } else {
                drawer.openDrawer(START);
            }
        }
    });
    final TextView styleButton = (TextView) findViewById(R.id.indicator_style);
    styleButton.setOnClickListener(new View.OnClickListener() {

        boolean rounded = false;

        @Override
        public void onClick(View v) {
            styleButton.setText(//
            rounded ? //
            resources.getString(R.string.rounded) : resources.getString(R.string.squared));
            rounded = !rounded;
            drawerArrowDrawable = new DrawerArrowDrawable(resources, rounded);
            drawerArrowDrawable.setParameter(offset);
            drawerArrowDrawable.setFlip(flipped);
            drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));
            imageView.setImageDrawable(drawerArrowDrawable);
        }
    });
}
Also used : TextView(android.widget.TextView) ImageView(android.widget.ImageView) Resources(android.content.res.Resources) DrawerLayout(android.support.v4.widget.DrawerLayout) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View)

Example 49 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project Reachability by sakebook.

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) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;
    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.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.
    mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */
    mDrawerLayout, /* 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 (!mUserLearnedDrawer) {
                // The user manually opened the drawer; store this flag to prevent auto-showing
                // the navigation drawer automatically in the future.
                mUserLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }
            // calls onPrepareOptionsMenu()
            getActivity().invalidateOptionsMenu();
        }
    };
    // per the navigation drawer design guidelines.
    if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
        mDrawerLayout.openDrawer(mFragmentContainerView);
    }
    // Defer code dependent on restoration of previous instance state.
    mDrawerLayout.post(new Runnable() {

        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });
    mDrawerLayout.setDrawerListener(mDrawerToggle);
}
Also used : SharedPreferences(android.content.SharedPreferences) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ActionBar(android.app.ActionBar)

Example 50 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project IITB-App by wncc.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    session = new SessionManager(getApplicationContext());
    session.checkLogin();
    Toast.makeText(getApplicationContext(), "Log In status: " + session.isLoggedIn(), Toast.LENGTH_LONG).show();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    FeedFragment feedFragment = new FeedFragment();
    updateFragment(feedFragment);
    fetchNotifications();
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) FeedFragment(in.ac.iitb.gymkhana.iitbapp.fragment.FeedFragment) Toolbar(android.support.v7.widget.Toolbar)

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