I have a SwipeRefreshLayout embedding a RecyclerView
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/catalog_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
I'd like it to trigger the refresh only when I start pulling down from the top of the scrollable area.
If I'm scrolling though the top of the content, when I reach the top still pulling down, it's not supposed to chain with the refresh, that's another intention.
How can I prevent the refresh to trigger when I didn't start the pull down from the top of the content ? Is there an option for that or do I need to cancel it from the refresh listener in some way ?
You can add a listener to the
RecyclerViewto know when the moving state isDRAGGINGorIDLE, and use this to allow the swipeRefresh to happen only if the RV is not DRAGGING by saving the condition in aBoolean(i.e. canRefresh), so you know the list is not scrolling, hence, you can refresh.You can disable the
SwipeRefreshLayoutwithisEnabled = false, this won't stop the list or its items functionality, just theSwipeRefreshLayout