Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FastAdapter Branch] Sometimes subitems are duplicated in the main list #926

Closed
justjanne opened this issue Jan 8, 2016 · 13 comments
Closed
Assignees
Labels

Comments

@justjanne
Copy link

See this example: http://imgur.com/a/OMbI3

Expanded and collapsed.

For the nth parent item in the list, the n last children are duplicated.

@mikepenz
Copy link
Owner

mikepenz commented Jan 8, 2016

@justjanne could you please add the code how you generate those items?

@mikepenz mikepenz self-assigned this Jan 8, 2016
@justjanne
Copy link
Author

This is inside the DemoActivity class I use to test the drawer:

public static class Parent extends PrimaryDrawerItem {
    public Parent(String name, List<IDrawerItem> children) {
        super();
        withName(name);
        withSubItems(children);
    }
}

public static class Child extends SecondaryDrawerItem {
    public Child(String name) {
        super();
        withName(name);
    }
}

static final ArrayList<IDrawerItem> LIST = new ArrayList<>(Arrays.asList(
            new Parent("Freenode", Arrays.asList(
                    new Child("##political_chat"),
                    new Child("##politics"),
                    new Child("#amarok"),
                    new Child("#android-dev"),
                    new Child("#kde"),
                    new Child("#quassel")
            )),
            new Parent("HackInt", Arrays.asList(
                    new Child("#32c3"),
                    new Child("#33c3"),
                    new Child("#ffki"),
                    new Child("#toppoint"),
                    new Child("#voc-lounge")
            )),
            new Parent("QuakeNet", Arrays.asList(
                    new Child("#frozen"),
                    new Child("#yepityha"),
                    new Child("gal"),
                    new Child("NK33"),
                    new Child("Sapphi"),
                    new Child("staffehn"),
                    new Child("voluhy")
            ))
    ));

protected void onCreate(Bundle savedInstanceState) {
        // Here I left out some initialization stuff
        drawer = new DrawerBuilder()
                .withActivity(this)
                .withToolbar(toolbar)
                .withHasStableIds(true)
                .withDrawerItems(LIST)
                .withAccountHeader(header)
                .withOnDrawerItemClickListener((view, position, drawerItem) -> {
                    if (drawerItem != null) {
                        if (((ICollapsible) drawerItem).getSubItems() != null) {
                            drawer.getAdapter().toggleCollapsible(position);
                        } else {
                            // Navigate there
                        }
                        return true;
                    }
                    return false;
                })
                .build();
}

All very plain, very simple code, nothing advanced yet.

@justjanne justjanne mentioned this issue Jan 8, 2016
@mikepenz
Copy link
Owner

mikepenz commented Jan 8, 2016

just tried it. can't reproduce it with the following items

ArrayList<IDrawerItem> LIST = new ArrayList<IDrawerItem>(Arrays.asList(
            new Parent("1. Freenode", Arrays.<IDrawerItem>asList(
                    new Child("1.2.1. ##political_chat"),
                    new Child("1.2.2. ##politics"),
                    new Child("1.2.3. #amarok"),
                    new Child("1.2.4. #android-dev"),
                    new Child("1.2.5. #kde"),
                    new Child("1.2.6. #quassel")
            )),
            new Parent("2. HackInt", Arrays.<IDrawerItem>asList(
                    new Child("2.2.1. #32c3"),
                    new Child("2.2.2. #33c3"),
                    new Child("2.2.3. #ffki"),
                    new Child("2.2.4. #toppoint"),
                    new Child("2.2.5. #voc-lounge")
            )),
            new Parent("3. QuakeNet", Arrays.<IDrawerItem>asList(
                    new Child("3.2.1. #frozen"),
                    new Child("3.2.2. #yepityha"),
                    new Child("3.2.3. gal"),
                    new Child("3.2.4. NK33"),
                    new Child("3.2.5. Sapphi"),
                    new Child("3.2.6. staffehn"),
                    new Child("3.2.7. voluhy")
            ))
    ));

add numbers so i can directly see when there are duplicates

could it probably happend that there are issues with the code updating the items?

@mikepenz
Copy link
Owner

mikepenz commented Jan 8, 2016

Just had one thought. it may also can happens because the subItems do not have an identifier and for those the IdDistributor does not provide automatically genereted id's. and this may cause display errors or update errors

@justjanne
Copy link
Author

I don’t update the items at all currently – and even if I give the items a unique identifier withIdentifier(UUID.randomUUID().hashCode()) I still get duplicates.

I’ll put the code on GitHub, wait a minute.

@mikepenz
Copy link
Owner

mikepenz commented Jan 8, 2016

you don't update them. what else do you do. do you click anything special. i can't reproduce it with the above items.

@justjanne
Copy link
Author

Here’s the source: https://github.com/justjanne/TestApplication

@mikepenz
Copy link
Owner

mikepenz commented Jan 8, 2016

@justjanne thanks. i will test it now

@justjanne
Copy link
Author

@mikepenz The issue seems to disappear when I remove the AccountHeader – and reappear when I add it again.
Maybe you’re forgetting to count that somewhere?

@justjanne
Copy link
Author

Can you replicate the issue?

@mikepenz
Copy link
Owner

mikepenz commented Jan 8, 2016

@justjanne yes. i can replicate the issue. and i just commit and push the solution ;)

@justjanne
Copy link
Author

Thanks!

@mikepenz
Copy link
Owner

mikepenz commented Jan 8, 2016

new snapshot 5.0.0.fastAdapter.b5-SNAPSHOT

Thanks for you help tracking down this bug ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants