Преглед изворни кода

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

江天明 пре 11 месеци
родитељ
комит
7840428b27

+ 4 - 0
BusinessMain/src/main/java/com/develop/main/init/ui/adapter/RecipesListAdapter.kt

@@ -11,6 +11,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter
 import com.chad.library.adapter.base.viewholder.BaseViewHolder
 import com.develop.food.base.data.model.FoodContentModel
 import com.develop.food.base.event.RefreshDataEvent
+import com.develop.food.base.event.RefreshLikeDataEvent
 import com.develop.food.base.repo.CURRENT_USER_ID
 import com.develop.food.base.repo.FoodDataProvider
 import com.develop.food.base.repo.entity.UserFavoriteRecipes
@@ -119,6 +120,7 @@ class RecipesListAdapter :
                 ivLike.setBackgroundResource(R.drawable.ic_unlike)
                 if (!isHistory) {
                     EventBus.getDefault().post(RefreshDataEvent())
+                    EventBus.getDefault().post(RefreshLikeDataEvent(false, item.foodId))
                 }
 
             } else {
@@ -127,9 +129,11 @@ class RecipesListAdapter :
                 FoodDataProvider.getUserDatabase().runInTransaction {
                     FoodDataProvider.getUserDatabase().userInfoDao().insertFavoriteRecipe(
                         UserFavoriteRecipes(CURRENT_USER_ID, item.foodId)
+
                     )
                 }
                 if (!isHistory) {
+                    EventBus.getDefault().post(RefreshLikeDataEvent(false, item.foodId))
                     EventBus.getDefault().post(RefreshDataEvent())
                 }
             }

+ 17 - 17
BusinessMain/src/main/res/layout/food_content_provider.xml

@@ -39,30 +39,30 @@
                 android:background="@drawable/ic_delete" />
         </RelativeLayout>
 
+        <RelativeLayout
+            android:id="@+id/like_layout"
+            android:layout_width="@dimen/convert_90px"
+            android:layout_height="@dimen/convert_90px"
+            android:layout_alignParentEnd="true"
+            android:layout_marginTop="@dimen/convert_24px"
+            android:layout_marginEnd="@dimen/convert_51px"
+            android:background="@drawable/white_circle"
+            android:visibility="gone">
+
+            <ImageView
+                android:id="@+id/iv_like"
+                android:layout_width="@dimen/convert_48px"
+                android:layout_height="@dimen/convert_42px"
+                android:layout_centerInParent="true"
+                android:background="@drawable/ic_like" />
+        </RelativeLayout>
         <RelativeLayout
             android:layout_width="match_parent"
             android:layout_height="@dimen/convert_210px"
             android:layout_alignParentBottom="true"
             android:background="@drawable/shape_30px8000000_bottom_corners">
 
-            <RelativeLayout
-                android:id="@+id/like_layout"
-                android:layout_width="@dimen/convert_90px"
-                android:layout_height="@dimen/convert_90px"
-                android:layout_below="@id/tv_time_and_level"
-                android:layout_alignParentEnd="true"
-                android:layout_marginTop="@dimen/convert_14px"
-                android:layout_marginEnd="@dimen/convert_51px"
-                android:background="@drawable/white_circle"
-                android:visibility="gone">
 
-                <ImageView
-                    android:id="@+id/iv_like"
-                    android:layout_width="@dimen/convert_48px"
-                    android:layout_height="@dimen/convert_42px"
-                    android:layout_centerInParent="true"
-                    android:background="@drawable/ic_like" />
-            </RelativeLayout>
 
             <ImageView
                 android:id="@+id/iv_net"