|
@@ -176,6 +176,14 @@ object AppVersionUtil {
|
|
|
|
|
|
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")
|
|
|
private fun downloadRecipes(
|
|
|
newRecipes: LinkedList<String>,
|
|
@@ -202,8 +210,25 @@ object AppVersionUtil {
|
|
|
|
|
|
TopResumedAtyHolder.getCurrentActivity()?.apply {
|
|
|
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
|
|
|
}
|
|
|
|
|
@@ -324,10 +349,8 @@ object AppVersionUtil {
|
|
|
RecipeUpdateDialog().apply {
|
|
|
onDialogClickListener = object : RecipeUpdateDialog.OnDialogClickListener {
|
|
|
override fun onConfirm() {
|
|
|
- val v = FoodDataProvider.getUserDatabase().devConfigDao().recipeVersion()
|
|
|
- ?: DevVersion(0, 0)
|
|
|
- v.recipeUpdateTime = recipeUpdateTime
|
|
|
- FoodDataProvider.getUserDatabase().devConfigDao().saveDevVersion(v)
|
|
|
+ saveRecipeUpdateTime(recipeUpdateTime)
|
|
|
+
|
|
|
removeSelf()
|
|
|
}
|
|
|
|