3

I have a RecyclerView (ParentRV) that render a list of items. Each child item (ViewHolder) is a RecyclerView (ChildRV) that render a list of items.

Then I implement the Paging Library to load data for ChildRV. The problem is the Paging library's DataSource keeps calling loadAfter() method infinitely after I update the result that returned from loadInitial() method to PagedListAdapter.

Any help please! Here are layouts for ParentRV and ChildRV.

parent_layout.xml

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white">

        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true">

                // ....

        </com.google.android.material.appbar.AppBarLayout>


        <com.example.ecommerce.presentation.widget.RefreshLayout
            android:id="@+id/refreshLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">


            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/sectionList"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clipToPadding="false" />


        </com.example.ecommerce.presentation.widget.RefreshLayout>


    </androidx.coordinatorlayout.widget.CoordinatorLayout>

</layout>

child_layout.xml

<layout xmlns:android="http://schemas.android.com/apk/res/android">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/productList"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </FrameLayout>
</layout>
Hoang Lam
  • 523
  • 8
  • 23
  • 1
    I think you need to put `adapter.setHasFixedSize(true)`. https://stackoverflow.com/questions/30079438/how-do-i-layout-nested-recyclerviews-while-remaining-performant Also, if the both the RecyclerView (parent and child) have vertical orientation, it's better to use only one RecyclerView with different view types. – Froyo Jun 11 '19 at 14:47
  • @Froyo I've tried but still not working. – Hoang Lam Jun 12 '19 at 02:15
  • No one has the same problem like me? I think this is the common case with nested recyclerview. – Hoang Lam Jun 18 '19 at 16:19
  • I had same issue, how to solve this? method loadAfter keep calling when first call, without scroll to bottom – Nanda Z Dec 14 '19 at 05:55
  • Phew I am also stuck with this problem – Martin Mbae Sep 02 '21 at 10:11

0 Answers0