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.OptionWellModelImpl;
import com.casic.dcms.mvp.presenter.IOptionWellPresenter;
import com.casic.dcms.mvp.view.IOptionWellView;

public class OptionWellPresenterImpl extends BasePresenter implements IOptionWellPresenter, OnActionResultListener {

    private final IOptionWellView view;
    private final OptionWellModelImpl actionModel;

    public OptionWellPresenterImpl(IOptionWellView optionWellView) {
        this.view = optionWellView;
        actionModel = new OptionWellModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String wellId, String bfzt) {
        view.showProgress();
        addSubscription(actionModel.sendSingleOptionRequest(wellId, bfzt));
    }

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

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

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

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