You can put the counter and call the update method only when this counter is greater than 0 (zero) and set the listener in the scroll event to set the value to 0 (zero), so every time the user views the list, the counter will be set to 0 ( zero), and when the list comes up and scrolls again, you call the refresh method.
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { if (countDelay > 0) { countDelay = 0; refresh(); } else { mSwipeRefreshLayout.setRefreshing(false); countDelay++; } } }); mSwipeRefreshLayout.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { countDelay = 0; } });
source share