package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.ActionResultBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.CaseUpdateSuperviseModelImpl;
import com.casic.dcms.mvp.view.ICaseUpdateSuperviseView;

public class CaseUpdateSupervisePresenterImpl extends BasePresenter implements ICaseUpdateSupervisePresenter,
        CaseUpdateSuperviseModelImpl.OnUpdateSuperviseListener {

    private ICaseUpdateSuperviseView view;
    private CaseUpdateSuperviseModelImpl actionModel;

    public CaseUpdateSupervisePresenterImpl(ICaseUpdateSuperviseView updateSuperviseView) {
        this.view = updateSuperviseView;
        actionModel = new CaseUpdateSuperviseModelImpl(this);
    }

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

    @Override
    public void onSuccess(ActionResultBean resultBean) {
        view.hideProgress();
        view.obtainUpdateSuperviseData(resultBean);
    }

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

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