Search in sources :

Example 61 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project BeautifulRefreshLayout by android-cjj.

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);
    final ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle(null);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "I'm CJJ", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : NavigationView(android.support.design.widget.NavigationView) TabLayout(android.support.design.widget.TabLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) ViewPager(android.support.v4.view.ViewPager) NavigationView(android.support.design.widget.NavigationView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 62 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project Klyph by jonathangerbaud.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    /*
		 * if (KlyphSession.getSessionUserName() != null)
		 * {
		 * loggedIn = true;
		 * setTitle(KlyphSession.getSessionUserName());
		 * }
		 * else
		 * {
		 * if (KlyphFlags.IS_PRO_VERSION == true)
		 * setTitle(R.string.app_pro_name);
		 * else
		 * setTitle(R.string.app_name);
		 * }
		 */
    setTitle("");
    if (Session.getActiveSession() == null || KlyphSession.getSessionUserId() == null || (Session.getActiveSession() != null && Session.getActiveSession().isOpened() == false)) {
        getActionBar().hide();
        getFragmentManager().beginTransaction().add(R.id.main, new LoginFragment(), FRAGMENT_TAG).commit();
    }
    // notificationsFragment.setHasOptionsMenu(false);
    adContainer = (ViewGroup) findViewById(R.id.ad);
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    drawerToggle = new ActionBarDrawerToggle(this, drawer, AttrUtil.getResourceId(this, R.attr.drawerIcon), R.string.open, R.string.close) {

        @Override
        public void onDrawerOpened(View view) {
            Log.d("MainActivity.onCreate(...).new ActionBarDrawerToggle() {...}", "onDrawerOpened: ");
            super.onDrawerOpened(view);
            Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG);
            if (drawer.isDrawerOpen(Gravity.RIGHT)) {
                if (notificationsFragment != null) {
                    notificationsFragment.setHasOptionsMenu(true);
                    notificationsFragment.onOpenPane();
                }
                if (fragment != null)
                    fragment.setHasOptionsMenu(false);
            } else if (drawer.isDrawerOpen(Gravity.LEFT)) {
                if (notificationsFragment != null) {
                    notificationsFragment.setHasOptionsMenu(false);
                }
                if (fragment != null)
                    fragment.setHasOptionsMenu(true);
            }
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
            if (!drawer.isDrawerOpen(Gravity.RIGHT)) {
                if (notificationsFragment != null)
                    notificationsFragment.setHasOptionsMenu(false);
                Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG);
                if (fragment != null)
                    fragment.setHasOptionsMenu(true);
            }
            invalidateOptionsMenu();
        }
    };
    drawer.setDrawerListener(drawerToggle);
    final List<String> labels = KlyphPreferences.getLeftDrawerMenuLabels();
    classes = new ArrayList<String>(KlyphPreferences.getLeftDrawerMenuClasses());
    classes.add("com.abewy.android.apps.klyph.fragment.UserTimeline");
    navAdapter = new DrawerLayoutAdapter(getActionBar().getThemedContext(), R.layout.item_drawer_layout, labels);
    final ListView navList = (ListView) findViewById(R.id.drawer);
    // Setting drawers max width
    int maxWidth = getResources().getDimensionPixelSize(R.dimen.max_drawer_layout_width);
    int w = Math.min(KlyphDevice.getDeviceWidth(), KlyphDevice.getDeviceHeight()) - getResources().getDimensionPixelSize(R.dimen.dip_64);
    int finalWidth = Math.min(maxWidth, w);
    LayoutParams params = ((View) navList.getParent()).getLayoutParams();
    params.width = finalWidth;
    ((View) navList.getParent()).setLayoutParams(params);
    final View notificationContainer = findViewById(R.id.notifications_container);
    params = notificationContainer.getLayoutParams();
    params.width = finalWidth;
    notificationContainer.setLayoutParams(params);
    // End max width
    navList.setFadingEdgeLength(0);
    navList.setVerticalFadingEdgeEnabled(false);
    navList.setAdapter(navAdapter);
    navList.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, final int pos, long id) {
            updateContent(pos);
            drawer.closeDrawer(Gravity.LEFT);
        }
    });
    // Facebook HashKey
    if (KlyphFlags.LOG_FACEBOOK_HASH)
        FacebookUtil.logHash(this);
    // Hierarchy View Connector
    if (KlyphFlags.ENABLE_HIERACHY_VIEW_CONNECTOR)
        HierachyViewUtil.connectHierarchyView(this);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) LoginFragment(com.abewy.android.apps.klyph.fragment.LoginFragment) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) UserCoverImageView(com.abewy.android.apps.klyph.widget.coverImage.UserCoverImageView) TextView(android.widget.TextView) ListView(android.widget.ListView) ProfileImageView(com.abewy.android.apps.klyph.widget.ProfileImageView) LoginFragment(com.abewy.android.apps.klyph.fragment.LoginFragment) Fragment(android.app.Fragment) IKlyphFragment(com.abewy.android.apps.klyph.fragment.IKlyphFragment) ListView(android.widget.ListView)

Example 63 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project Navigation-drawer-page-sliding-tab-strip by balaji-k13.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mTitle = mDrawerTitle = getTitle();
    mPlanetTitles = getResources().getStringArray(R.array.planets_array);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    // 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
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mPlanetTitles));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    // enable ActionBar app icon to behave as action to toggle nav drawer
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* 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 */
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            // creates call to
            invalidateOptionsMenu();
        // onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            // creates call to
            invalidateOptionsMenu();
        // onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    if (savedInstanceState == null) {
        selectItem(0);
    }
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 64 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project material-menu by balysv.

the class DemoActivity method initViews.

private void initViews() {
    materialMenuView = (MaterialMenuView) findViewById(R.id.material_menu_button);
    materialMenuView.setOnClickListener(this);
    drawerLayout = ((DrawerLayout) findViewById(R.id.drawer_layout));
    drawerLayout.setScrimColor(Color.parseColor("#66000000"));
    drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            getMaterialMenu(toolbar).setTransformationOffset(MaterialMenuDrawable.AnimationState.BURGER_ARROW, direction ? 2 - slideOffset : slideOffset);
        }

        @Override
        public void onDrawerOpened(android.view.View drawerView) {
            direction = true;
        }

        @Override
        public void onDrawerClosed(android.view.View drawerView) {
            direction = false;
        }
    });
    SeekBar duration = (SeekBar) findViewById(R.id.item_animation_duration);
    duration.setMax(4600);
    duration.setProgress(2600);
    duration.setOnSeekBarChangeListener(this);
    findViewById(R.id.switch_item_arrow).setOnClickListener(this);
    findViewById(R.id.switch_item_menu).setOnClickListener(this);
    findViewById(R.id.switch_item_x).setOnClickListener(this);
    findViewById(R.id.switch_item_check).setOnClickListener(this);
    findViewById(R.id.switch_item_show).setOnClickListener(this);
    findViewById(R.id.switch_item_hide).setOnClickListener(this);
    findViewById(R.id.animate_item_arrow).setOnClickListener(this);
    findViewById(R.id.animate_item_menu).setOnClickListener(this);
    findViewById(R.id.animate_item_x).setOnClickListener(this);
    findViewById(R.id.animate_item_check).setOnClickListener(this);
}
Also used : SeekBar(android.widget.SeekBar) View(android.view.View) DrawerLayout(android.support.v4.widget.DrawerLayout) MaterialMenuView(com.balysv.materialmenu.MaterialMenuView) View(android.view.View)

Example 65 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project StickyListHeaders by emilsjolander.

the class TestActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    refreshLayout.setRefreshing(false);
                }
            }, 1000);
        }
    });
    mAdapter = new TestBaseAdapter(this);
    stickyList = (StickyListHeadersListView) findViewById(R.id.list);
    stickyList.setOnItemClickListener(this);
    stickyList.setOnHeaderClickListener(this);
    stickyList.setOnStickyHeaderChangedListener(this);
    stickyList.setOnStickyHeaderOffsetChangedListener(this);
    stickyList.addHeaderView(getLayoutInflater().inflate(R.layout.list_header, null));
    stickyList.addFooterView(getLayoutInflater().inflate(R.layout.list_footer, null));
    stickyList.setEmptyView(findViewById(R.id.empty));
    stickyList.setDrawingListUnderStickyHeader(true);
    stickyList.setAreHeadersSticky(true);
    stickyList.setAdapter(mAdapter);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
    mDrawerLayout, /* DrawerLayout object */
    R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
    R.string.drawer_open, /* "open drawer" description */
    R.string.drawer_close);
    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    restoreButton = (Button) findViewById(R.id.restore_button);
    restoreButton.setOnClickListener(buttonListener);
    openExpandableListButton = (Button) findViewById(R.id.open_expandable_list_button);
    openExpandableListButton.setOnClickListener(buttonListener);
    updateButton = (Button) findViewById(R.id.update_button);
    updateButton.setOnClickListener(buttonListener);
    clearButton = (Button) findViewById(R.id.clear_button);
    clearButton.setOnClickListener(buttonListener);
    stickyCheckBox = (CheckBox) findViewById(R.id.sticky_checkBox);
    stickyCheckBox.setOnCheckedChangeListener(checkBoxListener);
    fadeCheckBox = (CheckBox) findViewById(R.id.fade_checkBox);
    fadeCheckBox.setOnCheckedChangeListener(checkBoxListener);
    drawBehindCheckBox = (CheckBox) findViewById(R.id.draw_behind_checkBox);
    drawBehindCheckBox.setOnCheckedChangeListener(checkBoxListener);
    fastScrollCheckBox = (CheckBox) findViewById(R.id.fast_scroll_checkBox);
    fastScrollCheckBox.setOnCheckedChangeListener(checkBoxListener);
    stickyList.setStickyHeaderTopOffset(-20);
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) Handler(android.os.Handler) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

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