优化
This commit is contained in:
@@ -14,6 +14,7 @@ import androidx.core.view.updateLayoutParams
|
||||
import com.shuwei.intelligent.shelves.utils.ext.appendText
|
||||
import com.shuwei.intelligent.shelves.utils.ext.buildSpannableString
|
||||
import com.sw.inbound.GlobalData
|
||||
import com.sw.inbound.R
|
||||
import com.sw.inbound.databinding.ActivityGoodsListBinding
|
||||
import com.sw.inbound.databinding.LayoutCameraPreviewBinding
|
||||
import com.sw.inbound.databinding.ListItemReceiptGoodsBinding
|
||||
@@ -113,11 +114,14 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
list = dropdownList,
|
||||
popHeight = min(355.dp, dropdownList.size * 71.dp)
|
||||
) {
|
||||
binding.cvDropdownBg.setCardBackgroundColor(Color.TRANSPARENT)
|
||||
binding.tvWareHouse.run {
|
||||
text = it.value
|
||||
tag = it.id
|
||||
}
|
||||
}.also {
|
||||
it.arrowImage = binding.ivDropdown
|
||||
it.bgLayout = binding.flWarehouseDropdown
|
||||
it.defLayoutBgResId = R.drawable.bg_white_radius10_stroke
|
||||
}
|
||||
}
|
||||
dropdownPopup?.showAsDropDown(v)
|
||||
@@ -432,6 +436,7 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
fun receiptSubmit() {
|
||||
if (binding.tvWareHouse.tag == null) {
|
||||
toast("请选择仓库")
|
||||
binding.flWarehouseDropdown.setBackgroundResource(R.drawable.bg_white_stroke_red)
|
||||
return
|
||||
}
|
||||
goodsList.forEach { goodsInfo ->
|
||||
@@ -462,7 +467,7 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
fun selfProcurementSubmit() {
|
||||
if (binding.tvWareHouse.tag == null) {
|
||||
toast("请选择仓库")
|
||||
binding.cvDropdownBg.setCardBackgroundColor(Color.RED)
|
||||
binding.flWarehouseDropdown.setBackgroundResource(R.drawable.bg_white_stroke_red)
|
||||
return
|
||||
}
|
||||
if (goodsList.isEmpty()) {
|
||||
|
||||
@@ -5,11 +5,13 @@ import android.net.Uri
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.camera.view.PreviewView
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import coil.load
|
||||
import com.sw.inbound.GlobalData
|
||||
import com.sw.inbound.R
|
||||
import com.sw.inbound.activity.GoodsListActivity
|
||||
import com.sw.inbound.databinding.DialogAddGoodsBinding
|
||||
import com.sw.inbound.databinding.LayoutCameraPreviewBinding
|
||||
@@ -107,6 +109,7 @@ class AddGoodsDialog(
|
||||
showDropDownList(
|
||||
binding.flProcurementUnit,
|
||||
textView = binding.tvProcurementUnit,
|
||||
arrowImage = binding.ivProcurementArrow,
|
||||
list = GlobalData.unitTypeList,
|
||||
height = 2*71.dp
|
||||
)
|
||||
@@ -118,11 +121,13 @@ class AddGoodsDialog(
|
||||
showDropDownList(
|
||||
binding.flStorageType,
|
||||
textView = binding.tvStorageType,
|
||||
arrowImage = binding.ivStorageArrow,
|
||||
list = GlobalData.storageTypeList,
|
||||
)
|
||||
showDropDownList(
|
||||
dropdownView = binding.flWarehouseUnit,
|
||||
textView = binding.tvWarehouseUnit,
|
||||
arrowImage = binding.ivWarehouseArrow,
|
||||
list = GlobalData.unitTypeList,
|
||||
height = 3*71.dp
|
||||
) {
|
||||
@@ -134,11 +139,12 @@ class AddGoodsDialog(
|
||||
private fun showDropDownList(
|
||||
dropdownView: FrameLayout,
|
||||
textView: TextView,
|
||||
arrowImage: ImageView,
|
||||
list: List<DictType>,
|
||||
height: Int = 355.dp,
|
||||
block: (DictType) -> Unit = {}
|
||||
) {
|
||||
dropdownView.setOnClickListener {
|
||||
dropdownView.setOnClickListener {v->
|
||||
dropdownList.clear()
|
||||
val tempList =
|
||||
list.filter { it.id.isNullOrBlank().not() && it.value.isNullOrBlank().not() }
|
||||
@@ -159,6 +165,9 @@ class AddGoodsDialog(
|
||||
tag = it.id
|
||||
}
|
||||
block(it)
|
||||
}.also {
|
||||
it.arrowImage = arrowImage
|
||||
it.bgLayout = dropdownView
|
||||
}
|
||||
dropdownPopup?.showAsDropDown(dropdownView)
|
||||
dropdownPopup?.setOnDismissListener {
|
||||
|
||||
@@ -63,7 +63,13 @@ class CollectSearchDialog(
|
||||
}
|
||||
}
|
||||
binding.btnConfirm.setOnClickListener {
|
||||
dismiss()
|
||||
if (clickIndex == -1) {
|
||||
dismiss()
|
||||
return@setOnClickListener
|
||||
}
|
||||
deleteGoods(clickIndex) {
|
||||
it.postDelayed({dismiss()}, 500)
|
||||
}
|
||||
}
|
||||
binding.rvSearch.let {
|
||||
it.layoutManager = GridLayoutManager(context, 2, LinearLayoutManager.VERTICAL, false)
|
||||
@@ -115,44 +121,54 @@ class CollectSearchDialog(
|
||||
private val searchAdapter by lazy {
|
||||
CollectSearchAdapter(list).apply {
|
||||
isStateViewEnable = true
|
||||
setOnItemClickListener { _, _, position ->
|
||||
//setOnItemClickListener { _, _, position ->
|
||||
// this@CollectSearchDialog.clickIndex = position
|
||||
// if (list[position].isSelected) {
|
||||
// return@setOnItemClickListener
|
||||
// }
|
||||
// list.forEach { item ->
|
||||
// item.isSelected = false
|
||||
// }
|
||||
// list[position].isSelected = true
|
||||
// notifyDataSetChanged()
|
||||
//}
|
||||
addOnItemChildClickListener(R.id.ivDelete) { _, _, position ->
|
||||
this@CollectSearchDialog.clickIndex = position
|
||||
if (list[position].isSelected) {
|
||||
return@setOnItemClickListener
|
||||
}
|
||||
list.forEach { item ->
|
||||
item.isSelected = false
|
||||
}
|
||||
list[position].isSelected = true
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
addOnItemChildClickListener(R.id.ivDelete) { _, _, position ->
|
||||
deleteGoods(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun deleteGoods(position: Int) {
|
||||
WarnDialog(context = context, content = "请确认是否删除物品:${list[position].goodsName}?", confirmBlock = {
|
||||
Thread {
|
||||
activity?.runOnUiThread {
|
||||
Loading.show(context)
|
||||
}
|
||||
val name = list[position].goodsName
|
||||
val filterIdList = box?.all?.filter { it.name == name }?.map { it.id }
|
||||
box?.removeByIds(filterIdList)
|
||||
activity?.runOnUiThread {
|
||||
Loading.dismiss()
|
||||
//list.remove(list[position])
|
||||
//searchAdapter.notifyDataSetChanged()
|
||||
searchAdapter.removeAt(position)
|
||||
activity?.toast("删除成功")
|
||||
if (list.isEmpty()) {
|
||||
loadEmptyView()
|
||||
private fun deleteGoods(position: Int, deleteAction:()-> Unit = {}) {
|
||||
WarnDialog(
|
||||
context = context,
|
||||
content = "请确认是否删除物品:${list[position].goodsName}?",
|
||||
confirmBlock = {
|
||||
Thread {
|
||||
activity?.runOnUiThread {
|
||||
Loading.show(context)
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}).show()
|
||||
val name = list[position].goodsName
|
||||
val filterIdList = box?.all?.filter { it.name == name }?.map { it.id }
|
||||
box?.removeByIds(filterIdList)
|
||||
activity?.runOnUiThread {
|
||||
Loading.dismiss()
|
||||
//list.remove(list[position])
|
||||
//searchAdapter.notifyDataSetChanged()
|
||||
searchAdapter.removeAt(position)
|
||||
activity?.toast("删除成功")
|
||||
if (list.isEmpty()) {
|
||||
loadEmptyView()
|
||||
}
|
||||
deleteAction()
|
||||
}
|
||||
}.start()
|
||||
}).show()
|
||||
}
|
||||
|
||||
private fun finishRefresh() {
|
||||
@@ -168,7 +184,7 @@ class CollectSearchDialog(
|
||||
private var box: Box<Food>? = null
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun getCollectGoods(searchName:String?=null) {
|
||||
private fun getCollectGoods(searchName: String? = null) {
|
||||
if (box == null) {
|
||||
box = ObjectBox.boxStore.boxFor(Food::class)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.graphics.Color
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.PopupWindow
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import androidx.core.view.updateLayoutParams
|
||||
@@ -18,8 +19,8 @@ import com.sw.inbound.utils.ext.dp
|
||||
class DropdownPopup(
|
||||
var context: Context,
|
||||
var list: MutableList<DictType>,
|
||||
var popWidth:Int = 280.dp,
|
||||
var popHeight:Int = 284.dp,
|
||||
var popWidth: Int = 280.dp,
|
||||
var popHeight: Int = 284.dp,
|
||||
var onPopupItemClick: (DictType) -> Unit
|
||||
) : PopupWindow() {
|
||||
|
||||
@@ -56,5 +57,22 @@ class DropdownPopup(
|
||||
}
|
||||
}
|
||||
|
||||
var arrowImage: ImageView? = null
|
||||
|
||||
var bgLayout: ViewGroup? = null
|
||||
|
||||
var defLayoutBgResId = R.drawable.bg_white_radius10_stroke2
|
||||
|
||||
override fun showAsDropDown(anchor: View?) {
|
||||
super.showAsDropDown(anchor)
|
||||
bgLayout?.setBackgroundResource(R.drawable.bg_white_stroke_blue)
|
||||
arrowImage?.setImageResource(R.mipmap.ic_triangle_up)
|
||||
}
|
||||
|
||||
override fun dismiss() {
|
||||
super.dismiss()
|
||||
bgLayout?.setBackgroundResource(defLayoutBgResId)
|
||||
arrowImage?.setImageResource(R.mipmap.ic_triangle_down)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -117,6 +117,9 @@ class GoodsStoreDialog(
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}.also {
|
||||
it.arrowImage = binding.ivDropdown
|
||||
it.bgLayout = binding.flUnitDropdown
|
||||
}
|
||||
}
|
||||
dropdownPopup?.showAsDropDown(v)
|
||||
|
||||
@@ -46,7 +46,8 @@ class CrashHandler private constructor(private val context: Context) :
|
||||
}
|
||||
|
||||
fun getCrashReportFiles(context: Context): Array<File> {
|
||||
val crashDir = File(context.getExternalFilesDir(null), CRASH_REPORTS_DIR)
|
||||
// val crashDir = File(context.getExternalFilesDir(null), CRASH_REPORTS_DIR)
|
||||
val crashDir = File(context.filesDir, CRASH_REPORTS_DIR)
|
||||
return if (crashDir.exists() && crashDir.isDirectory) {
|
||||
crashDir.listFiles { _, name -> name.endsWith(".log") } ?: emptyArray()
|
||||
} else {
|
||||
@@ -203,7 +204,8 @@ class CrashHandler private constructor(private val context: Context) :
|
||||
val time = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.getDefault()).format(Date())
|
||||
val fileName = "crash_$time.log"
|
||||
|
||||
val crashDir = File(context.getExternalFilesDir(null), CRASH_REPORTS_DIR)
|
||||
// val crashDir = File(context.getExternalFilesDir(null), CRASH_REPORTS_DIR)
|
||||
val crashDir = File(context.filesDir, CRASH_REPORTS_DIR)
|
||||
if (!crashDir.exists() && !crashDir.mkdirs()) {
|
||||
Timber.tag(TAG).e("Failed to create crash report directory")
|
||||
return
|
||||
@@ -222,7 +224,7 @@ class CrashHandler private constructor(private val context: Context) :
|
||||
* 清理旧的崩溃日志
|
||||
*/
|
||||
fun cleanupOldCrashReports(maxAgeDays: Int = 7) {
|
||||
val crashDir = File(context.getExternalFilesDir(null), CRASH_REPORTS_DIR)
|
||||
val crashDir = File(context.filesDir, CRASH_REPORTS_DIR)
|
||||
if (!crashDir.exists() || !crashDir.isDirectory) return
|
||||
|
||||
val now = System.currentTimeMillis()
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/white"/>
|
||||
<stroke android:color="#FF0032C8" android:width="2dp"/>
|
||||
<corners android:radius="10dp"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/white"/>
|
||||
<stroke android:color="#FF0000" android:width="2dp"/>
|
||||
<corners android:radius="10dp"/>
|
||||
</shape>
|
||||
@@ -88,7 +88,6 @@
|
||||
android:layout_width="284dp"
|
||||
android:layout_height="74dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardBackgroundColor="@android:color/transparent"
|
||||
app:cardCornerRadius="10dp">
|
||||
|
||||
<FrameLayout
|
||||
|
||||
@@ -323,6 +323,7 @@
|
||||
tools:ignore="Autofill,TextFields" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivStorageArrow"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
@@ -384,6 +385,7 @@
|
||||
tools:ignore="Autofill,TextFields" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivWarehouseArrow"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
@@ -495,7 +497,7 @@
|
||||
tools:ignore="Autofill,TextFields" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivDropdown"
|
||||
android:id="@+id/ivProcurementArrow"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
|
||||
@@ -117,7 +117,6 @@
|
||||
android:textColor="@color/white"
|
||||
android:textSize="30sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginStart="30dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
Reference in New Issue
Block a user