Paging Library loadAfter method called infinite in nested RecyclerView

Viewed 748

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>
0 Answers
Related