소스 검색

提交人:jtm
提交内容:菜品刷新优化

江天明 1 년 전
부모
커밋
19f7f5f43c

+ 49 - 42
BusinessCommon/src/main/java/com/develop/common/data_repo/db/DataFactory.kt

@@ -7,13 +7,14 @@ import com.develop.common.data_repo.db.entity.DevRecipe
 import com.develop.common.data_repo.db.entity.UserFavoriteRecipes
 import com.develop.common.widget.EntranceData
 import com.develop.common.widget.EntranceType
+import com.drake.brv.item.ItemHover
 
 
 object DataFactory {
 
     fun createLanguageData(resource: Resources): MutableList<LanguageModel> {
         val languageList = mutableListOf<LanguageModel>()
-        val strList = if (isNightTheme()){
+        val strList = if (isNightTheme()) {
             mutableListOf<String>(
 //            resource.getString(R.string.chinese),
                 resource.getString(R.string.france),
@@ -27,11 +28,11 @@ object DataFactory {
 //            resource.getString(R.string.japan)
             )
         }
-        val iconList = if (isNightTheme()){
+        val iconList = if (isNightTheme()) {
             mutableListOf<Int>(
 //
 //            R.drawable.ic_chinese,
-            R.drawable.ic_france
+                R.drawable.ic_france
             )
         } else {
             mutableListOf<Int>(
@@ -41,7 +42,7 @@ object DataFactory {
 //            R.drawable.ic_japan
             )
         }
-        val typeList = if (isNightTheme()){
+        val typeList = if (isNightTheme()) {
             mutableListOf<LanguageType>(
 //            LanguageType.Chinese,
                 LanguageType.France
@@ -163,25 +164,19 @@ object DataFactory {
 
             )
         val nameList = mutableListOf(
-            resource.getString(R.string.language),
-            resource.getString(R.string.wifi),
+            resource.getString(R.string.language), resource.getString(R.string.wifi),
 //            resource.getString(R.string.sound),
-            resource.getString(R.string.brightness),
-            resource.getString(R.string.user_account),
+            resource.getString(R.string.brightness), resource.getString(R.string.user_account),
 //            resource.getString(R.string.storage),
-            resource.getString(R.string.reset),
-            resource.getString(R.string.about)
+            resource.getString(R.string.reset), resource.getString(R.string.about)
 
         )
         val settingTypeList = mutableListOf(
-            SettingType.LANGUAGE,
-            SettingType.WIFI,
+            SettingType.LANGUAGE, SettingType.WIFI,
 //            SettingType.SOUND,
-            SettingType.BRIGHTNESS,
-            SettingType.USER_ACCOUNT,
+            SettingType.BRIGHTNESS, SettingType.USER_ACCOUNT,
 //            SettingType.STORAGE,
-            SettingType.RESTORE_FACTORY_SETTINGS,
-            SettingType.ABOUT
+            SettingType.RESTORE_FACTORY_SETTINGS, SettingType.ABOUT
         )
         for (i in resIdList.indices) {
             result.add(SettingModel(resIdList[i], nameList[i], settingTypeList[i]))
@@ -189,6 +184,7 @@ object DataFactory {
         return result
     }
 
+
     fun genLocalRecipes(
         categoryName: String,
         recipesList: MutableList<DevRecipe>,
@@ -196,16 +192,19 @@ object DataFactory {
         sortedType: SortedType
     ): MutableList<Any> {
         val result = mutableListOf<Any>()
-        result.add(FilterSortModel(""))
-        result.add(categoryName)
+        val homeHeader = HomeHeader()
+        homeHeader.apply {
+            filterSortModel = FilterSortModel("")
+            category = categoryName
+        }
+        result.add(homeHeader)
         val favoriteRecipesIds = mutableListOf<String>()
         favoriteRecipes.forEach {
             favoriteRecipesIds.add(it.favoriteRecipesId)
         }
-        val foodList = mutableListOf<FoodContentModel>()
         for (i in recipesList.indices) {
             val recipes = recipesList[i]
-            foodList.add(
+            result.add(
                 FoodContentModel(
                     recipes.photoPath ?: "",
                     recipes.name ?: "",
@@ -221,10 +220,10 @@ object DataFactory {
                 )
             )
         }
-        result.add(FoodListModel(foodList, categoryName))
         return result
     }
 
+
     fun genSortNameList(resource: Resources): MutableList<FilterSortModel> {
         val result = mutableListOf<FilterSortModel>()
         val sortNameList = mutableListOf(
@@ -241,25 +240,29 @@ object DataFactory {
 
     fun genTestSearchDataList(): MutableList<Any> {
         val result = mutableListOf<Any>()
-        result.add(FilterSortModel(""))
+        val homeHeader = HomeHeader()
+        homeHeader.filterSortModel = FilterSortModel("")
         val searchNameList =
             mutableListOf("Guacamole", "Aioli", "Popular", "Chinese food", "Healthy")
         val searchModelList = mutableListOf<CommonSearchItem>()
         searchNameList.forEach {
             searchModelList.add(CommonSearchItem(it))
         }
-        result.add(CommonSearchModel(searchModelList))
+        homeHeader.commonSearchModel = CommonSearchModel(searchModelList)
+        result.add(homeHeader)
         return result
     }
 
     fun genOnLineHotTags(hotTags: MutableList<String>): MutableList<Any> {
         val result = mutableListOf<Any>()
-        result.add(FilterSortModel(""))
+        val homeHeader = HomeHeader()
+        homeHeader.filterSortModel = FilterSortModel("")
         val searchModelList = mutableListOf<CommonSearchItem>()
         hotTags.forEach {
             searchModelList.add(CommonSearchItem(it))
         }
-        result.add(CommonSearchModel(searchModelList))
+        homeHeader.commonSearchModel = CommonSearchModel(searchModelList)
+        result.add(result)
         return result
     }
 
@@ -271,12 +274,17 @@ object DataFactory {
         sortedType: SortedType
     ): MutableList<Any> {
         val result = mutableListOf<Any>()
-        result.add(FilterSortModel("", isOnLineState = true))
-        result.add(categoryName)
+        val homeHeader = HomeHeader()
+        homeHeader.apply {
+            filterSortModel = FilterSortModel("", isOnLineState = true)
+            category = categoryName
+        }
+
         val favoriteRecipesIds = mutableListOf<String>()
         favoriteRecipes.forEach {
             favoriteRecipesIds.add(it.favoriteRecipesId)
         }
+        result.add(homeHeader)
         recipesList.sortWith(Comparator { t, t2 ->
             when (sortedType) {
                 SortedType.Popular -> {
@@ -318,10 +326,9 @@ object DataFactory {
                 }
             }
         })
-        val foodList = mutableListOf<FoodContentModel>()
         for (i in recipesList.indices) {
             val recipes = recipesList[i]
-            foodList.add(
+            result.add(
                 FoodContentModel(
                     recipes.photoPath ?: "",
                     recipes.name ?: "",
@@ -337,7 +344,6 @@ object DataFactory {
                 )
             )
         }
-        result.add(FoodListModel(foodList, categoryName))
         return result
     }
 
@@ -375,7 +381,6 @@ object DataFactory {
     )
 
 
-
     private var bgResIds1 = arrayListOf<Int>(
         R.drawable.entrance_bg_1,
         R.drawable.entrance_bg_3,
@@ -414,11 +419,7 @@ object DataFactory {
         for (i in iconResIds.indices) {
             dataList.add(
                 EntranceData(
-                    bgResIds[i],
-                    iconResIds[i],
-                    titleStrIds[i],
-                    title2StrIds[i],
-                    typeList[i]
+                    bgResIds[i], iconResIds[i], titleStrIds[i], title2StrIds[i], typeList[i]
                 )
             )
         }
@@ -426,16 +427,12 @@ object DataFactory {
     }
 
 
-    fun getNightEntranceData():MutableList<EntranceData>{
+    fun getNightEntranceData(): MutableList<EntranceData> {
         val dataList = mutableListOf<EntranceData>()
         for (i in iconResIds1.indices) {
             dataList.add(
                 EntranceData(
-                    bgResIds1[i],
-                    iconResIds1[i],
-                    titleStrIds1[i],
-                    title2StrIds1[i],
-                    typeList1[i]
+                    bgResIds1[i], iconResIds1[i], titleStrIds1[i], title2StrIds1[i], typeList1[i]
                 )
             )
         }
@@ -453,4 +450,14 @@ fun getTime(hour: Int, minute: Int): String {
         minuteStr = "${minute}minute"
     }
     return "$hourStr$minuteStr"
+}
+
+data class HomeHeader(
+    var filterSortModel: FilterSortModel? = null,
+    var category: String? = null,
+    var commonSearchModel: CommonSearchModel? = null,
+    var categoryModel: CategoryModel? = null
+) : ItemHover {
+
+    override var itemHover: Boolean = true
 }

+ 9 - 7
BusinessCommon/src/main/java/com/develop/common/widget/FoodContentView.kt

@@ -18,6 +18,8 @@ import com.develop.base.ext.background_drawable
 import com.develop.base.ext.load
 import com.develop.base.ext.navigateTo
 import com.develop.base.ext.resId2Dimension
+import com.develop.base.ext.skinBackground
+import com.develop.base.ext.skinSrc
 import com.develop.base.ext.src
 import com.develop.base.ext.updateText
 import com.develop.base.util.TopResumedAtyHolder
@@ -59,8 +61,8 @@ class FoodContentView : ConstraintLayout {
     init {
         val root = View.inflate(context, R.layout.food_content_view, this)
         binding = FoodContentViewBinding.bind(root)
-        binding.contentLayout.background_drawable = R.drawable.food_content_conner
-        binding.likeLayout.background_drawable = R.drawable.white_circle
+        binding.contentLayout.skinBackground(R.drawable.food_content_conner)
+        binding.likeLayout.skinBackground(R.drawable.white_circle)
         binding.contentLayout.setOnClickListener {
             mFoodContent?.apply {
                 TopResumedAtyHolder.getCurrentActivity()?.navigateTo(Screens.Cook.COOK_DETAIL) {
@@ -123,7 +125,7 @@ class FoodContentView : ConstraintLayout {
                 } else {
                     if (isLike) {
                         isLike = false
-                        binding.ivLike.src = R.drawable.ic_unlike
+                        binding.ivLike.skinSrc( R.drawable.ic_unlike)
                         FoodDataProvider.getUserDatabase().runInTransaction {
                             FoodDataProvider.getUserDatabase().userInfoDao().removeFavoriteRecipe(
                                 CURRENT_USER_ID, foodId
@@ -135,7 +137,7 @@ class FoodContentView : ConstraintLayout {
 
                     } else {
                         isLike = true
-                        binding.ivLike.src = R.drawable.ic_like
+                        binding.ivLike.skinSrc(R.drawable.ic_like)
                         FoodDataProvider.getUserDatabase().runInTransaction {
                             FoodDataProvider.getUserDatabase().userInfoDao().insertFavoriteRecipe(
                                 UserFavoriteRecipes(CURRENT_USER_ID, foodId)
@@ -192,12 +194,12 @@ class FoodContentView : ConstraintLayout {
                 ivNet.visibility = View.GONE
             }
             if (hasDownload) {
-                ivLike.src = R.drawable.ic_delete
+                ivLike.skinSrc(R.drawable.ic_delete)
             } else {
                 if (isLike) {
-                    ivLike.src = R.drawable.ic_like
+                    ivLike.skinSrc( R.drawable.ic_like)
                 } else {
-                    ivLike.src = R.drawable.ic_unlike
+                    ivLike.skinSrc(R.drawable.ic_unlike)
                 }
             }
 

+ 0 - 1
BusinessCommon/src/main/res/layout/fragment_comme_list.xml

@@ -8,7 +8,6 @@
 
     <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/rv"
-        app:stackFromEnd="true"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:overScrollMode="never" />

+ 30 - 0
BusinessCommon/src/main/res/layout/item_home_header.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:orientation="vertical"
+    android:layout_height="wrap_content">
+
+    <com.develop.common.widget.HomeFilterSortSearchView
+        android:id="@+id/function_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+
+    <androidx.appcompat.widget.AppCompatTextView
+        android:id="@+id/tv_food_category_name"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="@dimen/convert_24px"
+        android:layout_marginBottom="@dimen/convert_24px"
+        android:textColor="@color/home_category_title"
+        android:textSize="@dimen/convert_36px" />
+
+    <com.develop.common.widget.CommonSearchLayout
+        android:id="@+id/common_search_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+    <com.develop.common.widget.CategoryTabViewLayout
+        android:id="@+id/category_tab_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+</LinearLayout>

+ 85 - 74
BusinessMain/src/main/java/com/develop/main/ui/RecipesFragment.kt

@@ -11,6 +11,7 @@ import android.widget.RelativeLayout
 import androidx.appcompat.widget.AppCompatTextView
 import androidx.cardview.widget.CardView
 import androidx.databinding.ViewDataBinding
+import androidx.recyclerview.widget.GridLayoutManager
 import androidx.recyclerview.widget.RecyclerView
 import androidx.recyclerview.widget.RecyclerView.RecyclerListener
 import androidx.recyclerview.widget.SimpleItemAnimator
@@ -21,6 +22,8 @@ import com.develop.base.ext.globalApp
 import com.develop.base.ext.isNightTheme
 import com.develop.base.ext.navigateTo
 import com.develop.base.ext.resId2Dimension
+import com.develop.base.ext.setGone
+import com.develop.base.ext.setVisible
 import com.develop.base.ext.text_color
 import com.develop.base.ext.updateText
 import com.develop.base.util.GlobalToast
@@ -38,6 +41,7 @@ import com.develop.main.R
 import com.develop.main.databinding.ItemFilterAndSortViewBinding
 import com.develop.main.viewmodel.HomeViewModel
 import com.drake.brv.BindingAdapter
+import com.drake.brv.layoutmanager.HoverGridLayoutManager
 import com.drake.brv.utils.*
 import com.drake.net.utils.scopeNet
 import kotlinx.coroutines.delay
@@ -51,7 +55,6 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
 
     private var sortRv: RecyclerView? = null
     private var filterRv: RecyclerView? = null
-    private var foodRecycle: RecyclerView? = null
 
     private var categoryDataList = mutableListOf<DevRecipeCategory>()
     private var sortDataList = mutableListOf<FilterSortModel>()
@@ -150,95 +153,101 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
         sortDataList.addAll(DataFactory.genSortNameList(resources))
 
         binding.rv.apply {
-
             (itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false
             background_color = com.develop.common.R.color.bg_color
             setHasFixedSize(true)
             isNestedScrollingEnabled = false
-            linear()
+            val gridLayoutManager = GridLayoutManager(requireContext(), 4)
+            gridLayoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
+                override fun getSpanSize(position: Int): Int {
+                    return if (binding.rv.bindingAdapter.isHover(position)) 4 else 1 // 具体的业务逻辑由你确定
+                }
+            }
+            layoutManager = gridLayoutManager
             setup {
-                addType<String>(HOME_TITLE_PROVIDER)
-                addType<FilterSortModel>(HOME_FUNCTION_PROVIDER)
-                addType<HomeBannerListModel>(HOME_BANNER_PROVIDER)
-                addType<CommonSearchModel>(HOME_SEARCH_PROVIDER)
-                addType<CategoryModel>(HOME_CATEGORY_PROVIDER)
-                addType<FoodListModel>(HOME_FOOD_LIST_PROVIDER)
-                onCreate {
-                    if (it == HOME_FOOD_LIST_PROVIDER){
-                        foodRecycle = findView(R.id.food_recycle)
-
-                        (foodRecycle?.itemAnimator as SimpleItemAnimator).supportsChangeAnimations =
-                            false
-                        foodRecycle?.setHasFixedSize(true)
-                        foodRecycle?.isNestedScrollingEnabled = false
-                        foodRecycle?.setRecycledViewPool(recycledViewPool)
-                        foodRecycle?.grid(4)
-                        foodRecycle?.setup {
-                            setHasStableIds(true)
-                            if (isNightTheme()) {
-                                addType<FoodContentModel>(com.develop.common.R.layout.food_content_night_provider)
-                                onBind {
-                                    findView<FoodContentView>(com.develop.common.R.id.food_content_view).setFoodContent(
-                                        getModel()
-                                    )
+                setHasFixedSize(true)
+                addType<HomeHeader>(com.develop.common.R.layout.item_home_header)
+                if (isNightTheme()) {
+                    addType<FoodContentModel>(com.develop.common.R.layout.food_content_night_provider)
+                } else {
+                    addType<FoodContentModel>(com.develop.common.R.layout.food_content_provider)
+                }
+                onBind {
+                    when (itemViewType) {
+                        com.develop.common.R.layout.item_home_header -> {
+                            val model = getModel<HomeHeader>()
+                            //过滤/排序
+                            val filterSortModel = model.filterSortModel
+                            filterSortSearchView =
+                                findView<HomeFilterSortSearchView>(R.id.function_view)
+                            if (filterSortModel != null) {
+                                filterSortSearchView?.apply {
+                                    setVisible()
+                                    if (!viewModel.isSearch) {
+                                        resetView()
+                                    }
+                                    hideOnlineLayout(filterSortModel.isOnLineState)
+                                    onFunctionCallback = functionCallback
                                 }
                             } else {
-                                addType<FoodContentModel>(com.develop.common.R.layout.food_content_provider)
-                                onBind {
-                                    findView<FoodContentView>(com.develop.common.R.id.food_content_view).setFoodContent(
-                                        getModel()
+                                filterSortSearchView?.setGone()
+                            }
+
+                            //分类名称
+                            val categoryName = model.category
+                            val tvCategoryName =
+                                findView<AppCompatTextView>(R.id.tv_food_category_name)
+                            if (categoryName != null) {
+                                tvCategoryName.setVisible()
+                                if (!viewModel.isSearch) {
+                                    tvCategoryName.updateText(
+                                        categoryName
                                     )
                                 }
+                            } else {
+                                tvCategoryName.setGone()
                             }
-                        }
-                        foodRecycle?.setRecyclerListener { holder ->
-                            holder.itemView.findViewById<FoodContentView>(com.develop.common.R.id.food_content_view)
-                                .recycleImageView()
-                        }
-                    }
-                }
-                onBind {
-                    when (itemViewType) {
-                        HOME_TITLE_PROVIDER -> {
-                            if (!viewModel.isSearch) {
-                                findView<AppCompatTextView>(R.id.tv_food_category_name).updateText(
-                                    getModel()
-                                )
-                            }
-                        }
 
-                        HOME_FOOD_LIST_PROVIDER -> {
-                            val models = getModel<FoodListModel>()
-                            foodRecycle?.models = models.foodList
-                        }
+                            //搜索
+                            val commonSearchModel = model.commonSearchModel
+                            val commonSearchLayout =
+                                findView<CommonSearchLayout>(R.id.common_search_view)
+                            if (commonSearchModel != null) {
 
-                        HOME_FUNCTION_PROVIDER -> {
-                            filterSortSearchView =
-                                findView<HomeFilterSortSearchView>(R.id.function_view)
-                            filterSortSearchView?.apply {
-                                if (!viewModel.isSearch) {
-                                    resetView()
+                                commonSearchLayout.apply {
+                                    setVisible()
+                                    updateData(commonSearchModel)
+                                    onHotWordsSelectedListener = hotWordsSelectedCallback
                                 }
-                                hideOnlineLayout(getModel<FilterSortModel>().isOnLineState)
-                                onFunctionCallback = functionCallback
+                            } else {
+                                commonSearchLayout.setGone()
                             }
-                        }
 
-                        HOME_SEARCH_PROVIDER -> {
-                            findView<CommonSearchLayout>(R.id.common_search_view).apply {
-                                updateData(getModel())
-                                onHotWordsSelectedListener = hotWordsSelectedCallback
+                            //搜索的分类
+                            val categoryModel = model.categoryModel
+                            val categoryTabViewLayout =
+                                findView<CategoryTabViewLayout>(R.id.category_tab_view)
+                            if (categoryModel != null) {
+                                categoryTabViewLayout.setVisible()
+                                categoryTabViewLayout.apply {
+                                    updateCategorySize(
+                                        categoryModel.allSize,
+                                        categoryModel.recipesSize,
+                                        categoryModel.ingredientSize
+                                    )
+                                    onCategoryTabSelectedListener = categoryTabSelectedCallback
+                                }
+                            } else {
+                                categoryTabViewLayout.setGone()
                             }
+
                         }
 
-                        HOME_CATEGORY_PROVIDER -> {
-                            findView<CategoryTabViewLayout>(R.id.category_tab_view).apply {
-                                val model = getModel<CategoryModel>()
-                                updateCategorySize(
-                                    model.allSize, model.recipesSize, model.ingredientSize
-                                )
-                                onCategoryTabSelectedListener = categoryTabSelectedCallback
-                            }
+                        com.develop.common.R.layout.food_content_night_provider,
+                        com.develop.common.R.layout.food_content_provider -> {
+                            findView<FoodContentView>(com.develop.common.R.id.food_content_view).setFoodContent(
+                                getModel()
+                            )
                         }
                     }
                 }
@@ -259,6 +268,8 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                 }
             })
         }
+
+
         binding.page.apply {
             setDisableContentWhenRefresh(true)
             setDisableContentWhenLoading(true)
@@ -492,12 +503,12 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
 
             moreLocalRecipeLiveData.observe(viewLifecycleOwner) {
                 Log.d("------", "---222---")
-                foodRecycle?.bindingAdapter?.addModels(it, true)
+                binding.rv.bindingAdapter.addModels(it, true)
                 binding.page.finishLoadMore(0)
             }
 
             moreSearchLocalRecipeLiveData.observe(viewLifecycleOwner) {
-                foodRecycle?.bindingAdapter?.addModels(it, true)
+                binding.rv.bindingAdapter.addModels(it, true)
                 binding.page.finishLoadMore(0)
             }
 

+ 17 - 14
BusinessMain/src/main/java/com/develop/main/viewmodel/HomeViewModel.kt

@@ -182,7 +182,7 @@ class HomeViewModel : BaseViewModel() {
      */
     fun loadMoreLocalRecipes(): Boolean {
         if (hasMoreLocal) {
-            Log.d("------","------")
+            Log.d("------", "------")
             lastLocalRecipeList.clear()
             scope(Dispatchers.IO) {
                 startSize = endSize
@@ -216,7 +216,7 @@ class HomeViewModel : BaseViewModel() {
                         )
                     )
                 }
-                Log.d("------","---111---")
+                Log.d("------", "---111---")
                 moreLocalRecipeLiveData.postValue(foodList)
             }
         } else {
@@ -229,7 +229,8 @@ class HomeViewModel : BaseViewModel() {
     /**根据热词查询菜谱列表信息*/
     fun queryRecipesByHotWord(hotWord: String, categoryType: CategoryType) {
         val result = mutableListOf<Any>()
-        result.add(FilterSortModel(""))
+        val homeHeader = HomeHeader()
+        homeHeader.filterSortModel = FilterSortModel("")
         startSearchSize = 0
         endSearchSize = 11
         startFoodSearchSize = 0
@@ -286,12 +287,13 @@ class HomeViewModel : BaseViewModel() {
 
             lastTotalLocalSearchRecipeList.clear()
             lastTotalLocalSearchRecipeList.addAll(allList)
-            result.add(CategoryModel(recipeCount + foodCount, recipeCount, foodCount))
-            val foodContentList = mutableListOf<FoodContentModel>()
+            homeHeader.categoryModel =
+                CategoryModel(recipeCount + foodCount, recipeCount, foodCount)
+            result.add(homeHeader)
             when (categoryType) {
                 CategoryType.All -> {
                     allList.forEach {
-                        foodContentList.add(
+                        result.add(
                             FoodContentModel(
                                 it.photoPath ?: "",
                                 it.name ?: "",
@@ -307,7 +309,7 @@ class HomeViewModel : BaseViewModel() {
 
                 CategoryType.Recipes -> {
                     localRecipesList.forEach {
-                        foodContentList.add(
+                        result.add(
                             FoodContentModel(
                                 it.photoPath ?: "",
                                 it.name ?: "",
@@ -323,7 +325,7 @@ class HomeViewModel : BaseViewModel() {
 
                 CategoryType.Ingredients -> {
                     fooShowList.forEach {
-                        foodContentList.add(
+                        result.add(
                             FoodContentModel(
                                 it.photoPath ?: "",
                                 it.name ?: "",
@@ -337,7 +339,6 @@ class HomeViewModel : BaseViewModel() {
                     }
                 }
             }
-            result.add(FoodListModel(foodContentList, ""))
             hotWordSearchRecipesLiveData.postValue(result)
         }
     }
@@ -382,13 +383,15 @@ class HomeViewModel : BaseViewModel() {
                 lastLocalSearchFoodList.addAll(newFoods)
             }
             val result = mutableListOf<Any>()
-            result.add(FilterSortModel(""))
-            result.add(CategoryModel(recipeCount + foodCount, recipeCount, foodCount))
+            val homeHeader = HomeHeader()
+            homeHeader.filterSortModel = FilterSortModel("")
+            homeHeader.categoryModel = CategoryModel(recipeCount + foodCount, recipeCount, foodCount)
             val foodContentList = mutableListOf<FoodContentModel>()
+            result.add(homeHeader)
             when (lastSearchCategoryType) {
                 CategoryType.All -> {
                     lastTotalLocalSearchRecipeList.forEach {
-                        foodContentList.add(
+                        result.add(
                             FoodContentModel(
                                 it.photoPath ?: "",
                                 it.name ?: "",
@@ -403,7 +406,7 @@ class HomeViewModel : BaseViewModel() {
 
                 CategoryType.Recipes -> {
                     lastLocalRecipeList.forEach {
-                        foodContentList.add(
+                        result.add(
                             FoodContentModel(
                                 it.photoPath ?: "",
                                 it.name ?: "",
@@ -418,7 +421,7 @@ class HomeViewModel : BaseViewModel() {
 
                 CategoryType.Ingredients -> {
                     lastLocalSearchFoodList.forEach {
-                        foodContentList.add(
+                        result.add(
                             FoodContentModel(
                                 it.photoPath ?: "",
                                 it.name ?: "",

+ 1 - 5
libBase/src/main/java/com/develop/base/ext/GlobaExt.kt

@@ -229,11 +229,7 @@ fun ImageView.load(data: Any?, width: Int, height: Int) {
         .skipMemoryCache(true)
         .override(width, height)
         .dontAnimate()
-        .into(object:SimpleTarget<Drawable>(){
-            override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
-                this@load.setImageDrawable(resource)
-            }
-        })
+        .into(this)
 }
 
 fun ImageView.load(data: Any?, error: Int) {