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