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

import com.casic.dcms.bean.LightListBean;
import com.casic.dcms.listener.OnGetLightListListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.LightListModelImpl;
import com.casic.dcms.mvp.presenter.ILightListPresenter;
import com.casic.dcms.mvp.view.ILightListView;

public class LightListPresenterImpl extends BasePresenter implements ILightListPresenter, OnGetLightListListener {

    private final ILightListView view;
    private final LightListModelImpl actionModel;

    public LightListPresenterImpl(ILightListView lightListView) {
        this.view = lightListView;
        actionModel = new LightListModelImpl(this);
    }

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

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

    @Override
    public void onSuccess(LightListBean resultBean) {
        view.obtainLightResult(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }
}
