package com.tofly.ghrq_route.module.dasData;

import android.content.Context;

import com.mgq.base.utils.toast.ToastUtil;
import com.tofly.ghrq_route.base.BaseApp;
import com.tofly.ghrq_route.module.dasData.controller.DasDataCallBack;
import com.tofly.ghrq_route.module.dasData.controller.DasDataController;
import com.tofly.ghrq_route.module.dasData.domain.DasData;

import java.util.List;

/**
 * Created by Amu on 2017/4/26.
 */

public class DasDataTool {

    private static DasDataTool dasDataTool = null;

    private DasDataController dasDataController;

    private DasDataTool(){
        dasDataController = new DasDataController();
    }

    public static synchronized DasDataTool getInstance(){
        if (dasDataTool == null){
            dasDataTool = new DasDataTool();
        }
        return dasDataTool;
    }

    /**
     *  批量上传设备的数据采集信息
     */
    public void uploadDasDataBatch(Context context, List<DasData> dataList, DasDataCallBack dasDataCallBack) {
        dasDataController.uploadDasDataBatch(context, dataList, new DasDataCallBack() {
            @Override
            public void onSetData(boolean isSuccess, int errorCode, String errMsg) {
                super.onSetData(isSuccess, errorCode, errMsg);
                if (isSuccess) {

                } else {
                    errMsg = BaseApp.formatErrorMessage(errorCode, errMsg);
                    ToastUtil.showToast(context, errMsg);
                }

                if (dasDataCallBack != null){
                    dasDataCallBack.onSetData(isSuccess, errorCode, errMsg);
                }
            }
        });
    }
}
