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

Manually setting stickyContainer ViewGroup #179

Closed
borisdamato opened this issue Sep 30, 2016 · 3 comments
Closed

Manually setting stickyContainer ViewGroup #179

borisdamato opened this issue Sep 30, 2016 · 3 comments

Comments

@borisdamato
Copy link
Contributor

I'm implementing sticky headers to recyclerviews inside multiple fragments in a viewpager and as #70 points out, there are some problems between viewpager and stickyheader.

The solution I found myself is to extend the FlexibleAdapter class and pass it a ViewGroup object which will then be returned by the overridden getStickySectionHeadersHolder method.

I think this could be a good solution which should be included into the library itself.

I think we should add the method

private ViewGroup stickyContainer;

void setStickyContainer(@Nullable ViewGroup stickyContainer) {
    this.stickyContainer = stickyContainer;
}

and then modify the getStickySectionHeadersHolder method

public ViewGroup getStickySectionHeadersHolder() {
    if (stickyContainer != null) {
        return stickyContainer;
    } else {
        return (ViewGroup) Utils.scanForActivity(mRecyclerView.getContext()).findViewById(R.id.sticky_header_container);
    }
}

@davideas what do you think about it? I can make a pull request if you want

@davideas
Copy link
Owner

davideas commented Oct 4, 2016

@Aselox, thank you for this message, I will need to try myself this solution, in this period I'm quite busy, but in case, you will do a pull request after my tests.

@davideas
Copy link
Owner

davideas commented Oct 9, 2016

@Aselox, I think it is a good solution, you can create a PR.
Please, name the method setStickyHeaderContainer(). I will fix the get method name with the next deprecation release. Also, use mStickyContainer and return the FlexibleAdapter instance.

I will initially publish it as SNAPSHOT, then it will be released for the rc1.

@davideas
Copy link
Owner

davideas commented Dec 4, 2016

Be aware that, with the next Snapshot, the new just added set method will be deprecated as well.
The ViewGroup can be set while activating the stickyHeader, and most of the configuration will be automatic (no XML): No needs to specify the sticky header layout for ViewPager, etc..

There will be only a FrameLayout that wraps RV, but I'm trying to reparent the RV by creating the FrameLayout at runtime.

@borisdamato, if you have an idea how to reparent the RecyclerView, I will appreciate.

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

No branches or pull requests

2 participants