omadahealth / SwipyRefreshLayout

A SwipeRefreshLayout extension that allows to swipe in both direction
MIT License
964 stars 220 forks source link

For short refreshes, spinner animation never really stops, completely freezes fragment in which it is used #40

Closed intrepidclass closed 8 years ago

intrepidclass commented 8 years ago

When you set the delay to 50ms instead of 2000 ms in MainActivity in the sample app, pull down to refresh, wait for the spinner to disappear, pull down again but don't let go, you'll notice the spinner is already spinning.

This consistently happens for me for short refreshes in my own app. An unfortunate side effect of this is that when I try to load a new fragment in place of the current one (which contains the listview + swipyrefresh) after a list item click, the fragment completely freezes, and my only option is to kill the app to get it to work again.

For now I've added a 800ms delay (500 + actual networking seemed to be enough already in my case) in my app, but this is a suboptimal workaround of course.

intrepidclass commented 8 years ago

Why was this issue closed?

oliveeyay commented 8 years ago

Sorry did not reproduce. If you find a solution don't hesitate to do a pull request and we can discuss it.

Cheers

intrepidclass commented 8 years ago

I'll see if I can find some time to look into this.

intrepidclass commented 8 years ago

This issue is fixed in 1.2.3 For anyone running into it though: If you switch out a fragment currently showing an animating refreshlayout with another fragment, the fragment will completely freeze. Same goes for the original SwipeRefreshLayout. You can prevent this from happening by stopping and clearing the animation in onPause() of your fragment:

@Override
public void onPause() {
    if (swipyRefreshLayout != null) {
        // Stop the refreshing animation, otherwise the fragment will completely freeze and remain that way until app restart.
        swipyRefreshLayout.setRefreshing(false);
        swipyRefreshLayout.destroyDrawingCache();
        swipyRefreshLayout.clearAnimation();
    }
    super.onPause();
}

(I got this solution from http://stackoverflow.com/questions/27057449/when-switch-fragment-with-swiperefreshlayout-during-refreshing-fragment-freezes )