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

import com.casic.dcms.bean.ActionResultBean;
import com.casic.dcms.listener.OnActionResultListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.UpdateSuperviseModelImpl;
import com.casic.dcms.mvp.presenter.IUpdateSupervisePresenter;
import com.casic.dcms.mvp.view.IUpdateSuperviseView;

public class UpdateSupervisePresenterImpl extends BasePresenter implements IUpdateSupervisePresenter,
        OnActionResultListener {

    private final IUpdateSuperviseView view;
    private final UpdateSuperviseModelImpl actionModel;

    public UpdateSupervisePresenterImpl(IUpdateSuperviseView updateSuperviseView) {
        this.view = updateSuperviseView;
        actionModel = new UpdateSuperviseModelImpl(this);
    }

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

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

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

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