fix(spraying): 优化喷涂OCR和结果页面功能
- 在拍照前取消倒计时避免内存泄漏 - 将结果页面倒计时从10秒调整为5秒 - 结果页面跳转后自动关闭当前页面释放资源 - 更新结果页面使用专用的ViewModel和水平滚动布局 - 替换适配器使用菜单项布局并添加拍照、结束任务等功能选项 - 移除背景颜色配置文件中的填充色属性 - 新增照片选择器正常状态背景和菜单项布局文件
这个提交包含在:
父节点
cc7a72f098
当前提交
96303ebc35
@ -53,6 +53,8 @@ class SprayingOCRActivity :
|
||||
}
|
||||
|
||||
fun takePhoto() {
|
||||
resultCountdown?.cancel()
|
||||
resultCountdown = null
|
||||
val fileName = "test_${System.currentTimeMillis()}.png"
|
||||
val publicPicturesDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
||||
val file = File(publicPicturesDir, fileName)
|
||||
@ -137,7 +139,7 @@ class SprayingOCRActivity :
|
||||
|
||||
private fun restartResultCountdown(path: String) {
|
||||
resultCountdown?.cancel()
|
||||
resultCountdown = object : CountDownTimer(10_000, 1_000) {
|
||||
resultCountdown = object : CountDownTimer(5_000, 1_000) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
}
|
||||
|
||||
@ -145,6 +147,7 @@ class SprayingOCRActivity :
|
||||
startActivity(Intent(this@SprayingOCRActivity, SprayingResultActivity::class.java).apply {
|
||||
putExtra("path", path)
|
||||
})
|
||||
finish()
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
@ -6,12 +6,11 @@ import android.os.Environment
|
||||
import android.view.WindowManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.nova.brain.glass.R
|
||||
import com.nova.brain.glass.databinding.ActivitySprayingBinding
|
||||
import com.nova.brain.glass.databinding.ActivitySprayingResultBinding
|
||||
import com.nova.brain.glass.helper.OfflineCmdListener
|
||||
import com.nova.brain.glass.helper.OfflineCmdServiceHelper
|
||||
import com.nova.brain.glass.model.ItemItem
|
||||
import com.nova.brain.glass.viewmodel.SprayingVM
|
||||
import com.nova.brain.glass.viewmodel.SprayingResultVM
|
||||
import com.rokid.security.glass3.open.sdk.GlassSdk
|
||||
import com.rokid.security.glass3.sdk.base.data.media.PhotoResolution
|
||||
import com.rokid.security.system.server.media.callback.PhotoFileCallback
|
||||
@ -25,11 +24,11 @@ import java.io.File
|
||||
import java.util.UUID
|
||||
|
||||
class SprayingResultActivity :
|
||||
BaseListFormLayoutNormalActivity<ItemItem, SprayingVM, ActivitySprayingResultBinding>() {
|
||||
BaseListFormLayoutNormalActivity<ItemItem, SprayingResultVM, ActivitySprayingResultBinding>() {
|
||||
override fun getLayoutId(): Int = R.layout.activity_spraying_result
|
||||
override fun fullscreen(): Boolean = true
|
||||
|
||||
override fun getRecyclerOrientation(): Int = RecyclerView.VERTICAL
|
||||
override fun getRecyclerOrientation(): Int = RecyclerView.HORIZONTAL
|
||||
|
||||
private val listener = object : OfflineCmdListener {
|
||||
override fun onOfflineCmd(cmd: String) {
|
||||
@ -85,7 +84,10 @@ class SprayingResultActivity :
|
||||
"相机异常".showMessage()
|
||||
}
|
||||
} else {
|
||||
startActivity(Intent(this@SprayingResultActivity, SprayingOCRActivity::class.java).apply {
|
||||
startActivity(
|
||||
Intent(
|
||||
this@SprayingResultActivity, SprayingOCRActivity::class.java
|
||||
).apply {
|
||||
putExtra("path", path)
|
||||
})
|
||||
finish()
|
||||
@ -111,18 +113,33 @@ class SprayingResultActivity :
|
||||
}
|
||||
|
||||
private var isPhoto = false
|
||||
private val adapter = object : CommonPagedAdapter<ItemItem>(R.layout.item_photo) {
|
||||
private val adapter = object : CommonPagedAdapter<ItemItem>(R.layout.item_menu) {
|
||||
override fun convert(holder: ViewHolder, item: ItemItem, position: Int) {
|
||||
holder
|
||||
holder.setText(
|
||||
when (position) {
|
||||
1 -> R.id.text
|
||||
else -> R.id.text2
|
||||
}, item.text
|
||||
)
|
||||
.setVisibility(when (position) {
|
||||
1 -> R.id.da
|
||||
else -> R.id.xiao
|
||||
},true)
|
||||
.setClickListener(R.id.photo) {
|
||||
when (item.text) {
|
||||
"拍照" -> {
|
||||
"继续拍摄" -> {
|
||||
runOnUiThread {
|
||||
binding.hint.text = "拍照中,请稍后..."
|
||||
}
|
||||
isPhoto = true
|
||||
takePhoto()
|
||||
}
|
||||
|
||||
"结束任务" -> {
|
||||
}
|
||||
|
||||
"人工更正结果" -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package com.nova.brain.glass.viewmodel
|
||||
|
||||
import com.nova.brain.glass.model.ItemItem
|
||||
import com.xuqm.base.viewmodel.BaseListViewModel
|
||||
import com.xuqm.base.viewmodel.callback.Response
|
||||
|
||||
class SprayingResultVM: BaseListViewModel<ItemItem>() {
|
||||
override fun loadData(
|
||||
page: Int,
|
||||
onResponse: Response<ItemItem>
|
||||
) {
|
||||
onResponse.onResponse(arrayListOf<ItemItem>().apply {
|
||||
add(ItemItem("继续拍摄"))
|
||||
add(ItemItem("结束任务"))
|
||||
add(ItemItem("人工更正结果"))
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#1040FF5E" />
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#ff40FF5E" />
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true" android:drawable="@drawable/bg_photo"/>
|
||||
<item android:state_focused="false" android:drawable="@drawable/bg_photo_normal"/>
|
||||
</selector>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="44dp" />
|
||||
</shape>
|
||||
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#1040FF5E" />
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#ff40FF5E" />
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="160dp"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/photo"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/bg_task_list"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center">
|
||||
<LinearLayout
|
||||
android:id="@+id/da"
|
||||
android:visibility="gone"
|
||||
android:layout_width="94dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/bg_photo_l"
|
||||
android:layout_height="94dp"
|
||||
android:layout_gravity="center">
|
||||
<LinearLayout
|
||||
android:layout_width="88dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/bg_photo"
|
||||
android:layout_height="88dp"
|
||||
android:layout_gravity="center">
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="24.5dp"
|
||||
android:src="@mipmap/paizhao"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textColor="#4AFE59"
|
||||
android:id="@+id/text"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="开始任务"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="94dp"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/xiao"
|
||||
android:visibility="gone"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/bg_photo_l"
|
||||
android:layout_height="94dp"
|
||||
android:layout_gravity="center">
|
||||
<LinearLayout
|
||||
android:layout_width="60dp"
|
||||
android:background="@drawable/bg_photo"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:layout_height="60dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@mipmap/paizhao"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textColor="#4AFE59"
|
||||
android:id="@+id/text2"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="开始任务"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
正在加载...
在新工单中引用
屏蔽一个用户