Search in sources :

Example 1 with ActionBarDrawerToggle

use of com.ikimuhendis.ldrawer.ActionBarDrawerToggle in project superCleanMaster by joyoyao.

the class MainActivity method initDrawer.

private void initDrawer() {
    // TODO Auto-generated method stub
    ab = getActionBar();
    // 给home icon的左边加上一个返回的图标
    ab.setDisplayHomeAsUpEnabled(true);
    // 需要api level 14 使用home-icon 可点击
    ab.setHomeButtonEnabled(true);
    drawerArrow = new DrawerArrowDrawable(this) {

        @Override
        public boolean isLayoutRtl() {
            return false;
        }
    };
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, drawerArrow, R.string.drawer_open, R.string.drawer_close) {

        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            invalidateOptionsMenu();
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            invalidateOptionsMenu();
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
//        mNavigationDrawerFragment.setUp(R.id.navigation_drawer,
//                mDrawerLayout);
}
Also used : ActionBarDrawerToggle(com.ikimuhendis.ldrawer.ActionBarDrawerToggle) DrawerArrowDrawable(com.ikimuhendis.ldrawer.DrawerArrowDrawable) InjectView(butterknife.InjectView) View(android.view.View)

Example 2 with ActionBarDrawerToggle

use of com.ikimuhendis.ldrawer.ActionBarDrawerToggle in project LDrawer by keklikhasan.

the class SampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);
    ActionBar ab = getActionBar();
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setHomeButtonEnabled(true);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.navdrawer);
    drawerArrow = new DrawerArrowDrawable(this) {

        @Override
        public boolean isLayoutRtl() {
            return false;
        }
    };
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, drawerArrow, R.string.drawer_open, R.string.drawer_close) {

        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            invalidateOptionsMenu();
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            invalidateOptionsMenu();
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
    String[] values = new String[] { "Stop Animation (Back icon)", "Stop Animation (Home icon)", "Start Animation", "Change Color", "GitHub Page", "Share", "Rate" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
    mDrawerList.setAdapter(adapter);
    mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch(position) {
                case 0:
                    mDrawerToggle.setAnimateEnabled(false);
                    drawerArrow.setProgress(1f);
                    break;
                case 1:
                    mDrawerToggle.setAnimateEnabled(false);
                    drawerArrow.setProgress(0f);
                    break;
                case 2:
                    mDrawerToggle.setAnimateEnabled(true);
                    mDrawerToggle.syncState();
                    break;
                case 3:
                    if (drawerArrowColor) {
                        drawerArrowColor = false;
                        drawerArrow.setColor(R.color.ldrawer_color);
                    } else {
                        drawerArrowColor = true;
                        drawerArrow.setColor(R.color.drawer_arrow_second_color);
                    }
                    mDrawerToggle.syncState();
                    break;
                case 4:
                    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/IkiMuhendis/LDrawer"));
                    startActivity(browserIntent);
                    break;
                case 5:
                    Intent share = new Intent(Intent.ACTION_SEND);
                    share.setType("text/plain");
                    share.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    share.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name));
                    share.putExtra(Intent.EXTRA_TEXT, getString(R.string.app_description) + "\n" + "GitHub Page :  https://github.com/IkiMuhendis/LDrawer\n" + "Sample App : https://play.google.com/store/apps/details?id=" + getPackageName());
                    startActivity(Intent.createChooser(share, getString(R.string.app_name)));
                    break;
                case 6:
                    String appUrl = "https://play.google.com/store/apps/details?id=" + getPackageName();
                    Intent rateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(appUrl));
                    startActivity(rateIntent);
                    break;
            }
        }
    });
}
Also used : ActionBarDrawerToggle(com.ikimuhendis.ldrawer.ActionBarDrawerToggle) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) DrawerArrowDrawable(com.ikimuhendis.ldrawer.DrawerArrowDrawable) AdapterView(android.widget.AdapterView) ActionBar(android.app.ActionBar) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

View (android.view.View)2 ActionBarDrawerToggle (com.ikimuhendis.ldrawer.ActionBarDrawerToggle)2 DrawerArrowDrawable (com.ikimuhendis.ldrawer.DrawerArrowDrawable)2 ActionBar (android.app.ActionBar)1 Intent (android.content.Intent)1 AdapterView (android.widget.AdapterView)1 ArrayAdapter (android.widget.ArrayAdapter)1 ListView (android.widget.ListView)1 InjectView (butterknife.InjectView)1