fix(activity): 优化提交页返回未保存判断与采样页按钮样式
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -414,13 +414,29 @@ class SubmitFoodActivity : BaseActivity() {
|
|||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否存在未保存的数据
|
||||||
|
* isCooking=true 时检查是否有新增秤数据;isCooking=false 时检查是否有调料数据
|
||||||
|
*/
|
||||||
|
private fun hasUnsavedData(): Boolean {
|
||||||
|
return if (food?.isCooking == true) {
|
||||||
|
rawWeightMap.isNotEmpty()
|
||||||
|
} else {
|
||||||
|
seasoningAdapter.items.isNotEmpty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 未保存数据提醒dialog
|
* 未保存数据提醒dialog
|
||||||
*/
|
*/
|
||||||
private fun remindSaveDataDialog() {
|
private fun remindSaveDataDialog() {
|
||||||
|
if (!hasUnsavedData()) {
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
CommonDialog(this)
|
CommonDialog(this)
|
||||||
.setTitle("保存提示")
|
.setTitle("保存提示")
|
||||||
.setContent("可能存在未保存的数据,请确认?")
|
.setContent("存在未保存的数据,请确认?")
|
||||||
.setNegativeButton("取消,留在页面")
|
.setNegativeButton("取消,留在页面")
|
||||||
.setNeutralButton("返回上页,不保存") { finish() }
|
.setNeutralButton("返回上页,不保存") { finish() }
|
||||||
.setPositiveButton("保存为烹饪中菜品") { cook() }
|
.setPositiveButton("保存为烹饪中菜品") { cook() }
|
||||||
|
|||||||
@@ -90,12 +90,13 @@
|
|||||||
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
|
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatButton
|
<TextView
|
||||||
android:id="@+id/btnAddSampling"
|
android:id="@+id/btnAddSampling"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="90dp"
|
android:layout_height="90dp"
|
||||||
android:layout_margin="30dp"
|
android:layout_margin="30dp"
|
||||||
android:background="@drawable/shape_green_bg"
|
android:background="@drawable/shape_green_bg"
|
||||||
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/add_sampling"
|
android:text="@string/add_sampling"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
|
|||||||
Reference in New Issue
Block a user