PullLoadView icon indicating copy to clipboard operation
PullLoadView copied to clipboard

how to pullloadview from retrofit data

Open kickymaulana opened this issue 7 years ago • 3 comments

how to use pullloadview which the data is taken from retrofit data json

kickymaulana avatar Sep 23 '17 21:09 kickymaulana

异步网络请求,然后add到数据源 刷新适配器就好了 这根控件本身没关系,控件做的只是触发请求的时机。希望能帮到你理解这逻辑

tosslife avatar Sep 25 '17 10:09 tosslife

@tosslife I have been able to create the flow with retrofit and it works quite well. The only error I've seen with this is that if you do not add data to the adapter, but only call the setComplete method of the PullLoadView object, the progress object is not hidden, it remains in the view with the list empty.

eugenio1590 avatar Oct 11 '17 00:10 eugenio1590

My Fragment is this:

class CustomFragment extends Fragment {

    private PullToLoadView pullToLoadView;

    @Override
    protected void onCreateView(View view) {
        if (view instanceof PullToLoadView){
            pullToLoadView = (PullToLoadView) view;
            pullToLoadView.isLoadMoreEnabled(true);
            pullToLoadView.setPullCallback(mListener);
            ....
        }
    }

    public void initLoad(){
        pullToLoadView.initLoad();
    }

    public void setComplete(){
        pullToLoadView.setComplete();
    }
}

The error is replicated If I directly call the methods consecutively, like this:

@OnClick(R.id.fab)
public void onFabClick(View view) {
  fragment.initLoad();
  fragment.setComplete();
}

eugenio1590 avatar Oct 11 '17 02:10 eugenio1590