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

import com.casic.dcms.bean.ComSentenceBean;
import com.casic.dcms.listener.OnGetSentenceListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.ComSentenceModelImpl;
import com.casic.dcms.mvp.presenter.IComSentencePresenter;
import com.casic.dcms.mvp.view.ICommonSentenceView;

public class ComSentencePresenterImpl extends BasePresenter implements IComSentencePresenter, OnGetSentenceListener {

    private final ICommonSentenceView view;
    private final ComSentenceModelImpl actionModel;

    public ComSentencePresenterImpl(ICommonSentenceView sentenceView) {
        this.view = sentenceView;
        actionModel = new ComSentenceModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest() {
        addSubscription(actionModel.sendComSentenceRequest());
    }

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

    @Override
    public void onSuccess(ComSentenceBean resultBean) {
        view.obtainCommonSentenceData(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }
}
