package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.CaseListResultBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.CaseListModelImpl;
import com.casic.dcms.mvp.view.ICaseListView;

public class CaseListPresenterImpl extends BasePresenter implements ICaseListPresenter, CaseListModelImpl.OnGetCaseListListener {

    private ICaseListView view;
    private CaseListModelImpl actionModel;

    public CaseListPresenterImpl(ICaseListView caseListView) {
        this.view = caseListView;
        actionModel = new CaseListModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String casetypeCode, String casetypeDetailCode, String caseState,
                                       String registerTimeBegin, String registerTimeEnd, String eorc, int offset) {
        view.showProgress();
        addSubscription(actionModel.sendRetrofitRequest(casetypeCode, casetypeDetailCode, caseState,
                registerTimeBegin, registerTimeEnd, eorc, offset));
    }

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

    @Override
    public void onSuccess(CaseListResultBean resultBean) {
        view.hideProgress();
        view.obtainCaseListData(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {
        view.hideProgress();
    }
}
