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