How to disable pulltorefresh for the first time?

I am using chrisbanes Android-PullToRefresh in my application.

I need to disable the pulltorefresh function to start the first fragment - when the list is empty and the elements are loaded in the background. In this case (the list is empty), the user can scroll down, and the progress indicator with the indication "Release to refresh" will be shown.

After loading all the elements, I want to enable the pulltorefresh function.

How?

+6
source share
4 answers

I had the same problem.

According to the source, if viewing is disabled, it will not use the touch event.

https://github.com/chrisbanes/ActionBar-PullToRefresh/blob/master/library/src/uk/co/senab/actionbarpulltorefresh/library/PullToRefreshLayout.java#L137

simple you can do

mPullToRefreshLayout.setEnabled(false); 
+16
source

By default, you disable pull to update and enable asyncTask post execute when to populate the adapter list.

+1
source

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; } }); 
0
source

hope this help helps someone with the same problem:

 mRefreshableListView.setMode(PullToRefreshBase.Mode.DISABLED);//to disable the pull functionality mRefreshableListView.setMode(PullToRefreshBase.Mode.PULL_FROM_END);//or whatever you want 
-1
source

Source: https://habr.com/ru/post/958850/


All Articles