Quellcode durchsuchen

提交人:江天明
提交内容:优化

江天明 vor 10 Monaten
Ursprung
Commit
4617a899e6

+ 3 - 4
BusinessMain/src/main/java/com/develop/main/init/ui/FoodListActivity.kt

@@ -135,13 +135,12 @@ class FoodListActivity : BaseActivity<ActivityFoodListBinding>() {
             val recipesDao = FoodDataProvider.getDatabase().recipeDao()
             val recipesIdList = mutableListOf<String>()
             val favoriteRecipesIds = mutableListOf<String>()
-            if (foodListType == Favourite) {
-                userDao.queryFavoriteRecipes(CURRENT_USER_ID).forEach {
+            userDao.queryFavoriteRecipes(CURRENT_USER_ID).forEach {
+                if (foodListType == Favourite) {
                     recipesIdList.add(it.favoriteRecipesId)
-                    favoriteRecipesIds.add(it.favoriteRecipesId)
                 }
+                favoriteRecipesIds.add(it.favoriteRecipesId)
             }
-
             if (foodListType == History) {
                 userDao.queryHistoryRecipes(CURRENT_USER_ID).forEach {
                     recipesIdList.add(it.historyRecipesId)

+ 2 - 8
BusinessMain/src/main/java/com/develop/main/init/ui/adapter/RecipesListAdapter.kt

@@ -118,10 +118,7 @@ class RecipesListAdapter :
                     )
                 }
                 ivLike.setBackgroundResource(R.drawable.ic_unlike)
-                if (!isHistory) {
-                    EventBus.getDefault().post(RefreshDataEvent())
-                    EventBus.getDefault().post(RefreshLikeDataEvent(false, item.foodId))
-                }
+                EventBus.getDefault().post(RefreshLikeDataEvent(false, item.foodId))
 
             } else {
                 item.isLike = true
@@ -132,10 +129,7 @@ class RecipesListAdapter :
 
                     )
                 }
-                if (!isHistory) {
-                    EventBus.getDefault().post(RefreshLikeDataEvent(false, item.foodId))
-                    EventBus.getDefault().post(RefreshDataEvent())
-                }
+                EventBus.getDefault().post(RefreshLikeDataEvent(true, item.foodId))
             }
         }
     }