I have SwipeRefreshLayout
as like this:
.xml:
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<android.support.v7.widget.RecyclerView
android:id="@+id/haberRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
.java:
private SwipeRefreshLayout swipeLayout;
swipeLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_refresh_layout);
swipeLayout.setColorSchemeColors(getResources().getColor(R.color.primary_color));
swipeLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
refreshContent();
}
});
This allows me to pull swipeRefresh
multiple times and circling animation becomes weird, sometimes it stays on screen without circling:
On the first pull it appears a bit on top, on second pull it goes down a bit more as like on image.
How to disable multiple pull on SwipeRefresh
while it is already refreshing ?
I guess this does not happen below sdk 23. I am using buildTool 23, targetSdk 23, support-v4:23, appcompat-v7:23.
Update: this does not happen if i use ListView
instead of RecyclerView
.
"support-v4:23.1.0" already fixed this bug.
It looks like a bug in appcompat-v7 support library which was introduced in 23.0.0 release. As a workaround you can disable SwipeRefreshLayout in OnRefreshListener#onRefresh callback and enable it again when data is loaded:
private class MyOnRefreshListener implements SwipeRefreshLayout.OnRefreshListener {
@Override
public void onRefresh() {
swipeRefreshLayout.setEnabled(false);
load();
}
private void onLoaded() {
swipeRefreshLayout.setEnabled(true);
swipeRefreshLayout.setRefreshing(false);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With