SwipeRefreshLayout and Update Status

I am struggling with documentation SwipeRefreshLayoutfrom the Google Support Library.

When I receive an update call using the callback installed setOnRefreshListener, I perform my action, and after that I find that I need to set the update status to false again - if I DO NOT do this, I can never run it again by checking!

    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    if (mSwipeRefreshLayout != null) {

        mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                Toast.makeText(getApplication(), "Refreshing!", Toast.LENGTH_SHORT).show();
                //requestDataRefresh();
                mSwipeRefreshLayout.setRefreshing(false);
            }
        });
    }

So far so good. But look at the documentation setRefreshing:

/**
 * Notify the widget that refresh state has changed. Do not call this when
 * refresh is triggered by a swipe gesture.
 *
 * @param refreshing Whether or not the view should show refresh progress.
 */
public void setRefreshing(boolean refreshing) {...

But setting the update status to false again is exactly what I have to do after the update!

Is the documentation wrong or am I seeing it wrong? Should the doctor rather say: "Do not call this with the updated state true when the update is started with a swipe gesture"?

?

+4
2

SwipeRefreshLayout setRefreshing(true) . setRefreshing(true) . , setRefreshing(true), SwipeRefreshLayout, , SwipeRefreshLayout. , setRefreshing(true) SwipeRefreshLayout , setRefreshing(false) . , .

+3

, , , , true, .

, , :

private void setRefreshing(final boolean refreshing) {
        if (mSwipeRefreshLayout != null) {
            mSwipeRefreshLayout.post(new Runnable() {
                @Override
                public void run() {
                    mSwipeRefreshLayout.setRefreshing(refreshing);
                }
            });
        }
    }
+1

All Articles