ksoichiro / Android-ObservableScrollView

Android library to observe scroll events on scrollable views.
http://ksoichiro.github.io/Android-ObservableScrollView/
Apache License 2.0
9.66k stars 2.06k forks source link

StaggeredGridLayoutManager ObservableRecyclerView #223

Open SamJonson opened 8 years ago

SamJonson commented 8 years ago

Whether the ObservableRecyclerView support to use StaggeredGridLayoutManager?

ksoichiro commented 8 years ago

I haven't tried but if the current ObservableRecyclerView cannot handle StaggeredGridLayoutManager, I'd like to make it support. Do you have any specific problems with StaggeredGridLayoutManager?

SamJonson commented 8 years ago

First of all Thanks for this open project. The function that i need just as the FlexibleSpaceWithImageWithViewPagerTabActivity in the open source projects. (The different fragments in the viewPager all use the RecyclerVie but with the different LayoutManager.it contains the StaggeredGridLayoutManager and LinearLayoutManager.) the problem just as bellow when i using the StaggeredGridLayoutManager and LinearLayoutManager: 1.the custom recyclerAdapter need to support the different rows base on the using StaggeredGridLayoutManager or LinearLayoutManager(it's easy,just as you have done); 2.the scrollY in ObservableRecyclerView, i can't sure it's accuracy.so i use the bellow method:

if (0 == mStatusBarHeight) {
        mStatusBarHeight = ScreenUtils.getStatusBarHeight(mContext);
    }

    View firstView = getChildAt(0);
    firstView.getLocationOnScreen(mScrollInfo);
    int headerToTop = mStatusBarHeight - mScrollInfo[1];

    if (mCallbacks != null) {
        mCallbacks.onScrollChanged(headerToTop, firstScroll, dragging);
    }

3.when you switch the viewPager,the slidingTab in the fragment that has less content will sliding to the wrong position. I support what i said may be not quite right. Also please see understanding. Finally, Thanks again for the open source project and your reply.

ksoichiro commented 8 years ago

Thanks for your reply. Maybe the each items managed by StaggeredGridLayoutManager have different height, and ObservableRecyclerView can't handle that correctly, I think. I'll consider whether there is a solution for it.

eneim commented 8 years ago

Hm, Adapter in RecyclerView should not have any access to Layout measurement but the LayoutManager should do them, I suppose. So in any case you want to support those LayoutManager, consider to extends default layout manager and provide extended access.