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

import com.casic.dcms.bean.CaseProcessBean;
import com.casic.dcms.listener.OnGetCaseProcessListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.CaseProcessModelImpl;
import com.casic.dcms.mvp.presenter.ICaseProcessPresenter;
import com.casic.dcms.mvp.view.ICaseProcessView;

public class CaseProcessPresenterImpl extends BasePresenter implements ICaseProcessPresenter, OnGetCaseProcessListener {

    private final ICaseProcessView view;
    private final CaseProcessModelImpl actionModel;

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

    @Override
    public void onReadyRetrofitRequest(String processId) {
        view.showProgress();
        addSubscription(actionModel.sendCaseProcessRequest(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();
    }
}
