mikepenz / MaterialDrawer

The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.
https://mikepenz.dev
Apache License 2.0
11.67k stars 2.05k forks source link

Expandable drawer item inside another expandable drawer item causes issues #2305

Closed hamzabinamin closed 6 years ago

hamzabinamin commented 6 years ago

About this issue

Details

Checklist

hamzabinamin commented 6 years ago

@mikepenz any help?

hamzabinamin commented 6 years ago

@spbisya @alorma Can anyone help please. I really need to figure this one out.

mikepenz commented 6 years ago

@hamzabinamin what are you doing? do you have sample code to showcase the issue ?

Did you check out the sample of the FastAdapter showcasing this too?

mikepenz commented 6 years ago

You can check out this FastAdapter sample having multiple nested levels: https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/ExpandableSampleActivity.java

hamzabinamin commented 6 years ago

@mikepenz , thanks for replying. I'm going to check the fast adapter. I have a question. Why do you we need the fast adapter? I thought it was used to help with recycler view? Can't I get multiple nested levels without using the fast adapter?

mikepenz commented 6 years ago

@hamzabinamin the FastAdapter is a adapter simplification implemented by me to streamline usage of it and eliminate boilerplate adapter code...

You write an item, and that one can instantly be used in a RecyclerView.

RecyclerView and their default adapter has no "logic" for collapsable items. This is just provided via the FastAdapter by me.

The MaterialDrawer uses the FastAdapter internally to allow me providing a super flexible easily enhanceable API. Items can be written and provided to the adapter / drawer without any changes in the main code

asafbennatan commented 6 years ago

@mikepenz happens here as well ,using the following: drawer->expandable(three)->expandable(three)->secondary(10) if we open all(it happens if the last one is open) the inner expandable , and close the outer expandable , the secondaries are not being closed , under some circumstances it duplicates the drawer items entries

hamzabinamin commented 6 years ago

@mikepenz My code looks like this

 result = new DrawerBuilder()
                .withActivity(this)
                .withToolbar(toolbar)
                .withHasStableIds(true)
                .withItemAnimator(new DefaultItemAnimator())
                .withAccountHeader(headerResult) //set the AccountHeader we created earlier for the header
                .addDrawerItems(
                        new PrimaryDrawerItem().withName(R.string.homeTitle).withIcon(R.drawable.house).withIdentifier(12).withSelectable(false),

        new ExpandableDrawerItem().withName(getString(R.string.categoriesTitle)).withIcon(R.drawable.carttwo).withIdentifier(19).withSelectable(false).withSubItems(
        new SecondaryDrawerItem().withName(getString(R.string.categoryFruit)).withLevel(2).withIdentifier(7).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categoryMeat)).withLevel(2).withIdentifier(8).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categoryDairy)).withLevel(2).withIdentifier(9).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categoryBakery)).withLevel(2).withIdentifier(10).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categorySnacks)).withLevel(2).withIdentifier(11).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categoryBeverages)).withLevel(2).withIdentifier(13).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categoryHealthBeauty)).withLevel(2).withIdentifier(14).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categoryPantry)).withLevel(2).withIdentifier(30).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categoryReadyToEat)).withLevel(2).withIdentifier(32).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categoryGems)).withLevel(2).withIdentifier(33).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categoryPets)).withLevel(2).withIdentifier(34).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categoryPersonalCare)).withLevel(2).withIdentifier(35).withSelectable(false),
        new SecondaryDrawerItem().withName(getString(R.string.categoryBeauty)).withLevel(2).withIdentifier(37).withSelectable(false),
        new ExpandableDrawerItem().withName(getString(R.string.categoryFood)).withLevel(2).withIdentifier(101).withSelectable(false).withSubItems(
                new SecondaryDrawerItem().withName(getString(R.string.categoryFoodShelf)).withLevel(3).withIdentifier(43).withSelectable(false),
                new SecondaryDrawerItem().withName(getString(R.string.categoryDriedNuts)).withLevel(3).withIdentifier(44).withSelectable(false),
                new SecondaryDrawerItem().withName(getString(R.string.categoryCereals)).withLevel(3).withIdentifier(45).withSelectable(false)
                ),

You mentioned that fast adapter is already being used by the drawer internally, so how do I fix my issue? If I keep the child expandable list open and close the parent list (categories here), it starts to show some items outside of categories, like in 2nd image.

hamzabinamin commented 6 years ago

@mikepenz could you help me with this please?