Here is my code setup:
Currently I have a Main Activity which then creates a spawns a fragment with getSupportFragmentManager()
. The Fragment contains a RecyclerView
(for a card view) as defined in the xml below:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity" >
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" />
</RelativeLayout>
And this is the layout of my main activity:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
...
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
The main activity instantiates the fragment which then creates its own RecyclerView, LinearLayoutManager, and Adapter
without any connections to the main activity.
The main activity creates the SwipeRefreshLayout as seen in the xml above.
The problem I have is the when I scroll up in my activity, once the list cannot scroll any further up the refresh indicator pulls down if I keep swiping down and refreshes. I don't want the indicator to pull down until I release the current touch and pull down again.
Since I cannot directly access the recycler view from my activity to add an OnScrollListener and enable and disable the SwipeRefreshLayout programmatically, how should I go about solving this?
All answers appreciated!