|
|
|
@ -3,6 +3,7 @@ package org.easydarwin
|
|
|
|
|
import android.graphics.Bitmap
|
|
|
|
|
import android.graphics.Color
|
|
|
|
|
import android.text.TextUtils
|
|
|
|
|
import android.util.Log
|
|
|
|
|
import com.common.commonlib.db.entity.Gas
|
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
|
@ -10,6 +11,7 @@ import kotlinx.coroutines.delay
|
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
import org.easydarwin.util.YUVUtils
|
|
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by John on 2017/2/23.
|
|
|
|
@ -81,8 +83,10 @@ object TxtOverlay {
|
|
|
|
|
private val overlayBuilder: StringBuilder = java.lang.StringBuilder()
|
|
|
|
|
private var looping = false
|
|
|
|
|
|
|
|
|
|
private val gasMap = ConcurrentHashMap<String, Gas>()
|
|
|
|
|
// 外部调用,设置待显示水印文字
|
|
|
|
|
fun startShow(gasMap: HashMap<String, Gas>) {
|
|
|
|
|
fun startShow(gas: Gas) {
|
|
|
|
|
gasMap[gas.gasName] = gas
|
|
|
|
|
if (!looping) {
|
|
|
|
|
looping = true
|
|
|
|
|
GlobalScope.launch(Dispatchers.IO) {
|
|
|
|
@ -91,9 +95,9 @@ object TxtOverlay {
|
|
|
|
|
overlayBuilder.clear()
|
|
|
|
|
gasMap.forEach { item ->
|
|
|
|
|
val gas = item.value
|
|
|
|
|
val time = gas.time
|
|
|
|
|
// 3S内的数据我们认为有效
|
|
|
|
|
if (currentTimeMillis - time <= 3000) {
|
|
|
|
|
Log.i("cyy", "time = ${dateFormat.format(currentTimeMillis)} gasTime = ${dateFormat.format(gas.time)}")
|
|
|
|
|
if (currentTimeMillis - gas.time <= 3000) {
|
|
|
|
|
overlayBuilder.append("${gas.gasName}: ${gas.gasValue} ${gas.unit}")
|
|
|
|
|
.append("@")
|
|
|
|
|
}
|
|
|
|
|