feat(spraying-result): 添加OCR识别结果显示功能
- 引入Paint类用于文本样式处理 - 添加status变量控制识别状态显示 - 实现setStatusImage方法设置OCR识别结果UI - 根据识别结果更新任务标题和状态图标 - 对不合格项目添加删除线样式效果 - 在布局文件中添加状态显示相关控件ID
这个提交包含在:
父节点
dc199db79e
当前提交
daa92ba0e1
@ -2,6 +2,7 @@ package com.nova.brain.glass.ui
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
|
import android.graphics.Paint
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@ -29,7 +30,7 @@ class SprayingResultActivity :
|
|||||||
override fun fullscreen(): Boolean = true
|
override fun fullscreen(): Boolean = true
|
||||||
|
|
||||||
override fun getRecyclerOrientation(): Int = RecyclerView.HORIZONTAL
|
override fun getRecyclerOrientation(): Int = RecyclerView.HORIZONTAL
|
||||||
|
private var status = true
|
||||||
private val listener = object : OfflineCmdListener {
|
private val listener = object : OfflineCmdListener {
|
||||||
override fun onOfflineCmd(cmd: String) {
|
override fun onOfflineCmd(cmd: String) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
@ -63,9 +64,11 @@ class SprayingResultActivity :
|
|||||||
GlassSdk.getGlassMediaService()
|
GlassSdk.getGlassMediaService()
|
||||||
?.takePhoto(PhotoResolution.RESOLUTION_480P, file.absolutePath)
|
?.takePhoto(PhotoResolution.RESOLUTION_480P, file.absolutePath)
|
||||||
}
|
}
|
||||||
fun rest(){
|
|
||||||
|
fun rest() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val photoCallbackId = UUID.randomUUID().toString()
|
private val photoCallbackId = UUID.randomUUID().toString()
|
||||||
|
|
||||||
private val mPhotoFileCallback = object : PhotoFileCallback.Stub() {
|
private val mPhotoFileCallback = object : PhotoFileCallback.Stub() {
|
||||||
@ -109,9 +112,22 @@ class SprayingResultActivity :
|
|||||||
GlassSdk.getGlassMediaService()?.addPhotoCallback(mPhotoFileCallback)
|
GlassSdk.getGlassMediaService()?.addPhotoCallback(mPhotoFileCallback)
|
||||||
intent.getStringExtra("path")?.apply {
|
intent.getStringExtra("path")?.apply {
|
||||||
binding.iv.setImageBitmap(BitmapFactory.decodeFile(this))
|
binding.iv.setImageBitmap(BitmapFactory.decodeFile(this))
|
||||||
|
setStatusImage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun setStatusImage(){
|
||||||
|
binding.tvTaskHeader.text = if (status) "OCR识别结果:合格" else "OCR识别结果:不合格"
|
||||||
|
binding.status.setImageResource(if (status) R.mipmap.ocr_true else R.mipmap.ocr_false)
|
||||||
|
if (status){
|
||||||
|
binding.value1.paintFlags = binding.value1.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
||||||
|
binding.value2.paintFlags = binding.value2.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
||||||
|
binding.value3.paintFlags = binding.value3.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
||||||
|
}else{
|
||||||
|
binding.value1.paintFlags = binding.value1.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
|
||||||
|
binding.value2.paintFlags = binding.value2.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
|
||||||
|
binding.value3.paintFlags = binding.value3.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
|
||||||
|
}
|
||||||
|
}
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
OfflineCmdServiceHelper.removeOnLineListener(listener)
|
OfflineCmdServiceHelper.removeOnLineListener(listener)
|
||||||
@ -127,10 +143,12 @@ class SprayingResultActivity :
|
|||||||
else -> R.id.text2
|
else -> R.id.text2
|
||||||
}, item.text
|
}, item.text
|
||||||
)
|
)
|
||||||
.setVisibility(when (position) {
|
.setVisibility(
|
||||||
|
when (position) {
|
||||||
1 -> R.id.da
|
1 -> R.id.da
|
||||||
else -> R.id.xiao
|
else -> R.id.xiao
|
||||||
},true)
|
}, true
|
||||||
|
)
|
||||||
.setClickListener(R.id.photo) {
|
.setClickListener(R.id.photo) {
|
||||||
when (item.text) {
|
when (item.text) {
|
||||||
"继续拍摄" -> {
|
"继续拍摄" -> {
|
||||||
|
|||||||
@ -62,6 +62,7 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/value1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="识码一:XXXXX"
|
android:text="识码一:XXXXX"
|
||||||
@ -69,6 +70,7 @@
|
|||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/value2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
@ -77,6 +79,7 @@
|
|||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/value3"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
@ -88,6 +91,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/status"
|
||||||
android:layout_width="90dp"
|
android:layout_width="90dp"
|
||||||
android:layout_height="90dp"
|
android:layout_height="90dp"
|
||||||
android:src="@mipmap/ocr_true"
|
android:src="@mipmap/ocr_true"
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户