localhost localhost - 5 months ago 24
Android Question

Chris Banes ActionBar-PullToRefresh

Im using Chris Banes ActionBar-PullToRefresh.
I can start refreshing by pulling the layout down - everything is fine.

But how can i programmatically force start refreshing animation (progress animation)? Or how can i force start full refreshing programmatically like if i pull the layout down?

Tried:

mPullToRefreshLayout.startLayoutAnimation();
mPullToRefreshLayout.setRefreshing(true);
mPullToRefreshLayout.setActivated(true);


Nothing worked.

The only thing i got to work is check for
isRefreshing
and stop it:

if(mPullToRefreshLayout.isRefreshing()){
mPullToRefreshLayout.setRefreshComplete();
}


Please help.

Answer

Usually mPullToRefreshLayout.setRefreshing(true); is working (if getWindow().getWindowToken != null). If that's not working , you can see my fork https://github.com/quxey/ActionBar-PullToRefresh

Edited . Try this

final ViewGroup decorView = (ViewGroup)getActivity().getWindow().getDecorView();
                    if(decorView.getWindowToken() == null){
                    decorView.post(new Runnable() {
                                @Override
                                public void run() {
                                    if (decorView.getWindowToken() != null) {
                                        mPullToRefreshLayout.setRefreshing(true);
                                    } else {
                                        decorView.post(this);
                                    }
                                }
                            });
                    }else{
                    mPullToRefreshLayout.setRefreshing(true);
                    }
Comments