Search in sources :

Example 1 with MaterialItemSectionActivity

use of de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity in project AdvancedMaterialDrawer by madcyph3r.

the class NoClosePrevDrawerActivity_Activity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "Open the drawer and choose the 'start activity' section. Then press back, \" +\n" + "                \"you will get back to this activity.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "No Close Previous Drawer Activity"));
    menu.add(new MaterialItemDevisor());
    menu.add(new MaterialItemSectionActivity(this, "start Activity", new Intent(this, NoCloseActivity.class)));
    // load menu
    this.loadMenu(menu);
    // load first MaterialItemSectionFragment in the menu, because there is no start position
    this.loadStartFragmentFromMenu(menu);
}
Also used : MaterialItemSectionActivity(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) Bundle(android.os.Bundle) MaterialItemDevisor(de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor) MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu) Intent(android.content.Intent) FragmentInstruction(de.madcyph3r.example.example.FragmentInstruction) Fragment(android.support.v4.app.Fragment) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)

Example 2 with MaterialItemSectionActivity

use of de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity in project AdvancedMaterialDrawer by madcyph3r.

the class AllMenuTypesActivity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "This example shows all menu items. " + "Open the drawer and see ;).");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "All Menu Types"));
    menu.add(new MaterialItemDevisor());
    menu.add(new MaterialItemCustom(this, R.layout.custom_section));
    menu.add(new MaterialItemLabel(this, "Label"));
    menu.add(new MaterialItemSectionFragment(this, "Fragment Section", new FragmentDummy(), "Fragment Section"));
    MaterialItemSectionFragment secNoti = new MaterialItemSectionFragment(this, "Fragment Section Notification", new FragmentDummy(), "Fragment Section Notification");
    secNoti.setNotifications(20);
    menu.add(secNoti);
    menu.add(new MaterialItemSectionFragment(this, "Fragment Section Icon", this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), new FragmentDummy(), "Fragment Section Icon"));
    MaterialItemSectionFragment iconBanner = new MaterialItemSectionFragment(this, this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), true, new FragmentDummy(), "Fragment Section Icon Banner");
    //iconBanner.getIconView().setScaleType(ImageView.ScaleType.CENTER);  edit the iconView to your needs
    menu.add(iconBanner);
    menu.add(new MaterialItemSectionFragment(this, "Fragment Section Color Red", this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), new FragmentDummy(), "Fragment Section Color Red").setSectionColor(Color.parseColor("#ff0858")));
    menu.add(new MaterialItemDevisor());
    menu.add(new MaterialItemSectionActivity(this, "Activity Section", new Intent(this, DummyActivity.class)));
    MaterialItemSectionOnClick onClickSection = new MaterialItemSectionOnClick(this, "OnClick Section");
    onClickSection.setOnSectionClickListener(new MaterialSectionOnClickListener() {

        @Override
        public void onClick(MaterialItemSection section, View v) {
            Toast.makeText(drawer, "OnClickSection", Toast.LENGTH_SHORT).show();
        }
    });
    menu.add(onClickSection);
    MaterialItemSectionFragment bottom = new MaterialItemSectionFragment(this, "Fragment Bottom Section", new FragmentDummy(), "Fragment Bottom Section");
    bottom.setBottom(true);
    menu.add(bottom);
    // load menu
    this.loadMenu(menu);
    // load the MaterialItemSectionFragment, from the given startIndex
    this.loadStartFragmentFromMenu(menu);
}
Also used : MaterialItemSectionActivity(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity) Bundle(android.os.Bundle) MaterialItemSectionOnClick(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionOnClick) MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu) MaterialItemCustom(de.madcyph3r.materialnavigationdrawer.menu.item.custom.MaterialItemCustom) FragmentDummy(de.madcyph3r.example.example.FragmentDummy) Intent(android.content.Intent) FragmentInstruction(de.madcyph3r.example.example.FragmentInstruction) Fragment(android.support.v4.app.Fragment) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) ImageView(android.widget.ImageView) View(android.view.View) MaterialSectionOnClickListener(de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionOnClickListener) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) MaterialItemDevisor(de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor) MaterialItemLabel(de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel) MaterialItemSection(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)

Example 3 with MaterialItemSectionActivity

use of de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity in project AdvancedMaterialDrawer by madcyph3r.

the class ClosePrevDrawerActivity_Activity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "Open the drawer and choose the 'start activity' section. \" +\n" + "                \"This activity will be closed. You get Back to the latest non closed (not finish()) activity.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Close Previous Drawer Activity"));
    menu.add(new MaterialItemDevisor());
    menu.add(new MaterialItemSectionActivity(this, "start Activity", new Intent(this, CloseActivity.class)));
    // load menu
    this.loadMenu(menu);
    // load first MaterialItemSectionFragment in the menu, because there is no start position
    this.loadStartFragmentFromMenu(menu);
}
Also used : MaterialItemSectionActivity(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) Bundle(android.os.Bundle) MaterialItemDevisor(de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor) MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu) Intent(android.content.Intent) FragmentInstruction(de.madcyph3r.example.example.FragmentInstruction) Fragment(android.support.v4.app.Fragment) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)

Example 4 with MaterialItemSectionActivity

use of de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity in project AdvancedMaterialDrawer by madcyph3r.

the class MaterialNavigationDrawer method onClick.

@Override
public void onClick(final MaterialItemSection section, View view) {
    if (!drawerTouchLocked) {
        if (section != currentSectionFragment) {
            if (section instanceof MaterialItemSectionFragment) {
                sectionFragmentLastBackPatternList.add((MaterialItemSectionFragment) section);
                //unSelectOldSection(section);
                MaterialItemSectionFragment sectionFragment = (MaterialItemSectionFragment) section;
                if (currentSectionFragment != null) {
                    currentSectionFragment.unSelect();
                    changeFragment((Fragment) sectionFragment.getFragment(), sectionFragment.getFragmentTitle(), (Fragment) ((MaterialItemSectionFragment) currentSectionFragment).getFragment(), true);
                //sectionFragmentLastBackPatternList.add(currentSectionFragment);
                } else
                    changeFragment((Fragment) sectionFragment.getFragment(), sectionFragment.getFragmentTitle(), null, true);
                section.select();
                changeToolbarColor(section);
                currentSectionFragment = sectionFragment;
            } else if (section instanceof MaterialItemSectionActivity) {
                section.unSelect();
                // smooth close drawerViewGroup before activity start
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        Class<?> clazzSign = null;
                        try {
                            MaterialItemSectionActivity sectionActivity = (MaterialItemSectionActivity) section;
                            clazzSign = Class.forName(sectionActivity.getIntent().getComponent().getClassName());
                            final int RequestCode = getNewIntentRequestCode(clazzSign);
                            if (RequestCode > 100) {
                                startActivityForResult(sectionActivity.getIntent(), RequestCode);
                            } else {
                                startActivity(sectionActivity.getIntent());
                            }
                            if (finishActivityOnNewIntent)
                                finish();
                        } catch (ClassNotFoundException e) {
                            e.printStackTrace();
                        }
                    }
                }, getSmoothPauseFromSelectingItem());
                closeDrawer();
            }
        } else {
            currentSectionFragment.select();
        }
    }
}
Also used : MaterialItemSectionActivity(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) Handler(android.os.Handler) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) SuppressLint(android.annotation.SuppressLint)

Aggregations

MaterialItemSectionActivity (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity)4 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)4 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 Fragment (android.support.v4.app.Fragment)3 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)3 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)3 MaterialItemDevisor (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor)3 SuppressLint (android.annotation.SuppressLint)1 Handler (android.os.Handler)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)1 MaterialSectionOnClickListener (de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionOnClickListener)1 MaterialItemCustom (de.madcyph3r.materialnavigationdrawer.menu.item.custom.MaterialItemCustom)1 MaterialItemSection (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)1 MaterialItemSectionOnClick (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionOnClick)1 MaterialItemLabel (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel)1