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

import com.casic.dcms.bean.AlarmDataBean;
import com.casic.dcms.listener.OnGetAlarmListListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.AlarmListModelImpl;
import com.casic.dcms.mvp.presenter.IAlarmListPresenter;
import com.casic.dcms.mvp.view.IAlarmListView;

public class AlarmListPresenterImpl extends BasePresenter implements IAlarmListPresenter, OnGetAlarmListListener {

    private final IAlarmListView view;
    private final AlarmListModelImpl model;

    public AlarmListPresenterImpl(IAlarmListView alarmListView) {
        this.view = alarmListView;
        model = new AlarmListModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(int limit, int offset) {
        addSubscription(model.sendAlarmListRequest(limit, offset));
    }

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

    @Override
    public void onSuccess(AlarmDataBean resultBean) {
        view.obtainAlarmResult(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }
}
