package com.casic.endoscope.utils import com.casic.endoscope.base.BaseApplication import com.casic.endoscope.bean.GasValueBean import com.pengxh.kt.lite.extensions.timestampToTime class DataBaseManager private constructor() { companion object { //Kotlin委托模式双重锁单例 val get by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { DataBaseManager() } } private var gasValueBeanDao = BaseApplication.get().getDaoSession().gasValueBeanDao fun loadAll(): List<GasValueBean> { return gasValueBeanDao.loadAll() } fun saveGasDensity(density: Int) { val bean = GasValueBean() bean.value = density bean.time = System.currentTimeMillis().timestampToTime() gasValueBeanDao.insert(bean) } }