Android Open Source - material-menu Toolbar Activity






From Project

Back to project page material-menu.

License

The source code is released under:

Apache License

If you think the Android project material-menu listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.balysv.materialmenu.demo.toolbar;
/*  w w w. j  av  a2 s .  c o  m*/
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.balysv.materialmenu.demo.BaseActivityHelper;
import com.balysv.materialmenu.demo.R;
import com.balysv.materialmenu.extras.toolbar.MaterialMenuIconToolbar;

import static com.balysv.materialmenu.MaterialMenuDrawable.Stroke;
import static com.balysv.materialmenu.demo.BaseActivityHelper.generateState;
import static com.balysv.materialmenu.demo.BaseActivityHelper.intToState;


public class ToolbarActivity extends ActionBarActivity {

    private MaterialMenuIconToolbar materialMenu;

    private int actionBarMenuState;

    protected BaseActivityHelper helper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.toolbar);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override public void onClick(View v) {
                // random state
                actionBarMenuState = generateState(actionBarMenuState);
                materialMenu.animatePressedState(intToState(actionBarMenuState));
            }
        });
        materialMenu = new MaterialMenuIconToolbar(this, Color.WHITE, Stroke.THIN) {
            @Override public int getToolbarViewId() {
                return R.id.toolbar;
            }
        };
        materialMenu.setNeverDrawTouch(true);
        helper = new BaseActivityHelper();
        helper.init(getWindow().getDecorView(), materialMenu);
    }

    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        helper.refreshDrawerState();
        materialMenu.syncState(savedInstanceState);
    }

    @Override protected void onSaveInstanceState(Bundle outState) {
        materialMenu.onSaveInstanceState(outState);
        super.onSaveInstanceState(outState);
    }
}




Java Source Code List

com.balysv.materialmenu.MaterialMenuBase.java
com.balysv.materialmenu.MaterialMenuDrawable.java
com.balysv.materialmenu.MaterialMenuIcon.java
com.balysv.materialmenu.MaterialMenuView.java
com.balysv.materialmenu.MaterialMenu.java
com.balysv.materialmenu.demo.BaseActivityHelper.java
com.balysv.materialmenu.demo.abc.BaseActivity.java
com.balysv.materialmenu.demo.abc.CustomViewActivity.java
com.balysv.materialmenu.demo.abc.HomeIconActivity.java
com.balysv.materialmenu.demo.abs.BaseActivity.java
com.balysv.materialmenu.demo.abs.CustomViewActivity.java
com.balysv.materialmenu.demo.abs.HomeIconActivity.java
com.balysv.materialmenu.demo.stock.BaseActivity.java
com.balysv.materialmenu.demo.stock.CustomViewActivity.java
com.balysv.materialmenu.demo.stock.HomeIconActivity.java
com.balysv.materialmenu.demo.toolbar.ToolbarActivity.java
com.balysv.materialmenu.extras.abc.MaterialMenuIconCompat.java
com.balysv.materialmenu.extras.abs.MaterialMenuIconSherlock.java
com.balysv.materialmenu.extras.toolbar.MaterialMenuIconToolbar.java