Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwipeRefreshLayout pull multiple times behaviour (SDK 23)

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:

enter image description here

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.

like image 304
Jemshit Iskenderov Avatar asked Sep 08 '15 07:09

Jemshit Iskenderov


Video Answer


2 Answers

"support-v4:23.1.0" already fixed this bug.

like image 160
Shen Jianchun Avatar answered Nov 10 '22 00:11

Shen Jianchun


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);
    }
}
like image 33
se.solovyev Avatar answered Nov 10 '22 00:11

se.solovyev