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

Headers are shown multiple times #355

Closed
long1eu opened this issue May 6, 2017 · 5 comments
Closed

Headers are shown multiple times #355

long1eu opened this issue May 6, 2017 · 5 comments
Labels

Comments

@long1eu
Copy link
Contributor

long1eu commented May 6, 2017

ezgif-3-eb77d37d19
I switched to this wonderful lib. I spend whole day reading docs. But still I have this issue. Headers are displays above every item.

As always the code is here:
https://github.com/thelong1EU/FlipViewDemo

@davideas
Copy link
Owner

davideas commented May 6, 2017

@thelong1EU, UserHeader must be the same instance for each section, so you should NOT create new header object for each sectionable item in your use case.

Thanks, I've updated the Wiki with better explanation.

@long1eu
Copy link
Contributor Author

long1eu commented May 7, 2017 via email

@long1eu
Copy link
Contributor Author

long1eu commented May 7, 2017

I changed it in the mock app and it works. But on my real app it doesn't. I get the same result. I think I found the reason. In the FlexibleAdapter there is the method showAllHeadersWithReset(). Here you check if the headers are the same instance. Why not try equals? My Item and Header are Parcelable. So when I pass them in an Intent they are recreated and are not the same instance anymore.

Should I make a pull request?

private void showAllHeadersWithReset(boolean init) {
        int position = 0;
        IHeader sameHeader = null;
        while (position < getItemCount() - mScrollableFooters.size()) {
            T item = mItems.get(position);
            // Reset hidden status! Necessary after the filter and the update
            IHeader header = getHeaderOf(item);

            //should be !header.equals(sameHeader)
            if (header != sameHeader && header != null && !isExpandable((T) header)) {
                sameHeader = header;
                header.setHidden(true);
            }
            if (showHeaderOf(position, item, init))
                position++; //It's the same element, skip it
            position++;
        }
        headersShown = true;
    }

Where are you from? I really want to give you a beer.

@davideas
Copy link
Owner

davideas commented May 7, 2017

Hi @thelong1EU, I didn't think about Parcelable, sometimes we write a feature without seeing all the user points of views for development, some can be missed. The improvement can be done.

I'm Italian living in Brussels. for the beer I will check about donations, because you are not the first, neither second that would like to, I appreciate it :-D

@long1eu long1eu closed this as completed May 7, 2017
@long1eu long1eu reopened this May 7, 2017
@long1eu
Copy link
Contributor Author

long1eu commented May 7, 2017

Added fix to #357, so I'm closing this.
Thanks again.

@long1eu long1eu closed this as completed May 7, 2017
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