jeudi 7 mai 2015

swiprefreshlayout keep refreshing inside onscroll method

Im having a SwipeRefreshLayout and there's a listview inside it. I want to implement pull up to refresh(since swipe refresh only support pull down refresh), hence did a bit modification on the onscroll method of the list view

@Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, final int totalItemCount) {

                  if(firstVisibleItem + visibleItemCount >= totalItemCount && totalItemCount != 0 && !swipeRefreshLayout.isRefreshing() && pagecount > 0){
                      setRefresh();
                  }

//
            }

and in the setRefresh method I did this:

enter image description here

I even add a synchronized key word to restrict this method to be called once at a time, However, in my app I can see the refresh logo keep showing up very quickly and it turns out that the setRefresh keep calling.

I wonder how does it happen?

Aucun commentaire:

Enregistrer un commentaire