|
@@ -176,6 +176,14 @@ object AppVersionUtil {
|
|
|
|
|
|
var updateRecipe = false
|
|
var updateRecipe = false
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private fun saveRecipeUpdateTime(recipeUpdateTime: Long?) {
|
|
|
|
+ val v =
|
|
|
|
+ FoodDataProvider.getUserDatabase().devConfigDao().recipeVersion() ?: DevVersion(0, 0)
|
|
|
|
+ v.recipeUpdateTime = recipeUpdateTime
|
|
|
|
+ FoodDataProvider.getUserDatabase().devConfigDao().saveDevVersion(v)
|
|
|
|
+ }
|
|
|
|
+
|
|
@SuppressLint("InvalidWakeLockTag")
|
|
@SuppressLint("InvalidWakeLockTag")
|
|
private fun downloadRecipes(
|
|
private fun downloadRecipes(
|
|
newRecipes: LinkedList<String>,
|
|
newRecipes: LinkedList<String>,
|
|
@@ -202,8 +210,25 @@ object AppVersionUtil {
|
|
|
|
|
|
TopResumedAtyHolder.getCurrentActivity()?.apply {
|
|
TopResumedAtyHolder.getCurrentActivity()?.apply {
|
|
if (newRecipes.isEmpty()) {
|
|
if (newRecipes.isEmpty()) {
|
|
- recipeUpdateDialog.removeSelf()
|
|
|
|
- showRecipesUpdateDialog(recipeUpdateTime)
|
|
|
|
|
|
+ saveRecipeUpdateTime(recipeUpdateTime)
|
|
|
|
+ scopeNetLife {
|
|
|
|
+ //判断是否还有新菜谱
|
|
|
|
+ val result = Post<DevInfoResult>(Api.DEV_INFO) {
|
|
|
|
+ body = DeviceInfoBody.genDeviceInfoBody()
|
|
|
|
+ }.await()
|
|
|
|
+
|
|
|
|
+ val ut = result.recipeUpdateTime
|
|
|
|
+ val nr = LinkedList(result.newRecipes)
|
|
|
|
+ if (!nr.isEmpty()) {
|
|
|
|
+ downloadRecipes(nr,recipeUpdateDialog,
|
|
|
|
+ nr.size.toLong(),downloadDir,downloadName,ut)
|
|
|
|
+ return@scopeNetLife
|
|
|
|
+ }else{
|
|
|
|
+ recipeUpdateDialog.removeSelf()
|
|
|
|
+ showRecipesUpdateDialog(recipeUpdateTime)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -324,10 +349,8 @@ object AppVersionUtil {
|
|
RecipeUpdateDialog().apply {
|
|
RecipeUpdateDialog().apply {
|
|
onDialogClickListener = object : RecipeUpdateDialog.OnDialogClickListener {
|
|
onDialogClickListener = object : RecipeUpdateDialog.OnDialogClickListener {
|
|
override fun onConfirm() {
|
|
override fun onConfirm() {
|
|
- val v = FoodDataProvider.getUserDatabase().devConfigDao().recipeVersion()
|
|
|
|
- ?: DevVersion(0, 0)
|
|
|
|
- v.recipeUpdateTime = recipeUpdateTime
|
|
|
|
- FoodDataProvider.getUserDatabase().devConfigDao().saveDevVersion(v)
|
|
|
|
|
|
+ saveRecipeUpdateTime(recipeUpdateTime)
|
|
|
|
+
|
|
removeSelf()
|
|
removeSelf()
|
|
}
|
|
}
|
|
|
|
|