Chris Banes ActionBar-PullToRefresh

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

But how can I programmatically make refreshing animation (progress animation) start? Or how can I get a full update to start programmatically, as if I pulled out a layout?

I tried:

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

Nothing succeeded.

The only thing I need is to check on isRefreshingand stop it:

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

Please, help.

+3
source share
3 answers

Usually mPullToRefreshLayout.setRefreshing(true);works (if getWindow().getWindowToken != null). If this does not work, you can see my fork https://github.com/quxey/ActionBar-PullToRefresh

Edited. try it

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);
                    }
+3

, .

    if (fromTouch) {
        if (mOnRefreshListener != null) {
            mOnRefreshListener.onRefreshStarted(view);
        }
    }

startRefresh(View view, boolean fromTouch). fromTouch , . pulltorefresh - , fromTouch false, mOnRefreshListener.onRefreshStarted(view); . , . , , .

0

@AdamS made it simple here . One insert myRefreshableView.setRefreshing();I placed it in my fragment onResume(). It works, except that since I am doing this programmatically, I would like to update ref-refresh without rolling back .

0
source

All Articles