优化
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.Inbound"
|
android:theme="@style/Theme.Inbound"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
|
android:largeHeap="true"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
<!-- 注册BootReceiver,监听开机完成广播 -->
|
<!-- 注册BootReceiver,监听开机完成广播 -->
|
||||||
<receiver
|
<receiver
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.sw.inbound.activity
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -16,6 +17,8 @@ import androidx.core.view.updateLayoutParams
|
|||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import coil.ImageLoader
|
||||||
|
import coil.annotation.ExperimentalCoilApi
|
||||||
import com.sw.inbound.R
|
import com.sw.inbound.R
|
||||||
import com.sw.inbound.adapter.FoodCollectionAdapter
|
import com.sw.inbound.adapter.FoodCollectionAdapter
|
||||||
import com.sw.inbound.adapter.GoodsSearchAdapter
|
import com.sw.inbound.adapter.GoodsSearchAdapter
|
||||||
@@ -62,8 +65,8 @@ class FoodCollectionActivity : ComponentActivity() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "FoodCollectionActivity"
|
const val TAG = "FoodCollectionActivity"
|
||||||
const val MAX_COUNT = 102
|
const val MAX_COUNT = 16
|
||||||
val PAGE_SIZE = 30
|
const val PAGE_SIZE = 30
|
||||||
}
|
}
|
||||||
|
|
||||||
private var box: Box<Food>? = null
|
private var box: Box<Food>? = null
|
||||||
@@ -131,7 +134,7 @@ class FoodCollectionActivity : ComponentActivity() {
|
|||||||
cameraUtils.setPreviewController(previewView)
|
cameraUtils.setPreviewController(previewView)
|
||||||
binding.btnBack.setOnClickListener { finish() }
|
binding.btnBack.setOnClickListener { finish() }
|
||||||
binding.rvFoodCollection.let {
|
binding.rvFoodCollection.let {
|
||||||
it.layoutManager = GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false)
|
it.layoutManager = GridLayoutManager(this, 4, GridLayoutManager.VERTICAL, false)
|
||||||
it.adapter = collectionAdapter
|
it.adapter = collectionAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,6 +254,9 @@ class FoodCollectionActivity : ComponentActivity() {
|
|||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
private fun clearData() {
|
private fun clearData() {
|
||||||
|
val count = collectList.count { it.imageFile !=null }
|
||||||
|
if (count == 0) return
|
||||||
|
clearCoilCache(this)
|
||||||
collectList.forEach {
|
collectList.forEach {
|
||||||
try {
|
try {
|
||||||
if (it.bitmap?.isRecycled?.not() == true) {
|
if (it.bitmap?.isRecycled?.not() == true) {
|
||||||
@@ -574,6 +580,19 @@ class FoodCollectionActivity : ComponentActivity() {
|
|||||||
tvTip?.text = tip
|
tvTip?.text = tip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除Coil缓存
|
||||||
|
*/
|
||||||
|
@OptIn(ExperimentalCoilApi::class)
|
||||||
|
fun clearCoilCache(context: Context) {
|
||||||
|
val imageLoader = ImageLoader.Builder(context).build()
|
||||||
|
// 清除内存缓存
|
||||||
|
imageLoader.memoryCache?.clear()
|
||||||
|
// 清除磁盘缓存
|
||||||
|
imageLoader.diskCache?.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
data class RespData(
|
data class RespData(
|
||||||
var code: String? = null,
|
var code: String? = null,
|
||||||
var data: String? = null,
|
var data: String? = null,
|
||||||
|
|||||||
@@ -164,6 +164,9 @@ abstract class GoodsListActivity : ComponentActivity() {
|
|||||||
binding.btnClearZero.setOnClickListener {
|
binding.btnClearZero.setOnClickListener {
|
||||||
SensorScaleUtils.tare()
|
SensorScaleUtils.tare()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//val array = arrayOf("1","2","qwe")
|
||||||
|
//Timber.tag(TAG).d("测试:${array[2].toInt()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
private var weightCallback: ((weight: Int) -> Unit)? = null
|
private var weightCallback: ((weight: Int) -> Unit)? = null
|
||||||
@@ -183,7 +186,7 @@ abstract class GoodsListActivity : ComponentActivity() {
|
|||||||
binding.tvTotalWeight.text = "重量:${weight}克"
|
binding.tvTotalWeight.text = "重量:${weight}克"
|
||||||
}
|
}
|
||||||
if (weight < 200) {
|
if (weight < 200) {
|
||||||
if (abs(weight) < 10) {
|
if (weight < 10) {
|
||||||
// val clazzName = DialogManager.getDialogList()
|
// val clazzName = DialogManager.getDialogList()
|
||||||
// .map { it.javaClass.simpleName }
|
// .map { it.javaClass.simpleName }
|
||||||
// .joinToString(",")
|
// .joinToString(",")
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import android.view.ViewGroup
|
|||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import coil.load
|
import coil.load
|
||||||
|
import coil.transform.CircleCropTransformation
|
||||||
|
import coil.transform.RoundedCornersTransformation
|
||||||
import com.chad.library.adapter4.BaseQuickAdapter
|
import com.chad.library.adapter4.BaseQuickAdapter
|
||||||
import com.chad.library.adapter4.viewholder.QuickViewHolder
|
import com.chad.library.adapter4.viewholder.QuickViewHolder
|
||||||
import com.sw.inbound.R
|
import com.sw.inbound.R
|
||||||
@@ -34,14 +36,21 @@ class FoodCollectionAdapter (var list: MutableList<FoodCollectionBean>) :
|
|||||||
binding.ivDelete.visibility = if (it.isShowCamera) View.GONE else View.VISIBLE
|
binding.ivDelete.visibility = if (it.isShowCamera) View.GONE else View.VISIBLE
|
||||||
binding.imageView.run {
|
binding.imageView.run {
|
||||||
if (it.isShowCamera) {
|
if (it.isShowCamera) {
|
||||||
|
load(null)
|
||||||
|
postDelayed({
|
||||||
scaleType = ImageView.ScaleType.CENTER
|
scaleType = ImageView.ScaleType.CENTER
|
||||||
setImageResource(R.mipmap.ic_camera256)
|
setImageResource(R.mipmap.ic_camera256)
|
||||||
|
},100)
|
||||||
} else {
|
} else {
|
||||||
scaleType = ImageView.ScaleType.FIT_CENTER
|
scaleType = ImageView.ScaleType.FIT_CENTER
|
||||||
//setImageURI(it.imageUri)
|
//setImageURI(it.imageUri)
|
||||||
//load(it.bitmap)
|
// load(it.bitmap)
|
||||||
// setImageBitmap(it.bitmap!!)
|
// setImageBitmap(it.bitmap!!)
|
||||||
setImageURI(it.imageFile?.toUri())
|
//setImageURI(it.imageFile?.toUri())
|
||||||
|
load(it.imageFile?.toUri()) {
|
||||||
|
crossfade(true)
|
||||||
|
transformations(RoundedCornersTransformation(5f,5f,5f,5f))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.sw.inbound.utils.CameraUtils
|
|||||||
import com.sw.inbound.utils.ImageUtil
|
import com.sw.inbound.utils.ImageUtil
|
||||||
import com.sw.inbound.utils.ext.dp
|
import com.sw.inbound.utils.ext.dp
|
||||||
import com.sw.inbound.utils.ext.gone
|
import com.sw.inbound.utils.ext.gone
|
||||||
|
import com.sw.inbound.utils.ext.hideKeyboard
|
||||||
import com.sw.inbound.utils.ext.toast
|
import com.sw.inbound.utils.ext.toast
|
||||||
import com.sw.inbound.utils.ext.visible
|
import com.sw.inbound.utils.ext.visible
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
@@ -152,6 +153,7 @@ class AddGoodsDialog(
|
|||||||
block: (DictType) -> Unit = {}
|
block: (DictType) -> Unit = {}
|
||||||
) {
|
) {
|
||||||
dropdownView.setOnClickListener { v ->
|
dropdownView.setOnClickListener { v ->
|
||||||
|
v.hideKeyboard()
|
||||||
dropdownList.clear()
|
dropdownList.clear()
|
||||||
val tempList =
|
val tempList =
|
||||||
list.filter { it.id.isNullOrBlank().not() && it.value.isNullOrBlank().not() }
|
list.filter { it.id.isNullOrBlank().not() && it.value.isNullOrBlank().not() }
|
||||||
|
|||||||
@@ -115,12 +115,12 @@ fun TopTitleBar(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.combinedClickable(
|
// modifier = Modifier.combinedClickable(
|
||||||
onClick = {},
|
// onClick = {},
|
||||||
onLongClick = {
|
// onLongClick = {
|
||||||
onLogoutClick()
|
// onLogoutClick()
|
||||||
}
|
// }
|
||||||
),
|
// ),
|
||||||
text = currentTime,
|
text = currentTime,
|
||||||
style = TextStyle(
|
style = TextStyle(
|
||||||
fontWeight = FontWeight.Medium,
|
fontWeight = FontWeight.Medium,
|
||||||
|
|||||||
@@ -203,19 +203,28 @@ class CrashHandler private constructor(private val context: Context) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveCrashInfoToFile(crashInfo: String) {
|
private fun saveLog(logInfo:String) {
|
||||||
try {
|
|
||||||
val time = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.getDefault()).format(Date())
|
val time = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.getDefault()).format(Date())
|
||||||
val fileName = "crash_$time.log"
|
val fileName = "crash_$time.log"
|
||||||
|
|
||||||
val crashDir = getCrashDir()
|
val crashDir = getCrashDir()
|
||||||
|
|
||||||
val crashFile = File(crashDir, fileName)
|
val crashFile = File(crashDir, fileName)
|
||||||
FileOutputStream(crashFile).use { it.write(crashInfo.toByteArray()) }
|
FileOutputStream(crashFile).use { it.write(logInfo.toByteArray()) }
|
||||||
|
|
||||||
Timber.tag(TAG).d("Crash info saved to: ${crashFile.absolutePath}")
|
Timber.tag(TAG).d("Crash info saved to: ${crashFile.absolutePath}")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun saveCrashInfoToFile(crashInfo: String) {
|
||||||
|
try {
|
||||||
|
saveLog(crashInfo)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.tag(TAG).e(e, "Error saving crash info to file")
|
Timber.tag(TAG).e(e, "Error saving crash info to file")
|
||||||
|
try {
|
||||||
|
saveLog("Error saving crash info to file:${e.message}")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Timber.tag(TAG).e(e, "save exception")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class PhotoCaptureHelper(
|
|||||||
|
|
||||||
}
|
}
|
||||||
Timber.e(exception, errorMsg)
|
Timber.e(exception, errorMsg)
|
||||||
onError(errorMsg)
|
onError("拍照失败")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="200dp"
|
android:layout_height="170dp"
|
||||||
android:background="@drawable/bg_gray"
|
android:background="@drawable/bg_gray"
|
||||||
android:layout_margin="5dp"
|
android:layout_margin="5dp"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
@@ -18,8 +18,7 @@
|
|||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:layout_gravity="end|top"
|
android:layout_gravity="end|top"
|
||||||
android:paddingTop="10dp"
|
android:padding="13dp"
|
||||||
android:paddingBottom="10dp"
|
|
||||||
android:src="@mipmap/ic_delete_red"/>
|
android:src="@mipmap/ic_delete_red"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
Reference in New Issue
Block a user