联调优化
This commit is contained in:
@@ -49,14 +49,7 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
private val TAG = "FoodCollectionActivity"
|
||||
|
||||
private var box: Box<Food>? = null
|
||||
private val collectList: MutableList<FoodCollectionBean> = mutableListOf(
|
||||
FoodCollectionBean(isShowCamera = true),
|
||||
FoodCollectionBean(isShowCamera = true),
|
||||
FoodCollectionBean(isShowCamera = true),
|
||||
FoodCollectionBean(isShowCamera = true),
|
||||
FoodCollectionBean(isShowCamera = true),
|
||||
FoodCollectionBean(isShowCamera = true)
|
||||
)
|
||||
private val collectList: MutableList<FoodCollectionBean> = mutableListOf<FoodCollectionBean>()
|
||||
private lateinit var binding: ActivityFoodCollectionBinding
|
||||
private lateinit var previewView: PreviewView
|
||||
|
||||
@@ -119,6 +112,11 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
it.adapter = collectionAdapter
|
||||
}
|
||||
|
||||
repeat(MAX_COUNT) {
|
||||
collectList.add(FoodCollectionBean(isShowCamera = true))
|
||||
}
|
||||
collectionAdapter.notifyDataSetChanged()
|
||||
|
||||
binding.ivGoodsSearch.setOnClickListener { searchGoods() }
|
||||
binding.etGoodsInput.let { v ->
|
||||
v.addOnActionSearchListener {
|
||||
@@ -195,11 +193,13 @@ class FoodCollectionActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
val MAX_COUNT = 100
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun takePhoto() {
|
||||
val count = collectList.count { it.bitmap != null }
|
||||
if (count == 6) {
|
||||
toast("每次只允许保存6条数据")
|
||||
if (count == MAX_COUNT) {
|
||||
toast("每次只允许保存${MAX_COUNT}条数据")
|
||||
return
|
||||
}
|
||||
cameraUtils.takePhoto(cameraCallback)
|
||||
|
||||
@@ -164,14 +164,15 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rvFoodCollection"
|
||||
android:layout_width="620dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:overScrollMode="never"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
app:layout_constraintStart_toEndOf="@id/flPreview"
|
||||
app:layout_constraintTop_toTopOf="@id/flPreview"
|
||||
app:spanCount="3"
|
||||
tools:itemCount="6"
|
||||
tools:itemCount="18"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
tools:listitem="@layout/list_item_food_collection" />
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user