Android how to keep RecyclerView recycling inside ScrollView - android

I have three recyclerview inside a nestedscrollview and I need that the third one keep recycling like if he was out of the nestedscrollview.
It all goes great except the recycling feature is missing.
Here is my xml :
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/scroll_discovery"
android:fillViewport="true"
android:fitsSystemWindows="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/category_recycler"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/category_recycler"
android:id="#+id/user_recycler"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/user_recycler"
android:id="#+id/experiences"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
and here is the java part
experienceRecycler=(RecyclerView)findViewById(R.id.experiences);
experienceRecycler.setHasFixedSize(true);
mLayoutManager =new LinearLayoutManager(this) {
#Override
public boolean canScrollVertically() {
return false;
}
};
page= 1;
experienceRecycler.setLayoutManager(mLayoutManager);
experienceAdapter=new FeedCardAdapter(experiences,this,currentUser);
experienceRecycler.setAdapter(experienceAdapter);
/*experienceRecycler.addOnScrollListener(new RecyclerView.OnScrollListener() {
#Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
#Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
feedCardAdapter.setScrolled(true);
}
});*/
categoryRecycler=(RecyclerView)findViewById(R.id.category_recycler);
categoryRecycler.setLayoutManager(new LinearLayoutManager(this){
#Override
public boolean canScrollVertically() {
return false;
}
});
categoryAdapter=new CategoryAdapter(this,categories);
categoryRecycler.setHasFixedSize(true);
categoryRecycler.setAdapter(categoryAdapter);
userRecycler=(RecyclerView)findViewById(R.id.user_recycler);
userRecycler.setLayoutManager(new LinearLayoutManager(this){
#Override
public boolean canScrollVertically() {
return false;
}
});
userAdapter=new UserAdapter(this,users);
userRecycler.setAdapter(userAdapter);
userRecycler.setHasFixedSize(true);

I finaly find the solution by myself.
I just had a height to the recyclerview I want to keep recycling.

Related

Monitor ScrollView for recyclerview in android

How can I monitor RecyclerView's scroll whether it is scrolling up or down?
Is the below code a correct way to detect scrolling?
MessageRecyclerView.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
With the OnScrollListener.
Usage:
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
#Override
public void onScrollStateChanged(final RecyclerView recyclerView, final int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
#Override
public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) {
super.onScrolled(recyclerView, dx, dy);
}
});
Use OnScrollListener for this:
mMessageRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
#Override
public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) {
if (dy > 0) {
//scroll up
} else {
//scroll down
}
}
});
if you are using Recyclerview inside scrollview recyclerview scroll will not be smooth sometime becauseof recyclerview have default scroll. Instead of scroll use NestedScrollView.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/app_back">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/toprel"
android:layout_width="match_parent"
android:layout_height="140dp">
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"/>
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="bottom"
android:padding="10dip"
app:centered="true"
app:fillColor="#color/text_black_light"
app:pageColor="#ffffff"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/homecat_rec"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
android:layout_marginTop="#dimen/margin_4"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
and use yourrecyclerview.setNestedScrollingEnabled(false); in Activity class.

Make View scrolls along RecyclerView

Well, I'm trying to make a top bar like the one that is on Youtube's app. It works on almost all cases but when I use the ScrollListener from RecyclerView I get a problem.
As you can see the View doesn't change its position at certain moment when scrolled.
Here is my code:
rvTop.addOnScrollListener(new RecyclerView.OnScrollListener() {
#Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
LinearLayoutManager layoutManager = (LinearLayoutManager) layoutManagerTop;
if(filterTopAdapter.lastSelected >= layoutManager.findFirstVisibleItemPosition() && filterTopAdapter.lastSelected <= layoutManager.findLastVisibleItemPosition()) {
selectionLine.setVisibility(View.VISIBLE);
final View view = rvTop.findViewHolderForAdapterPosition(filterTopAdapter.lastSelected).itemView;
selectionLine.setTranslationX(view.getLeft() - rvTop.getScrollX());
Log.d("Scroll", String.valueOf(view.getLeft() - rvTop.getScrollX()));
}
else {
selectionLine.setVisibility(View.GONE);
}
}
#Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
LinearLayoutManager layoutManager = (LinearLayoutManager) layoutManagerTop;
if(filterTopAdapter.lastSelected >= layoutManager.findFirstVisibleItemPosition() && filterTopAdapter.lastSelected <= layoutManager.findLastVisibleItemPosition()) {
selectionLine.setVisibility(View.VISIBLE);
final View view = rvTop.findViewHolderForAdapterPosition(filterTopAdapter.lastSelected).itemView;
selectionLine.setTranslationX(view.getLeft() - rvTop.getScrollX());
Log.d("Scroll", String.valueOf(view.getLeft() - rvTop.getScrollX()));
}
else {
selectionLine.setVisibility(View.GONE);
}
}
});
You should try TabLayout with ViewPager
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="stellar.kade_c.com.MainActivity">
<android.support.design.widget.TabLayout
android:id="#+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable" />
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
You should use TabLayout with ViewPager for this

How to hide Floating Action Button on Nested Scroll

I'm trying to hide two FAB on Nested Scroll scrolling. I've tried to implement my own FAB behavior but it did't work. FAB's don't react on scrolling at all. Note: I deleted some part of layout to fit the post.
Layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="ru.berezin.maxim.im.budget_v3.userinterface.StartPage">
<android.support.design.widget.AppBarLayout
android:id="#+id/appcollapse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/testingscroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
app:behavior_overlapTop="30dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<!--content including-->
<include layout="#layout/start_content_layout"/>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/start_page_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:src="#drawable/plus"
app:layout_anchor="#id/testingscroll"
app:layout_anchorGravity="end|bottom"
app:layout_behavior="ru.berezin.maxim.im.budget_v3.FabOnScroll"
/>
<View
android:id="#+id/dummy"
android:layout_width="1dp"
android:layout_height="16dp"
app:layout_anchor="#id/start_page_fab"
app:layout_anchorGravity="top|right|end"
/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/account_det_add_transfer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|top"
android:layout_margin="16dp"
android:src="#drawable/minus"
app:layout_anchor="#id/dummy"
app:layout_anchorGravity="top|right|end"
app:layout_behavior="ru.berezin.maxim.im.budget_v3.FabOnScroll"
/>
</android.support.design.widget.CoordinatorLayout>
FabOnScroll class
public class FabOnScroll extends FloatingActionButton.Behavior {
public FabOnScroll(Context context, AttributeSet attrs) {
super();
}
#Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
//child -> Floating Action Button
if (dyConsumed > 0) {
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
int fab_bottomMargin = layoutParams.bottomMargin;
child.animate().translationY(child.getHeight() + fab_bottomMargin).setInterpolator(new LinearInterpolator()).start();
} else if (dyConsumed < 0) {
child.animate().translationY(0).setInterpolator(new LinearInterpolator()).start();
}
}
#Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View directTargetChild, View target, int nestedScrollAxes) {
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL;
}
}
So, I fixed it. Not exactly what I wanted, but it's working. I dont have any ideas why, but for some reason dyConsumed is always equals 0. But I noticed that dyUnconsumed is changing while I scroll. So I've just add dxUnconsumed check to my If/else statment and it's worked. Can someone explain why dyConsumed equals 0?
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener()
{
#Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
{
if (dy > 0 ||dy<0 && fab.isShown())
{
fab.hide();
}
}
#Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState)
{
if (newState == RecyclerView.SCROLL_STATE_IDLE)
{
fab.show();
}
super.onScrollStateChanged(recyclerView, newState);
}
});
I know it's a late answer but my solution is to use dyUnconsumed instead of dyConsumed inside the if statement and it worked very well with me
if (dyUnconsumed > 0 && child.getVisibility() == View.VISIBLE) {
child.hide(new FloatingActionButton.OnVisibilityChangedListener() {
#Override
public void onHidden(FloatingActionButton fab) {
super.onHidden(fab);
child.setVisibility(View.INVISIBLE);
}
});
} else if (dyUnconsumed <0 && child.getVisibility() != View.VISIBLE) {
child.show();
}

Recyclerview inside CoordinatorLayout - Endless scrolling issue

I have an issue with endless scrolling when recyclerview is used inside coordinatorlayout. Here is my main activity xml file:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"/>
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextColor="#android:color/white"
app:tabSelectedTextColor="#android:color/white"
app:tabIndicatorColor="#android:color/white"
app:tabIndicatorHeight="6dp"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fabButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/createlook"
android:layout_gravity="end|bottom"
android:layout_margin="#dimen/fab_margin"
app:borderWidth="0dp"
app:layout_behavior="com.abhishek.materialdesign.ScrollingFABBehavior" />
</android.support.design.widget.CoordinatorLayout>
The viewpager is setup to work with fragments. Here is fragment xml :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.abhishek.materialdesign.FirstFragment">
<!-- TODO: Update blank fragment layout -->
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/first_recycler_view">
</android.support.v7.widget.RecyclerView>
<ProgressBar
android:id="#+id/progress_bar"
style="?android:attr/progressBarStyleInverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:visibility="gone" />
<ProgressBar
android:id="#+id/progress_bar_paging"
style="?android:attr/progressBarStyleInverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
I want to achieve endless scrolling with above recyclerview. Here is the code:
private int visibleThreshold = 5;
int visibleItemCount, totalItemCount, firstVisibleItem ;
static boolean loadingMore = true;
static boolean noMoreDataOnServer = false;
private int previousTotal = 0;
firstRecyclerView = (RecyclerView)view.findViewById(R.id.first_recycler_view);
gridLayoutManager = new GridLayoutManager(getActivity(),2);
firstRecyclerView.setLayoutManager(gridLayoutManager);
firstRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener(){
#Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
// TODO Auto-generated method stub
super.onScrollStateChanged(recyclerView, newState);
}
#Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if(recyclerView.getAdapter() != null && !noMoreDataOnServer){
// mRecyclerViewHelper = RecyclerViewPositionHelper.createHelper(recyclerView);
visibleItemCount = firstRecyclerView.getChildCount();
totalItemCount = gridLayoutManager.getItemCount();
firstVisibleItem = gridLayoutManager.findFirstVisibleItemPosition();
if (loadingMore) {
if (totalItemCount > previousTotal) {
loadingMore = false;
previousTotal = totalItemCount;
}
}
if (!loadingMore && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {
// End has been reached
currentPage++;
new FetchMoviesData(currentPage).execute(movieType);
loadingMore = true;
}
}
}
});
The issue is that the block to fetch more data is executed multiple times when we haven't even begun scrolling.
Try This code.
#Override
public void onScrolled(RecyclerView recyclerViewa, int dx, int dy) {
super.onScrolled(recyclerViewa, dx, dy);
int th = 4;
int count = gridLayoutManager.getItemCount();
if (layoutManager1.findLastCompletelyVisibleItemPosition() >= count
- th) {
if (!loadingMore) {
loadingMore = true;
currentPage++;
new FetchMoviesData(currentPage).execute(movieType);
}
}
}
and inside onPostExecute() of FetchMoviesData make loadingMore false again.
protected void onPostExecute(String result) {
super.onPostExecute(result);
loading = false;
....
}
Happy Coding.

In nested recyclerview, child recyclerview's GridLayoutManager.getChildCount() gives total item count

I am using a RecyclerView inside SwipeRefreshLayout.The RecyclerView has another 2 RecyclerView (for now; it may increase). In my second RecyclerView i am trying to implement infinite scrolling. But my RecyclerView.getItemCount() and RecyclerView.getChildCount() are giving same value. Also the 2nd re has GridLayoutManager and GridlayoutManager.findFirstVisibleItemPosition() always gives 0 and GridLayoutManager.findLastVisibleItemPosition() always gives list size - 1 in OnScrolled of the RecyclerView. What is causing this and what should i do to implement the infinite scrolling.
fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_container"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="#dimen/padding_standard"
android:paddingBottom="#dimen/padding_standard">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
parent_recyclerview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:layout_marginBottom="#dimen/padding_standard"
android:orientation="vertical">
<TextView
android:id="#+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/padding_standard"
android:layout_marginBottom="#dimen/margin_standard"
android:textColor="#color/label_text"
android:textSize="#dimen/text_size_standard"
android:textStyle="bold"
tools:text="MOments"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/section_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"/>
<ProgressBar
android:id="#+id/events_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
</LinearLayout>
onScrollListener for child recycler view
RecyclerView.OnScrollListener scrollListener = new RecyclerView.OnScrollListener() {
#Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
GridLayoutManager manager = (GridLayoutManager) recyclerView.getLayoutManager();
int itemSize = manager.getItemCount();
int firstVisibleItem = manager.findFirstVisibleItemPosition();
int visibleChIldCount = manager.getChildCount();
Logger.e(TAG,"=============== START =====================");
Logger.e(TAG, "itemSize: " + itemSize);
Logger.e(TAG, "firstVisibleitem: " + firstVisibleItem);
Logger.e(TAG, "visibleChIldCount: " + visibleChIldCount);
Logger.e(TAG,"mLayoutManager.firstCOmpletely: "+ manager.findFirstCompletelyVisibleItemPosition());
Logger.e(TAG,"mLayoutManager. lastcompletey: "+ manager.findLastCompletelyVisibleItemPosition());
Logger.e(TAG,"mLayoutManager.findLastVisible: "+ manager.findLastVisibleItemPosition());
Logger.e(TAG,"=================END ================");
if (itemSize >= firstVisibleItem + visibleChIldCount){
Logger.e("", "loading");
mLoadMoreListener.loadMore();
} else {
Logger.e(TAG, "not Loading");
}
}
};
Sorry for the late reply. But i will post my solution here if in case someone else is looking for them.
In the adapter of the parent recycler view i have set tag for the view
#Override
public SectionRowHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mLayoutInflater.inflate(R.layout.view_section, parent, false);
view.setTag(viewType);
return new SectionRowHolder(view);
}
The SectionRowHolder is simple ViewHolder with a RecyclerView.OnScrollListener property with getter and setter.
public class SectionRowHolder extends RecyclerView.ViewHolder {
protected RecyclerView recyclerView;
RecyclerView.OnScrollListener mOnScrollListener;
public SectionRowHolder(View view) {
super(view);
this.recyclerView = (RecyclerView) view.findViewById(R.id.section_list);
}
public RecyclerView.OnScrollListener getCustomScrollListener() {
return mOnScrollListener;
}
public void setCustomScrollListener(RecyclerView.OnScrollListener mOnScrollListener) {
this.mOnScrollListener = mOnScrollListener;
}
}
Then in the onBindViewHolder for the child with infinite scrolling I have implemented the load more logic in scroll listener and set to the child RecyclerView.
RecyclerView.OnScrollListener scrollListener = new RecyclerView.OnScrollListener() {
boolean loadEnable = false;
#Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
mTotalScrolled += dy;
if ((mTotalScrolled + LOAD_MORE_ENABLE_HEIGHT) > recyclerView.getHeight() && loadEnable) {
loadEnable = false;
mLoadMoreListener.loadMore();
} else {
loadEnable = true;
}
}
};
holder.setCustomScrollListener(scrollListener);
holder.recyclerView.addOnScrollListener(scrollListener);
Here LOAD_MORE_ENABLE_HEIGHT is offset from bottom of the child recycler view to initialize the loadmore() logic and mLoadMoreListener is callback to the fragment or activity.
Finally for passing the scoll listener from parent recycler view to the child recycler vew, in my parent RecyclerView's onScrollListener
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
#Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
View v = mRecyclerView.findViewWithTag(CHILD_RECYCLERVIEW_TAG);
SectionedLifeAtAdapter.SectionRowHolder viewHolder =
(SectionedLifeAtAdapter.SectionRowHolder) mRecyclerView
.findContainingViewHolder(v);
if (viewHolder.getCustomScrollListener() != null)
viewHolder.getCustomScrollListener().onScrolled((RecyclerView) v
.findViewById(R.id.section_list), dx, dy);
Logger.e(TAG, ">>> call to on scrolled listener >>>");
}
});
Here CHILD_RECYCLERVIEW_TAG is the view type that you set in the onCreateViewHolder of the parent Adapter.
It kind of look like messy but it did the job for me without any issues.

Categories

Resources