Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwipeRefreshLayout refresh conflict with fragmentTransactions

TLDR: here's my bug report : http://goo.gl/UgBFW2

Using a SwipeRefreshLayout if I press back and trigger either a getSupportFragmentManager().popBackstack(), super.onBackPressed() or fragmentTransaction.replace() right when the adapter triggers the views refresh, the two fragments overlap (a video showing the problem can be found in the top link).

I tried several things and adding a background is not a solution since the list fragment is in the foreground and the one clickable is the previous fragment.

Has anyone found a solution to this ?

Replacing Fragment does not work properly while swipeRefresh is running

like image 607
Cristen Avatar asked Apr 21 '15 13:04

Cristen


1 Answers

Add this to the fragment that contains the swipe

@Override
public void onPause() {
    super.onPause();
    if (swipeRefreshLayout!=null) {
        swipeRefreshLayout.setRefreshing(false);
        swipeRefreshLayout.destroyDrawingCache();
        swipeRefreshLayout.clearAnimation();
    }
}
like image 111
Kenny Orellana Avatar answered Nov 02 '22 07:11

Kenny Orellana