I'm using Horizontal ViewPager2 which has 4 fragments inside. Each fragment has SwipeRefreshLayout on a RecyclerView. The issue that I'm facing is that when RecyclerView is at top position then onClick on any item is list is not working. If I scroll the RecyclerView a bit down then onClick works fine. And when RecyclerView is at top position then if SwipeRefreshLayout is in refreshing state then onClick works fine. It seems SwipeRefreshLayout is conflicting with ViewPager2 in touch events. It works fine with simple ViewPager. What could be the actual problem and how can we handle it? Any ideas would be appreciable.
Thanks
xml:
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/fragment_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<include
android:id="@+id/headerPanel"
layout="@layout/home_header"
app:viewModel="@{viewModel}" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:paddingStart="@dimen/home_post_side_spacing"
android:paddingEnd="@dimen/home_post_side_spacing"
app:colorScheme="@{@color/fayvo_color}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/headerPanel"
app:onRefreshListener="@{() -> viewModel.manualRefresh()}"
app:refreshing="@{viewModel.isRefreshing}"
android:background="#f0f0f0">
<RelativeLayout
android:id="@+id/rl_rv"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_homePosts"
adapter="@{viewModel.postObservableArrayList}"
addToTop="@{viewModel.addToTop}"
clearList="@{viewModel.clearList}"
showLoader="@{viewModel.isPagingEnabled && viewModel.isLoading}"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<FrameLayout
android:id="@+id/emptyFrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="@{viewModel.showEmptyLayout?View.VISIBLE:View.GONE}" />
<include
android:id="@+id/postUploadProgressLayout"
layout="@layout/item_post_upload_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:viewModel="@{viewModel}" />
</RelativeLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<View
android:id="@+id/tooltipView"
android:layout_width="1dp"
android:layout_height=".1dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>