Search in sources :

Example 31 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 32 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 33 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 34 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project flexbox-layout by google.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initializeStringResources();
    mFlexboxLayout = (FlexboxLayout) findViewById(R.id.flexbox_layout);
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    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);
    if (drawer != null) {
        drawer.addDrawerListener(toggle);
    }
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        navigationView.setNavigationItemSelectedListener(this);
        Menu navigationMenu = navigationView.getMenu();
        initializeFlexDirectionSpinner(navigationMenu);
        initializeFlexWrapSpinner(navigationMenu);
        initializeJustifyContentSpinner(navigationMenu);
        initializeAlignItemsSpinner(navigationMenu);
        initializeAlignContentSpinner(navigationMenu);
    }
    if (savedInstanceState != null) {
        ArrayList<FlexItem> flexItems = savedInstanceState.getParcelableArrayList(FLEX_ITEMS_KEY);
        assert flexItems != null;
        mFlexboxLayout.removeAllViews();
        for (int i = 0; i < flexItems.size(); i++) {
            FlexItem flexItem = flexItems.get(i);
            FlexboxLayout.LayoutParams lp = flexItem.toLayoutParams(this);
            TextView textView = createBaseFlexItemTextView(i);
            ViewCompat.setPaddingRelative(textView, flexItem.paddingStart, flexItem.paddingTop, flexItem.paddingEnd, flexItem.paddingBottom);
            textView.setLayoutParams(lp);
            mFlexboxLayout.addView(textView);
        }
    }
    for (int i = 0; i < mFlexboxLayout.getChildCount(); i++) {
        mFlexboxLayout.getChildAt(i).setOnClickListener(new FlexItemClickListener(i));
    }
    FloatingActionButton addFab = (FloatingActionButton) findViewById(R.id.add_fab);
    if (addFab != null) {
        addFab.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                int viewIndex = mFlexboxLayout.getChildCount();
                // index starts from 0. New View's index is N if N views ([0, 1, 2, ... N-1])
                // exist.
                TextView textView = createBaseFlexItemTextView(viewIndex);
                textView.setLayoutParams(createDefaultLayoutParams());
                textView.setOnClickListener(new FlexItemClickListener(viewIndex));
                mFlexboxLayout.addView(textView);
            }
        });
    }
    FloatingActionButton removeFab = (FloatingActionButton) findViewById(R.id.remove_fab);
    if (removeFab != null) {
        removeFab.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (mFlexboxLayout.getChildCount() == 0) {
                    return;
                }
                mFlexboxLayout.removeViewAt(mFlexboxLayout.getChildCount() - 1);
            }
        });
    }
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) NavigationView(android.support.design.widget.NavigationView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) FlexboxLayout(com.google.android.flexbox.FlexboxLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) TextView(android.widget.TextView) Menu(android.view.Menu) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 35 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project OkVolley by googolmo.

the class DrawerFragment 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.drawer_open, /* "open drawer" description for accessibility */
    R.string.drawer_close) {

        /* "close drawer" description for accessibility */
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (!isAdded()) {
                return;
            }
            // calls onPrepareOptionsMenu()
            getActivity().supportInvalidateOptionsMenu();
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!isAdded()) {
                return;
            }
            // calls onPrepareOptionsMenu()
            getActivity().supportInvalidateOptionsMenu();
        }
    };
    // Defer code dependent on restoration of previous instance state.
    mDrawerLayout.post(new Runnable() {

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

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)80 View (android.view.View)76 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)34 TextView (android.widget.TextView)31 NavigationView (android.support.design.widget.NavigationView)30 AdapterView (android.widget.AdapterView)30 ListView (android.widget.ListView)29 Toolbar (android.support.v7.widget.Toolbar)25 DrawerLayout (android.support.v4.widget.DrawerLayout)23 ActionBar (android.support.v7.app.ActionBar)19 ImageView (android.widget.ImageView)16 SharedPreferences (android.content.SharedPreferences)14 Intent (android.content.Intent)12 RecyclerView (android.support.v7.widget.RecyclerView)8 SearchView (android.support.v7.widget.SearchView)8 Handler (android.os.Handler)6 PackageManager (android.content.pm.PackageManager)5 MenuItem (android.view.MenuItem)5 InjectView (butterknife.InjectView)5 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)5