package com.casic.dcms.mvp.presenter.impl;

import com.casic.dcms.bean.CaseHandledBean;
import com.casic.dcms.listener.OnGetCaseHandledListListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.CaseHandledListModelImpl;
import com.casic.dcms.mvp.presenter.ICaseListHandledPresenter;
import com.casic.dcms.mvp.view.ICaseListHandledView;

public class CaseListHandledPresenterImpl extends BasePresenter implements ICaseListHandledPresenter,
        OnGetCaseHandledListListener {

    private final ICaseListHandledView view;
    private final CaseHandledListModelImpl actionModel;

    public CaseListHandledPresenterImpl(ICaseListHandledView caseHandledListView) {
        this.view = caseHandledListView;
        actionModel = new CaseHandledListModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(int offset) {
        addSubscription(actionModel.sendCaseHandledListRequest(offset));
    }

    @Override
    public void disposeRetrofitRequest() {
        unSubscription();
    }

    @Override
    public void onSuccess(CaseHandledBean resultBean) {
        view.obtainCaseHandledList(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }
}
