Search in sources :

Example 11 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project fresco by facebook.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    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.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    if (savedInstanceState == null) {
        int selectedItem = PreferenceManager.getDefaultSharedPreferences(this).getInt(KEY_SELECTED_NAVDRAWER_ITEM_ID, INITIAL_NAVDRAWER_ITEM_ID);
        handleNavigationItemClick(selectedItem);
        navigationView.setCheckedItem(selectedItem);
    }
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 12 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project android-seed by freezy.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (toolbar != null) {
        toolbar.setTitle(R.string.app_name);
        setSupportActionBar(toolbar);
    }
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };
    drawerLayout.setDrawerListener(drawerToggle);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
    }
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) View(android.view.View)

Example 13 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project cardslib by gabrielemariotti.

the class LPreviewUtilsBase method setupDrawerToggle.

//----------------------------------------------------------------------------
// Navigation Drawer
//----------------------------------------------------------------------------
public ActionBarDrawerToggle setupDrawerToggle(DrawerLayout drawerLayout, final DrawerLayout.DrawerListener drawerListener) {
    mDrawerToggle = new ActionBarDrawerToggle(mActivity, /* host Activity */
    drawerLayout, /* DrawerLayout object */
    mActionBarToolbar, /* nav drawer icon to replace 'Up' caret */
    R.string.app_name, /* "open drawer" description */
    R.string.app_name);
    drawerLayout.setDrawerListener(mDrawerToggle);
    return mDrawerToggle;
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle)

Example 14 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project Hummingbird-for-Android by xiprox.

the class NavigationDrawerFragment method setUp.

public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;
    mDrawerLayout.setDrawerShadow(R.drawable.navigation_drawer_shadow, GravityCompat.START);
    mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.apptheme_primary_dark));
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    mDrawerToggle = new ActionBarDrawerToggle(getActivity(), mDrawerLayout, ((MainActivity) getActivity()).getToolbar(), R.string.navigation_drawer_open, R.string.navigation_drawer_close) {

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (!isAdded()) {
                return;
            }
            getActivity().invalidateOptionsMenu();
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!isAdded()) {
                return;
            }
            if (!mUserLearnedDrawer) {
                mUserLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }
            getActivity().invalidateOptionsMenu();
        }
    };
    if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
        mDrawerLayout.openDrawer(mFragmentContainerView);
    }
    mDrawerLayout.post(new Runnable() {

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

Example 15 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project TourGuide by worker8.

the class NavDrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mActivity = this;
    setContentView(R.layout.activity_nav_drawer);
    /* get views from xml */
    mTextView1 = (TextView) findViewById(R.id.item1);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    /* setup toolbar */
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    toolbar.setTitle("Nav Drawer Example");
    mTutorialHandler = TourGuide.init(mActivity).with(TourGuide.Technique.CLICK).setPointer(new Pointer()).setToolTip(new ToolTip().setTitle(null).setDescription("hello world")).setOverlay(new Overlay().setBackgroundColor(Color.parseColor("#66FF0000")));
    final ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open_string, R.string.drawer_close_string) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            /* We need call playOn only after the drawer is opened,
                   so that TourGuide knows the updated location of the targetted view */
            mTutorialHandler.playOn(mTextView1);
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
    /* setup clean up code */
    mTextView1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mTutorialHandler.cleanUp();
            mDrawerLayout.closeDrawers();
        }
    });
    final ViewTreeObserver viewTreeObserver = mTextView1.getViewTreeObserver();
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            // make sure this only run once
            mTextView1.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            mDrawerLayout.openDrawer(Gravity.LEFT);
        }
    });
}
Also used : ToolTip(tourguide.tourguide.ToolTip) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Pointer(tourguide.tourguide.Pointer) Overlay(tourguide.tourguide.Overlay) TextView(android.widget.TextView) View(android.view.View) ViewTreeObserver(android.view.ViewTreeObserver) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)91 View (android.view.View)80 NavigationView (android.support.design.widget.NavigationView)34 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)34 TextView (android.widget.TextView)32 Toolbar (android.support.v7.widget.Toolbar)31 AdapterView (android.widget.AdapterView)30 DrawerLayout (android.support.v4.widget.DrawerLayout)29 ListView (android.widget.ListView)29 ActionBar (android.support.v7.app.ActionBar)20 ImageView (android.widget.ImageView)18 Intent (android.content.Intent)15 SharedPreferences (android.content.SharedPreferences)15 RecyclerView (android.support.v7.widget.RecyclerView)9 SearchView (android.support.v7.widget.SearchView)8 MenuItem (android.view.MenuItem)7 Handler (android.os.Handler)6 PackageManager (android.content.pm.PackageManager)5 InjectView (butterknife.InjectView)5 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)5