分页库的loadAfter方法在嵌套的RecyclerView中称为infinite

时间:2019-06-11 14:34:24

标签: android android-recyclerview android-paging nestedrecyclerview

我有一个RecyclerView(ParentRV),可以显示项目列表。每个子项(ViewHolder)是一个RecyclerView(ChildRV),用于呈现项列表。

然后,我实现了分页库以为ChildRV加载数据。问题在于,在我将从loadInitial()方法返回的结果更新到PagedListAdapter之后,分页库的DataSource不断无限调用loadAfter()方法。

请帮忙!这是ParentRV和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 个答案:

没有答案