package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.ActionResultBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.UploadPositionModelImpl;
import com.casic.dcms.mvp.view.IUploadPositionView;

public class UploadPositionPresenterImpl extends BasePresenter implements IUploadPositionPresenter,
        UploadPositionModelImpl.OnUpdateListener {

    private IUploadPositionView view;
    private UploadPositionModelImpl actionModel;

    public UploadPositionPresenterImpl(IUploadPositionView uploadPositionView) {
        this.view = uploadPositionView;
        actionModel = new UploadPositionModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String imei, String positionLat, String positionLng) {
        addSubscription(actionModel.sendRetrofitRequest(imei, positionLat, positionLng));
    }

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

    @Override
    public void onFailure(Throwable throwable) {

    }

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