功能优化
This commit is contained in:
@@ -23,6 +23,7 @@ import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
import kotlin.math.atan
|
||||
|
||||
class UserViewModel : BaseViewModel() {
|
||||
|
||||
@@ -210,12 +211,14 @@ class UserViewModel : BaseViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun getFoodInfo(foodName: String) {
|
||||
fun getFoodInfo(foodName: String, action:(List<FoodInfo>)-> Unit = {}) {
|
||||
Timber.d("getFoodInfo")
|
||||
launchWithLoading {
|
||||
val response = repository.getFoodInfo(foodName = foodName)
|
||||
if (parseResponse(response)) {
|
||||
_identifiedFoodInfoList2.value = response.result ?: emptyList()
|
||||
val list = response.result ?: emptyList()
|
||||
_identifiedFoodInfoList2.value = list
|
||||
action(list)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user