2

a ViewPager which has 3 Fragment(A,B,C),the FragmentA has a SwipeRefreshLayout,for delay-loaded

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
           new Handler().postDelayed(new Runnable() {
               @Override
               public void run() {
                   //before refresh the item is "000000"
                   //change Data and notify
                   //after is "111111"
                   adapter.update(data);
               }
           },3000);
        }
    });
}
  1. when it refreshing , slide the viewpager to FragmentC ,
  2. after 3000 return to FragmentA ,
  3. then refresh the SwipeRefreshLayout, the "000000" and "111111" are overlapped.

But if I use the same code in onCreateView ,not use SwipeRefreshLayout

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    //……
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            //before refresh the item is "000000"
            //change Data and notify
            //after is "111111"
            adapter.update(data);
        }
    }, 3000);
}

it will not overlapped, the item is "111111",I think it is the right result. When I slide to FragmentC,the FragmentA will execute onDestroyView.(Does it leak memory in ViewPager?)Why does the old view not destroy when I use SwipeRefreshLayout for delay-loaded?

enter image description here

Sorry for my English.

yexiaohu
  • 103
  • 1
  • 5
  • Yes. This is a bug of SwipeRefreshLayout. See the workaround [here](http://stackoverflow.com/questions/27057449/when-switch-fragment-with-swiperefreshlayout-during-refreshing-fragment-freezes). – hqzxzwb Nov 26 '16 at 03:25

0 Answers0