|
|
@ -6,6 +6,7 @@ import android.os.Process
|
|
|
|
import android.view.View
|
|
|
|
import android.view.View
|
|
|
|
import androidx.annotation.RequiresApi
|
|
|
|
import androidx.annotation.RequiresApi
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
|
|
|
|
import com.common.commonlib.db.DBUtils
|
|
|
|
import com.common.commonlib.utils.NetworkHelper
|
|
|
|
import com.common.commonlib.utils.NetworkHelper
|
|
|
|
import com.yinuo.library.vlc.IFrameCallBack
|
|
|
|
import com.yinuo.library.vlc.IFrameCallBack
|
|
|
|
import com.yinuo.library.vlc.RtspSurfaceRender2
|
|
|
|
import com.yinuo.library.vlc.RtspSurfaceRender2
|
|
|
@ -25,6 +26,7 @@ import com.yinuo.safetywatcher.watcher.utils.BatteryHelper
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.SimHelper
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.SimHelper
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.WifiHelper
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.WifiHelper
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
|
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
|
|
|
|
|
|
|
class HomeActivity : NoOptionsActivity() {
|
|
|
|
class HomeActivity : NoOptionsActivity() {
|
|
|
@ -105,11 +107,13 @@ class HomeActivity : NoOptionsActivity() {
|
|
|
|
//mHasSensorData = true
|
|
|
|
//mHasSensorData = true
|
|
|
|
mBinding.errorView.visibility =
|
|
|
|
mBinding.errorView.visibility =
|
|
|
|
if (!AppData.hasCameraData()) View.VISIBLE else View.GONE
|
|
|
|
if (!AppData.hasCameraData()) View.VISIBLE else View.GONE
|
|
|
|
val errorRes = if (!AppData.hasCameraData() && !AppData.hasSensorData()) R.drawable.ic_nosingal else R.drawable.ic_icon
|
|
|
|
val errorRes =
|
|
|
|
|
|
|
|
if (!AppData.hasCameraData() && !AppData.hasSensorData()) R.drawable.ic_nosingal else R.drawable.ic_icon
|
|
|
|
mBinding.errorView.setImageResource(errorRes)
|
|
|
|
mBinding.errorView.setImageResource(errorRes)
|
|
|
|
|
|
|
|
|
|
|
|
// tipView
|
|
|
|
// tipView
|
|
|
|
mBinding.tipView.visibility = if (!AppData.hasCameraData() && AppData.hasSensorData()) View.VISIBLE else View.GONE
|
|
|
|
mBinding.tipView.visibility =
|
|
|
|
|
|
|
|
if (!AppData.hasCameraData() && AppData.hasSensorData()) View.VISIBLE else View.GONE
|
|
|
|
mBinding.tipView.setImageBitmap(TxtOverlay.getOverlayBitmap())
|
|
|
|
mBinding.tipView.setImageBitmap(TxtOverlay.getOverlayBitmap())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -148,12 +152,39 @@ class HomeActivity : NoOptionsActivity() {
|
|
|
|
AppData.setSensorData(true)
|
|
|
|
AppData.setSensorData(true)
|
|
|
|
closeLoadingDialog()
|
|
|
|
closeLoadingDialog()
|
|
|
|
changeViewStatus()
|
|
|
|
changeViewStatus()
|
|
|
|
|
|
|
|
setWarnView()
|
|
|
|
watchSensor(DELAY_TIME_CHECK_SENSOR)
|
|
|
|
watchSensor(DELAY_TIME_CHECK_SENSOR)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
watchSensor(DELAY_TIME_CHECK_SENSOR)
|
|
|
|
watchSensor(DELAY_TIME_CHECK_SENSOR)
|
|
|
|
GasUtils.initPort()
|
|
|
|
GasUtils.initPort()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 设置告警视图展示
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private fun setWarnView() {
|
|
|
|
|
|
|
|
GlobalScope.launch {
|
|
|
|
|
|
|
|
val warningDao = DBUtils.warningDao()
|
|
|
|
|
|
|
|
val warningList = warningDao.queryWarningsNoEndTime()
|
|
|
|
|
|
|
|
val builder = StringBuilder()
|
|
|
|
|
|
|
|
warningList?.forEachIndexed { index, it ->
|
|
|
|
|
|
|
|
builder.append(it.gasName).append("浓度异常,")
|
|
|
|
|
|
|
|
.append("当前值: ${it.gasValue} ${it.unit}")
|
|
|
|
|
|
|
|
if (index != warningList.size - 1) {
|
|
|
|
|
|
|
|
builder.append("\n")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
launch(Dispatchers.Main) {
|
|
|
|
|
|
|
|
if (builder.toString().isNotEmpty()) {
|
|
|
|
|
|
|
|
mBinding.tvWarn.text = builder.toString()
|
|
|
|
|
|
|
|
mBinding.tvWarn.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
mBinding.tvWarn.visibility = View.GONE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 监视传感器
|
|
|
|
* 监视传感器
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|