Set pull to update as an update when starting or resuming a fragment

I use this Android-PullToRefresh library: https://github.com/chrisbanes/Android-PullToRefresh

I need to implement an automatic "pull to refresh" when starting an activity, which has the same visual and functional effect as pushing a fragment that starts automatically, rather than user gestures. Do you know if I can do this?

EDIT: My code is below

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle saved)
{
    View view = inflater.inflate(R.layout.layout_frg_summarized, group, false);
    mPullToRefreshLayout = (PullToRefreshLayout) view.findViewById(R.id.summary_layout);
    ActionBarPullToRefresh.from(getActivity())
    .allChildrenArePullable()
    .listener(this)
    .setup(mPullToRefreshLayout);   

    return view;

}


@Override
public void onActivityCreated (Bundle savedInstanceState)
{
    super.onActivityCreated(savedInstanceState);

    //some code here

    mPullToRefreshLayout.isRefreshing();

}

@Override
public void onResume(){
    super.onResume();

    if (mPullToRefreshLayout.isRefreshing()) {
     mPullToRefreshLayout.setRefreshing(true);
    } 

}


@Override
public void onPause(){
    super.onPause();
    mPullToRefreshLayout.setRefreshing(false);
    if (mPullToRefreshLayout.isRefreshing()) {
        mPullToRefreshLayout.setRefreshComplete();
    } 


}
+4
source share
1 answer

Yes, you can.

As for the call onRefreshComplete(), there is a method setRefreshing():

myRefreshableView.setRefreshing();

Edit:

, onRefreshStarted , . , , . , , :

@Override
public void onRefreshStarted(View view) {
    startDownload();
}

, (, onResume):

@Override
public void onResume(){
    super.onResume();
    mPullToRefreshLayout.setRefreshing(true);
    startDownload();
}

isRefreshing() onActivityCreated - , , "" . , onResume , - , .

+6

All Articles