package com.tofly.ghrq_route.module.troubleType.controller;

/**
 * Created by Amu on 2017/3/7.
 */

import android.content.Context;

import com.tofly.ghrq_route.module.OfflineWork.OfflineWorkTool;
import com.tofly.ghrq_route.module.troubleType.service.ITroubleTypeService;
import com.tofly.ghrq_route.module.troubleType.service.TroubleTypeServiceImpl;
import com.tofly.ghrq_route.module.troubleType.service.TroubleTypeServiceImplOffline;

/**
 * 隐患类型控制类
 */
public class TroubleTypeController {
    /**
     * 是否在綫
     */
    boolean mbOnline;
    /**
     * 上下文
     */
    Context mContext;
    /**
     * TroubleType接口实现对象
     */
    ITroubleTypeService troubleTypeService;

    public TroubleTypeController(Context context){
        mbOnline = true;
        mContext = context;
        troubleTypeService = new TroubleTypeServiceImpl(context);
    }

    private void setSignService(){
        boolean isOffline = OfflineWorkTool.isOffline();
        if (isOffline){
            troubleTypeService = new TroubleTypeServiceImplOffline(mContext);
        }else {
            troubleTypeService = new TroubleTypeServiceImpl(mContext);
        }
    }

    /**
     * 获取系统设备类型信息
     * @param token
     * @param troubleTypeCallBack
     */
    public void getSysDeviceTypeList(String token, TroubleTypeCallBack troubleTypeCallBack){
        setSignService();
        troubleTypeService.getSysDeviceTypeList(token, troubleTypeCallBack);
    }

    /**
     * 获取隐患类型信息列表
     * @param troubleTypeCallBack
     */
    public void getTroubleTypeList(Context context, int pageindex, int pagesize, final TroubleTypeCallBack troubleTypeCallBack){
        setSignService();
        troubleTypeService.getTroubleTypeList(context, pageindex, pagesize, troubleTypeCallBack);
    }

    /**
     * 获取隐患类风险等级列表
     * @param troubleTypeCallBack
     */
    public void getTroubleLevelList(Context context, int pageindex, int pagesize, final TroubleTypeCallBack troubleTypeCallBack) {
        setSignService();
        troubleTypeService.getTroubleRiskLevelList(context, pageindex, pagesize, troubleTypeCallBack);
    }

    /**
     *  获取管网类型列表
     */
    public void getPipeTypeList(Context context, int pageindex, int pagesize, TroubleTypeCallBack troubleTypeCallBack) {
        setSignService();
        troubleTypeService.getPipeTypeList(context, pageindex, pagesize, troubleTypeCallBack);
    }
}
