fix(food): 修复菜品列表刷新和净材对话框显示问题
- 在 Fragment 初始化时启用下拉刷新功能 - 将数据加载逻辑移至 onResume 方法中并添加异常处理 - 添加 onHiddenChanged 回调以在 Fragment 显示时重新加载数据 - 更新净材对话框为空时的提示文本和按钮样式
This commit is contained in:
@@ -133,13 +133,19 @@ class FoodListFragment : BaseFragment<FragmentFoodListBinding>() {
|
|||||||
adapter = dishAdapter
|
adapter = dishAdapter
|
||||||
}
|
}
|
||||||
addViewListener()
|
addViewListener()
|
||||||
|
|
||||||
pageNo = 1
|
|
||||||
activity.showLoading()
|
|
||||||
getDishList()
|
|
||||||
binding.refreshLayout.setEnableRefresh(true)
|
binding.refreshLayout.setEnableRefresh(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
runCatching {
|
||||||
|
pageNo = 1
|
||||||
|
getDishList()
|
||||||
|
}.onFailure {
|
||||||
|
it.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建统一样式的删除菜单项
|
* 构建统一样式的删除菜单项
|
||||||
*/
|
*/
|
||||||
@@ -167,6 +173,15 @@ class FoodListFragment : BaseFragment<FragmentFoodListBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onHiddenChanged(hidden: Boolean) {
|
||||||
|
super.onHiddenChanged(hidden)
|
||||||
|
if (!hidden) {
|
||||||
|
Log.d("FoodList", "显示")
|
||||||
|
pageNo = 1
|
||||||
|
getDishList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getDishList(pageNo: Int, dinnerType: String, foodName: String? = null) {
|
fun getDishList(pageNo: Int, dinnerType: String, foodName: String? = null) {
|
||||||
this.pageNo = pageNo
|
this.pageNo = pageNo
|
||||||
this.dinnerType = dinnerType
|
this.dinnerType = dinnerType
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ fun showRawMaterialsDialog(
|
|||||||
|
|
||||||
if (typeList.isEmpty()) {
|
if (typeList.isEmpty()) {
|
||||||
// 无净材数据时仅展示提示文字
|
// 无净材数据时仅展示提示文字
|
||||||
dialog.setContent("无净材数据")
|
dialog.setContent("暂无净材种类,联系管理员添加")
|
||||||
.setPositiveButton("确认") {}
|
.setSingleButton("确认") {}
|
||||||
} else {
|
} else {
|
||||||
// 构建单选 ChipGroup 作为自定义内容
|
// 构建单选 ChipGroup 作为自定义内容
|
||||||
val chipGroup = buildSingleChoiceChipGroup(context, typeList, checkedType)
|
val chipGroup = buildSingleChoiceChipGroup(context, typeList, checkedType)
|
||||||
|
|||||||
Reference in New Issue
Block a user