package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.CaseProcessBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.CaseProcessModelImpl;
import com.casic.dcms.mvp.view.ICaseProcessView;

public class CaseProcessPresenterImpl extends BasePresenter implements ICaseProcessPresenter, CaseProcessModelImpl.OnGetCaseProcessListener {

    private ICaseProcessView view;
    private CaseProcessModelImpl actionModel;

    public CaseProcessPresenterImpl(ICaseProcessView caseProcessView) {
        this.view = caseProcessView;
        actionModel = new CaseProcessModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String processId) {
        view.showProgress();
        addSubscription(actionModel.sendRetrofitRequest(processId));
    }

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

    @Override
    public void onSuccess(CaseProcessBean resultBean) {
        view.hideProgress();
        view.obtainCaseProcessData(resultBean);
    }

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