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

import com.casic.dcms.listener.OnGetLightDetailListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.LightDetailModelImpl;
import com.casic.dcms.mvp.presenter.ILightDetailPresenter;
import com.casic.dcms.mvp.view.ILightDetailView;

public class LightDetailPresenterImpl extends BasePresenter implements ILightDetailPresenter, OnGetLightDetailListener {

    private final ILightDetailView view;
    private final LightDetailModelImpl actionModel;

    public LightDetailPresenterImpl(ILightDetailView detailView) {
        this.view = detailView;
        actionModel = new LightDetailModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String lampId) {
        addSubscription(actionModel.sendLightDetailRequest(lampId));
    }

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

    @Override
    public void onSuccess(String resultJson) {
        view.obtainLightDetailResult(resultJson);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }
}
