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