1.物品采集页面增加查看已采集物品信息,可以与搜索进行切换显示;2.收货已确认未确认显示优化;3.debug和release依赖切换使用问题解决;4其它优化;
This commit is contained in:
@@ -22,6 +22,7 @@ import com.sw.inbound.model.response.SearchGoodsInfo
|
||||
import com.sw.inbound.objbox.Food
|
||||
import com.sw.inbound.objbox.FoodCollectionBean
|
||||
import com.sw.inbound.objbox.FoodModule
|
||||
import com.sw.inbound.objbox.Food_
|
||||
import com.sw.inbound.objbox.ObjectBox
|
||||
import com.sw.inbound.utils.BitmapCropper
|
||||
import com.sw.inbound.utils.BitmapSaver
|
||||
@@ -30,8 +31,10 @@ import com.sw.inbound.utils.ImageUtil
|
||||
import com.sw.inbound.utils.ext.addOnActionSearchListener
|
||||
import com.sw.inbound.utils.ext.clickWithDebounce
|
||||
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 com.sw.inbound.viewmodel.ReceiptViewModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.objectbox.Box
|
||||
@@ -39,11 +42,11 @@ import io.objectbox.kotlin.boxFor
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import timber.log.Timber
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@AndroidEntryPoint
|
||||
class FoodCollectionActivity : ComponentActivity() {
|
||||
|
||||
private val TAG = "FoodCollectionActivity"
|
||||
private var selectedFoodName: String = ""
|
||||
|
||||
private var box: Box<Food>? = null
|
||||
private val collectList: MutableList<FoodCollectionBean> = mutableListOf(
|
||||
@@ -97,11 +100,13 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
cameraUtils.unbind()
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityFoodCollectionBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
cameraUtils.initCamera()
|
||||
binding.root.hideKeyboard()
|
||||
val previewBinding =
|
||||
LayoutCameraPreviewBinding.inflate(layoutInflater, binding.flCameraPreview)
|
||||
previewView = previewBinding.previewView.also {
|
||||
@@ -149,15 +154,13 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
}.start()
|
||||
}
|
||||
binding.btnRemoveDefault.clickWithDebounce {
|
||||
if (box == null) {
|
||||
box = ObjectBox.boxStore.boxFor(Food::class)
|
||||
}
|
||||
initBox()
|
||||
val list = box?.all?.filter { it.foodIdx == FoodModule.DEFAULT_FOOD_INDEX }
|
||||
if (list.isNullOrEmpty()) {
|
||||
toast("不存在默认数据")
|
||||
return@clickWithDebounce
|
||||
}
|
||||
box?.removeByIds(list!!.map { it.id })
|
||||
box?.removeByIds(list.map { it.id })
|
||||
toast("移除完成")
|
||||
}
|
||||
binding.btnClearData.setOnClickListener { clearData() }
|
||||
@@ -176,7 +179,45 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
searchGoods()
|
||||
}
|
||||
}
|
||||
loadEmptyView()
|
||||
binding.radioGroup.setOnCheckedChangeListener { group, checkedId ->
|
||||
if (checkedId == R.id.rbCollected) {
|
||||
binding.llSearchInput.gone()
|
||||
binding.refreshLayout.let {
|
||||
it.setEnableRefresh(false)
|
||||
it.setEnableLoadMore(false)
|
||||
}
|
||||
getCollectedGoods()
|
||||
return@setOnCheckedChangeListener
|
||||
}
|
||||
if (checkedId == R.id.rbSearch) {
|
||||
binding.llSearchInput.visible()
|
||||
pageNo = 1
|
||||
clickIndex = -1
|
||||
searchGoodsList.clear()
|
||||
searchAdapter.notifyDataSetChanged()
|
||||
binding.refreshLayout.let {
|
||||
it.setEnableRefresh(true)
|
||||
it.setEnableLoadMore(false)
|
||||
}
|
||||
loadEmptyView()
|
||||
return@setOnCheckedChangeListener
|
||||
}
|
||||
}
|
||||
binding.radioGroup.check(R.id.rbCollected)
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun getCollectedGoods() {
|
||||
searchGoodsList.clear()
|
||||
initBox()
|
||||
box?.all?.distinctBy { it.name }?.forEach {
|
||||
searchGoodsList.add((SearchGoodsInfo.Record(goodsName = it.name)))
|
||||
}
|
||||
binding.rvSearch.layoutManager = GridLayoutManager(this, 2, LinearLayoutManager.VERTICAL, false)
|
||||
searchAdapter.notifyDataSetChanged()
|
||||
if (searchGoodsList.isEmpty()) {
|
||||
loadEmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
private var pageNo = 1
|
||||
@@ -284,9 +325,7 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
}
|
||||
|
||||
private fun image2VectorTask(bitmap: Bitmap, position: Int) {
|
||||
if (box == null) {
|
||||
box = ObjectBox.boxStore.boxFor(Food::class)
|
||||
}
|
||||
initBox()
|
||||
val imageVector = FoodModule.bitmap2FloatArray(bitmap)
|
||||
box?.put(Food(name = searchGoodsList[clickIndex].goodsName, foodIdx = 0, foodVector = imageVector))
|
||||
collectList[position].let {
|
||||
@@ -361,4 +400,10 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun initBox() {
|
||||
if (box == null) {
|
||||
box = ObjectBox.boxStore.boxFor(Food::class)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user