Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New version of SwipeRefreshLayout causes wrong draw of views

I've got a ViewPager (backed by a AbstractBrowsePagerAdapter) composed of Fragments. Each fragment inflates a layout with a SwipeRefreshLayout as the root. I've recently updated to the support-v4:21.0.0 library. The new SwipeRefreshLayout uses a circle progress bar instead of the linear vertical progress bar as shown on the screenshot below.

When I pull to refresh, swipe right, create a new fragment in the ViewPager at the same index as the one where I pulled to refresh and then go to that new Fragment, the previous view still appears on top of my new content.

Bug with new SwipeRefreshLayout

As you can see on the screenshot, the "empty directory" textview and the "circle progressbar" are still appearing from the previous fragment that was destroyed.

  1. This only occurs when the SwipeRefreshLayout is in the loading state (the loader is displayed on the screen)
  2. This doesn't occur with the previous version of the SwipeRefreshLayout
  3. The hierarchyviewer tool doesn't work when the bug occurs. It works before, it works if i restart the application but doesn't work when in the bugging state.
  4. When I'm dumping the view with DDMS, the views from the previous fragment don't appear.

This seems like a bug in the new SwipeRefreshLayout but I couldn't find anybody having the same issue and it doesn't seem to be reported on https://code.google.com/p/android/issues/list?can=1&q=SwipeRefreshLayout&colspec=ID+Type+Status+Owner+Summary+Stars&cells=tiles

I'm looking for a workaround, forcing the views from the former fragment to be removed for good.

like image 245
Quanturium Avatar asked Dec 10 '14 21:12

Quanturium


1 Answers

I was able to solve this issue by calling clearAnimation() on the onPause() method of my Fragment

@Override
public void onPause() {
    swipeLayout.clearAnimation();
    super.onPause();
}
like image 101
Pyrmont Avatar answered Nov 05 '22 13:11

Pyrmont