Browse Source

提交人:jtm
提交内容:bug fixed

江天明 1 year ago
parent
commit
37fc176934
22 changed files with 356 additions and 131 deletions
  1. 3 3
      BusinessAuth/src/main/java/com/develop/auth/ui/UserIconSelectDialog.kt
  2. 5 46
      BusinessCommon/src/main/java/com/develop/common/data_repo/db/DataFactory.kt
  3. 2 2
      BusinessCommon/src/main/java/com/develop/common/dialog/AmountSelectDialog.kt
  4. 1 1
      BusinessCommon/src/main/java/com/develop/common/dialog/CookStepCompleteDialog.kt
  5. 1 1
      BusinessCommon/src/main/java/com/develop/common/dialog/DownloadFailedDialog.kt
  6. 4 4
      BusinessCommon/src/main/java/com/develop/common/dialog/GenderSelectDialog.kt
  7. 1 1
      BusinessCommon/src/main/java/com/develop/common/dialog/NoteEditDialog.kt
  8. 1 1
      BusinessCommon/src/main/java/com/develop/common/dialog/PotCoverUnlockedDialog.kt
  9. 2 2
      BusinessCommon/src/main/java/com/develop/common/dialog/RecipeDeleteConfirmDialog.kt
  10. 1 1
      BusinessCommon/src/main/java/com/develop/common/dialog/ShareQRCodeDialog.kt
  11. 10 1
      BusinessCommon/src/main/java/com/develop/common/widget/FoodContentView.kt
  12. 5 0
      BusinessCommon/src/main/java/com/develop/common/widget/StarView.kt
  13. 21 21
      BusinessCommon/src/main/res/layout/dialog_share_qr_code.xml
  14. 1 1
      BusinessCommon/src/main/res/layout/home_sort_filter_search_view.xml
  15. 27 8
      BusinessMain/src/main/java/com/develop/main/ui/RecipesFragment.kt
  16. 224 12
      BusinessMain/src/main/java/com/develop/main/viewmodel/HomeViewModel.kt
  17. 15 1
      BusinessStep/src/main/java/com/develop/step/ui/recipes_detail/CookDetailActivity.kt
  18. 3 1
      BusinessStep/src/main/java/com/develop/step/viewmodel/FoodListViewModel.kt
  19. 1 1
      app/src/main/AndroidManifest.xml
  20. 5 21
      build.gradle
  21. 2 2
      gradle/wrapper/gradle-wrapper.properties
  22. 21 0
      settings.gradle

+ 3 - 3
BusinessAuth/src/main/java/com/develop/auth/ui/UserIconSelectDialog.kt

@@ -18,10 +18,10 @@ class UserIconSelectDialog(var viewModel: MemberViewModel) : FullScreenTranspare
             inflater, container, false
         )
         binding.ivCancel.setOnClickListener {
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         binding.root.setOnClickListener {
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         settingIconClick(binding.ivIcon1, 0)
         settingIconClick(binding.ivIcon2, 1)
@@ -35,7 +35,7 @@ class UserIconSelectDialog(var viewModel: MemberViewModel) : FullScreenTranspare
     private fun settingIconClick(view: View, index: Int) {
         view.setOnClickListener {
             viewModel.chooseAvatar.value = index
-            dismissAllowingStateLoss()
+            removeSelf()
         }
     }
 }

+ 5 - 46
BusinessCommon/src/main/java/com/develop/common/data_repo/db/DataFactory.kt

@@ -177,50 +177,6 @@ object DataFactory {
         favoriteRecipes.forEach {
             favoriteRecipesIds.add(it.favoriteRecipesId)
         }
-        recipesList.sortWith(Comparator { t, t2 ->
-            when (sortedType) {
-                SortedType.Popular -> {
-                    if ((t.useNum ?: 0) > (t2.useNum ?: 0)) {
-                        return@Comparator -1
-                    } else if ((t.useNum ?: 0) == (t2.useNum ?: 0)) {
-                        return@Comparator 0
-                    } else {
-                        return@Comparator 1
-                    }
-                }
-                SortedType.Newest -> {
-                    if ((t.updateTime ?: 0L) > (t2.updateTime ?: 0L)) {
-                        return@Comparator 1
-                    } else if ((t.updateTime ?: 0L) == (t2.updateTime ?: 0L))
-                        return@Comparator 0
-                    else {
-                        return@Comparator -1
-                    }
-
-                }
-                SortedType.Score -> {
-                    val score1 = t.score?.toInt() ?: 0
-                    val score2 = t2.score?.toInt() ?: 0
-                    if (score1 > score2) {
-                        return@Comparator 1
-                    } else if (score1 == score2) {
-                        return@Comparator 0
-                    } else {
-                        return@Comparator -1
-                    }
-                }
-                SortedType.A2Z -> {
-                    val score1 = t.name?.compareTo(t2.name ?: "") ?: 0
-                    if (score1 > 0) {
-                        return@Comparator 1
-                    } else if (score1 == 0) {
-                        return@Comparator 0
-                    } else {
-                        return@Comparator -1
-                    }
-                }
-            }
-        })
         val foodList = mutableListOf<FoodContentModel>()
         for (i in recipesList.indices) {
             val recipes = recipesList[i]
@@ -247,10 +203,10 @@ object DataFactory {
     fun genSortNameList(resource: Resources): MutableList<FilterSortModel> {
         val result = mutableListOf<FilterSortModel>()
         val sortNameList = mutableListOf(
+            "A-Z",
             resource.getString(R.string.most_popular),
             resource.getString(R.string.newest),
-            "rating",
-            "A-Z"
+            "rating"
         )
         for (name in sortNameList) {
             result.add(FilterSortModel(name))
@@ -305,6 +261,7 @@ object DataFactory {
                         return@Comparator 1
                     }
                 }
+
                 SortedType.Newest -> {
                     if ((t.updateTime ?: 0L) > (t2.updateTime ?: 0L)) {
                         return@Comparator 1
@@ -313,6 +270,7 @@ object DataFactory {
                     }
 
                 }
+
                 SortedType.Score -> {
                     val score1 = t.score?.toInt() ?: 0
                     val score2 = t2.score?.toInt() ?: 0
@@ -322,6 +280,7 @@ object DataFactory {
                         return@Comparator -1
                     }
                 }
+
                 SortedType.A2Z -> {
                     val score1 = t.name?.compareTo(t2.name ?: "") ?: 0
                     if (score1 > 0) {

+ 2 - 2
BusinessCommon/src/main/java/com/develop/common/dialog/AmountSelectDialog.kt

@@ -30,10 +30,10 @@ class AmountSelectDialog(
             inflater, container, false
         )
         binding.ivCancel.setOnClickListener {
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         binding.root.setOnClickListener {
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         val wrappers = mutableListOf<Wrapper>()
         data.forEach {

+ 1 - 1
BusinessCommon/src/main/java/com/develop/common/dialog/CookStepCompleteDialog.kt

@@ -24,7 +24,7 @@ class CookStepCompleteDialog(
         )
         binding.tvOk.setOnClickListener {
             clickOk?.invoke()
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         return binding.root
     }

+ 1 - 1
BusinessCommon/src/main/java/com/develop/common/dialog/DownloadFailedDialog.kt

@@ -21,7 +21,7 @@ class DownloadFailedDialog: FullScreenTransparentDialog() {
             inflater, container, false
         )
         binding.tvOk.setOnClickListener {
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         return binding.root
     }

+ 4 - 4
BusinessCommon/src/main/java/com/develop/common/dialog/GenderSelectDialog.kt

@@ -23,22 +23,22 @@ class GenderSelectDialog(
             inflater, container, false
         )
         binding.root.setOnClickListener {
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         binding.ivCancel.setOnClickListener {
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         binding.tvSelectMale.setOnClickListener {
             binding.tvSelectFemale.isSelected = false
             binding.tvSelectMale.isSelected = true
             onSelect(true)
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         binding.tvSelectFemale.setOnClickListener {
             binding.tvSelectFemale.isSelected = true
             binding.tvSelectMale.isSelected = false
             onSelect(false)
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         binding.tvSelectMale.isSelected = true
         return binding.root

+ 1 - 1
BusinessCommon/src/main/java/com/develop/common/dialog/NoteEditDialog.kt

@@ -33,7 +33,7 @@ class NoteEditDialog: FullScreenTransparentDialog() {
         binding.viewComplete.setOnClickListener {
             listener?.onComplete(binding.etNote.text.toString());
             removeSelf()
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         binding.viewEdit.setOnClickListener {
             binding.etNote.text.clear();

+ 1 - 1
BusinessCommon/src/main/java/com/develop/common/dialog/PotCoverUnlockedDialog.kt

@@ -20,7 +20,7 @@ class PotCoverUnlockedDialog: FullScreenTransparentDialog() {
             inflater, container, false
         )
         binding.ivCancel.setOnClickListener {
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         return binding.root
     }

+ 2 - 2
BusinessCommon/src/main/java/com/develop/common/dialog/RecipeDeleteConfirmDialog.kt

@@ -24,10 +24,10 @@ class RecipeDeleteConfirmDialog(
         )
         binding.tvYes.setOnClickListener {
             onConfirm()
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         binding.tvCancel.setOnClickListener {
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         return binding.root
     }

+ 1 - 1
BusinessCommon/src/main/java/com/develop/common/dialog/ShareQRCodeDialog.kt

@@ -30,7 +30,7 @@ class ShareQRCodeDialog : FullScreenTransparentDialog() {
                 }
             })
         binding.ivCancel.setOnClickListener {
-            dismissAllowingStateLoss()
+            removeSelf()
         }
         return binding.root
     }

+ 10 - 1
BusinessCommon/src/main/java/com/develop/common/widget/FoodContentView.kt

@@ -4,6 +4,7 @@ import android.content.Context
 import android.util.AttributeSet
 import android.view.View
 import android.widget.RelativeLayout
+import com.blankj.utilcode.util.ThreadUtils.runOnUiThread
 import com.develop.base.ext.load
 import com.develop.base.ext.navigateTo
 import com.develop.base.ext.resId2Dimension
@@ -89,8 +90,16 @@ class FoodContentView : RelativeLayout {
         binding.apply {
             ivCover.load(cover)
             tvFoodName.updateText(content.foodName)
+            FoodDataProvider.getUserDatabase().runInTransaction {
+                val result = FoodDataProvider.getUserDatabase().userInfoDao()
+                    .queryUserTag(CURRENT_USER_ID, content.foodId)
+                runOnUiThread {
+                    result?.starCount?.apply {
+                        starView.setStarCount(this)
+                    }
+                }
+            }
             starView.apply {
-                setStarCount(content.starCount)
                 setCommentNumber(content.useNum.toString())
                 setCommentTextColorGray()
             }

+ 5 - 0
BusinessCommon/src/main/java/com/develop/common/widget/StarView.kt

@@ -32,6 +32,11 @@ class StarView : LinearLayout {
         if (starCount > 5 || starCount < 0) {
             starCount = 0
         }
+        binding.star1.load(R.drawable.ic_star_unselected)
+        binding.star2.load(R.drawable.ic_star_unselected)
+        binding.star3.load(R.drawable.ic_star_unselected)
+        binding.star4.load(R.drawable.ic_star_unselected)
+        binding.star5.load(R.drawable.ic_star_unselected)
         when (starCount) {
             1 -> {
                 binding.star1.load(R.drawable.ic_star_selected)

+ 21 - 21
BusinessCommon/src/main/res/layout/dialog_share_qr_code.xml

@@ -12,54 +12,54 @@
 
         <RelativeLayout
             android:id="@+id/cl_layer"
-            android:layout_width="@dimen/convert_780px"
-            android:layout_height="wrap_content"
+            android:layout_width="@dimen/convert_580px"
+            android:layout_height="@dimen/convert_500px"
             android:background="@drawable/bg_icon_page"
-            android:paddingBottom="@dimen/convert_164px"
+            android:gravity="center_horizontal"
             android:orientation="vertical"
-            android:gravity="center_horizontal">
+            android:paddingBottom="@dimen/convert_64px">
 
             <TextView
                 android:id="@+id/tv_title"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:layout_centerHorizontal="true"
+                android:layout_marginTop="@dimen/convert_49px"
+                android:includeFontPadding="false"
                 android:text="@string/share_with_more_people"
-                android:textSize="@dimen/convert_45px"
                 android:textColor="#F30101"
-                android:includeFontPadding="false"
-                android:layout_marginTop="@dimen/convert_89px"
-                android:layout_centerHorizontal="true"/>
+                android:textSize="@dimen/convert_45px" />
 
             <TextView
                 android:id="@+id/tv_subtitle"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:layout_below="@+id/tv_title"
+                android:layout_centerHorizontal="true"
+                android:layout_marginTop="@dimen/convert_48px"
+                android:includeFontPadding="false"
                 android:text="@string/scan_qr_code_with_camera"
-                android:textSize="@dimen/convert_36px"
                 android:textColor="#6B6B6B"
-                android:includeFontPadding="false"
-                android:layout_marginTop="@dimen/convert_48px"
-                android:layout_below="@+id/tv_title"
-                android:layout_centerHorizontal="true"/>
+                android:textSize="@dimen/convert_36px" />
 
             <ImageView
                 android:id="@+id/iv_qr_code"
-                android:layout_width="@dimen/convert_300px"
-                android:layout_height="@dimen/convert_300px"
+                android:layout_width="@dimen/convert_200px"
+                android:layout_height="@dimen/convert_200px"
+                android:layout_below="@+id/tv_subtitle"
                 android:layout_centerHorizontal="true"
-                tools:src="#aaa"
+                android:layout_marginTop="@dimen/convert_50px"
                 android:scaleType="fitCenter"
-                android:layout_below="@+id/tv_subtitle"
-                android:layout_marginTop="@dimen/convert_113px"/>
+                tools:src="#aaa" />
 
             <ProgressBar
                 android:id="@+id/loading"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:layout_below="@+id/tv_subtitle"
                 android:layout_centerHorizontal="true"
-                android:indeterminateTint="#000"
-                android:layout_marginTop="@dimen/convert_200px"
-                android:layout_below="@+id/tv_subtitle"/>
+                android:layout_marginTop="@dimen/convert_100px"
+                android:indeterminateTint="#000" />
 
         </RelativeLayout>
 

+ 1 - 1
BusinessCommon/src/main/res/layout/home_sort_filter_search_view.xml

@@ -66,7 +66,7 @@
                 android:layout_marginEnd="@dimen/convert_50px"
                 android:ellipsize="end"
                 android:singleLine="true"
-                android:text="@string/most_popular"
+                android:text="A-Z"
                 android:textColor="@color/color_1A1A1A"
                 android:textSize="@dimen/convert_30px" />
 

+ 27 - 8
BusinessMain/src/main/java/com/develop/main/ui/RecipesFragment.kt

@@ -20,6 +20,7 @@ import com.develop.base.widgets.CommonPopupWindow
 import com.develop.common.data_repo.db.*
 import com.develop.common.data_repo.db.entity.DevRecipeCategory
 import com.develop.common.databinding.FragmentCommeListBinding
+import com.develop.common.dialog.LoadingDialog
 import com.develop.common.event.RefreshDataEvent
 import com.develop.common.router.Screens
 import com.develop.common.tag.*
@@ -48,6 +49,9 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
     private var currentHotWord = ""
     private var categoryCode: String = ""
 
+    private val loadingDialog  by lazy {
+        LoadingDialog()
+    }
     private var isRefresh = false
 
     private val filterPopupWindow by lazy {
@@ -107,6 +111,11 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
         super.onPostCreateView()
         initView()
         initLiveDataCallback()
+
+    }
+
+    override fun onResume() {
+        super.onResume()
         refreshOnLineOrLocalRecipes()
     }
 
@@ -187,8 +196,9 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
             setOnLoadMoreListener {
                 isRefresh = false
                 if (viewModel.isSearch) {
-                    finishLoadMore(0)
-                    return@setOnLoadMoreListener
+                    if (!viewModel.loadMoreForSearch()) {
+                        finishLoadMore(0)
+                    }
                 }
                 if (viewModel.recipesType == RecipesType.ONLINE) {
                     if (viewModel.currentPage < viewModel.totalPageSize) {
@@ -237,6 +247,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
 
         override fun onInputSearch(searchContent: String) {
             currentHotWord = searchContent
+            loadingDialog.showDialog(childFragmentManager,"loadingDialog")
             if (viewModel.recipesType == RecipesType.ONLINE) {
                 viewModel.getOnLineRecipeList("", currentHotWord)
             } else {
@@ -257,6 +268,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
 
         override fun onOnlineRecipesClick() {
             viewModel.apply {
+                loadingDialog.showDialog(childFragmentManager,"loadingDialog")
                 getOnLineCategoryList()
                 recipesType = RecipesType.ONLINE
                 netFoodLiveData.postValue(true)
@@ -270,6 +282,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
     private var hotWordsSelectedCallback = object : CommonSearchLayout.OnHotWordsSelectedListener {
         override fun onHotWordsSelected(hotWord: String) {
             currentHotWord = hotWord
+            loadingDialog.showDialog(childFragmentManager,"loadingDialog")
             if (viewModel.recipesType == RecipesType.ONLINE) {
                 viewModel.getOnLineRecipeList("", currentHotWord)
             } else {
@@ -285,6 +298,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
     private var categoryTabSelectedCallback =
         object : CategoryTabViewLayout.OnCategoryTabSelectedListener {
             override fun onCurrentSelected(categoryType: CategoryType) {
+                loadingDialog.showDialog(childFragmentManager,"loadingDialog")
                 if (viewModel.recipesType == RecipesType.ONLINE) {
                     viewModel.getOnLineRecipeList("", currentHotWord)
                 } else {
@@ -369,6 +383,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
 
             //获取对应分类菜谱回调
             localRecipesLiveData.observe(viewLifecycleOwner) {
+                loadingDialog.removeSelf()
                 binding.page.apply {
                     finishLoadMore(0)
                 }
@@ -382,6 +397,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
 
             //获取线上菜谱列表回调
             onLineRecipesLiveData.observe(viewLifecycleOwner) {
+                loadingDialog.removeSelf()
                 binding.page.apply {
                     finishLoadMore(0)
                 }
@@ -414,10 +430,11 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
 
             //搜索回调
             hotWordSearchRecipesLiveData.observe(viewLifecycleOwner) {
-                binding.rv.apply {
-                    models = it
-                    scrollToPosition(0)
+                loadingDialog.removeSelf()
+                binding.page.apply {
+                    finishLoadMore(0)
                 }
+                binding.rv.models = it
             }
         }
     }
@@ -425,6 +442,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
 
     /**更新分类名称并获取对应数据*/
     private fun updateCategoryName(devRecipeCategory: DevRecipeCategory) {
+        loadingDialog.showDialog(childFragmentManager,"loadingDialog")
         viewModel.currCategoryName = devRecipeCategory.name ?: ""
         filterSortSearchView?.updateFilterName(
             viewModel.currCategoryName
@@ -442,11 +460,12 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
 
     /**更新分类排序并获取对应数据*/
     private fun updateSortName(pos: Int, needRefresh: Boolean = true) {
+        loadingDialog.showDialog(childFragmentManager,"loadingDialog")
         filterSortSearchView?.updateSortName(
             sortDataList[pos].name
         )
         viewModel.sortedType = when (pos) {
-            0 -> {
+            3 -> {
                 SortedType.Popular
             }
             1 -> {
@@ -455,11 +474,11 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
             2 -> {
                 SortedType.Score
             }
-            3 -> {
+            0 -> {
                 SortedType.A2Z
             }
             else -> {
-                SortedType.Popular
+                SortedType.A2Z
             }
         }
         if (needRefresh) {

+ 224 - 12
BusinessMain/src/main/java/com/develop/main/viewmodel/HomeViewModel.kt

@@ -38,19 +38,46 @@ class HomeViewModel : BaseViewModel() {
     var currentPage = 1
     var currentPageSize = 12
     var totalPageSize = 1
-    var sortedType = SortedType.Popular
+    var sortedType = SortedType.A2Z
     var homeOrBackLiveData = MutableLiveData<HomeOrBack>()
     var isSearch = false
     private val userId = CURRENT_USER_ID
 
     private var totalLocalRecipes = mutableListOf<DevRecipe>()
+    private var totalSearchLocalRecipes = mutableListOf<DevRecipe>()
+    private var searchLocalRecipes = mutableListOf<DevRecipe>()
+    private var searchLocalFood = mutableListOf<DevRecipe>()
+
     private var totalLocalSize = 0
     private var startSize = 0
-    private var endSize = 12
+    private var endSize = 11
+
+    private var totalSearchLocalSize = 0
+    private var searchLocalSize = 0
+    private var foodSize = 0
+    private var startSearchSize = 0
+    private var endSearchSize = 11
+
+    private var startRecipesSearchSize = 0
+    private var endRecipesSearchSize = 11
+
+    private var startFoodSearchSize = 0
+    private var endFoodSearchSize = 11
+
     private var lastLocalRecipesShowList = mutableListOf<Any>()
     private var hasMoreLocal = false
+    private var hasMoreTotalSearchLocal = false
+    private var hasMoreSearchLocal = false
+    private var hasMoreFoodLocal = false
     private var lastLocalRecipeList = mutableListOf<DevRecipe>()
+    private var lastTotalLocalSearchRecipeList = mutableListOf<DevRecipe>()
+    private var lastLocalSearchRecipeList = mutableListOf<DevRecipe>()
+    private var lastLocalSearchFoodList = mutableListOf<DevRecipe>()
     private var localFavoriteRecipesList = mutableListOf<UserFavoriteRecipes>()
+    private var lastSearchCategoryType = CategoryType.All
+
+    private var recipeCount = 0
+    private var foodCount = 0
 
     /**查询本地菜谱分类*/
     fun queryRecipesCategory() {
@@ -65,7 +92,7 @@ class HomeViewModel : BaseViewModel() {
     fun queryLocalRecipes(categoryNum: String) {
         scope(Dispatchers.IO) {
             startSize = 0
-            endSize = 12
+            endSize = 11
             localFavoriteRecipesList =
                 FoodDataProvider.getUserDatabase().userInfoDao().queryFavoriteRecipes(userId)
                     .toMutableList()
@@ -77,6 +104,54 @@ class HomeViewModel : BaseViewModel() {
                     FoodDataProvider.getDatabase().recipeDao().queryRecipesByCategory(categoryNum)
                         .toMutableList()
                 }
+            totalLocalRecipes.sortWith(Comparator { t, t2 ->
+                when (sortedType) {
+                    SortedType.Popular -> {
+                        if ((t.useNum ?: 0) > (t2.useNum ?: 0)) {
+                            return@Comparator -1
+                        } else if ((t.useNum ?: 0) == (t2.useNum ?: 0)) {
+                            return@Comparator 0
+                        } else {
+                            return@Comparator 1
+                        }
+                    }
+
+                    SortedType.Newest -> {
+                        if ((t.updateTime ?: 0L) > (t2.updateTime ?: 0L)) {
+                            return@Comparator 1
+                        } else if ((t.updateTime ?: 0L) == (t2.updateTime
+                                ?: 0L)
+                        ) return@Comparator 0
+                        else {
+                            return@Comparator -1
+                        }
+
+                    }
+
+                    SortedType.Score -> {
+                        val score1 = t.score?.toInt() ?: 0
+                        val score2 = t2.score?.toInt() ?: 0
+                        if (score1 > score2) {
+                            return@Comparator 1
+                        } else if (score1 == score2) {
+                            return@Comparator 0
+                        } else {
+                            return@Comparator -1
+                        }
+                    }
+
+                    SortedType.A2Z -> {
+                        val score1 = t.name?.compareTo(t2.name ?: "") ?: 0
+                        if (score1 > 0) {
+                            return@Comparator 1
+                        } else if (score1 == 0) {
+                            return@Comparator 0
+                        } else {
+                            return@Comparator -1
+                        }
+                    }
+                }
+            })
             totalLocalSize = totalLocalRecipes.size
             val localRecipeList = if (totalLocalSize < 12) {
                 hasMoreLocal = false
@@ -124,11 +199,20 @@ class HomeViewModel : BaseViewModel() {
     fun queryRecipesByHotWord(hotWord: String, categoryType: CategoryType) {
         val result = mutableListOf<Any>()
         result.add(FilterSortModel(""))
-        FoodDataProvider.getDatabase().runInTransaction {
+        startSearchSize = 0
+        endSearchSize = 11
+        startFoodSearchSize = 0
+        endFoodSearchSize = 11
+        startRecipesSearchSize = 0
+        endRecipesSearchSize = 11
+        totalSearchLocalRecipes.clear()
+        searchLocalRecipes.clear()
+        searchLocalFood.clear()
+        lastSearchCategoryType = categoryType
+        scope(Dispatchers.IO) {
             val recipeDao = FoodDataProvider.getDatabase().recipeDao()
             val recipesList = recipeDao.queryRecipeByName(hotWord)
             val foodList = mutableListOf<DevRecipe>()
-            val allList = mutableListOf<DevRecipe>()
             recipeDao.queryFoodByFoodName(hotWord).forEach {
                 it.recipeNumber?.apply {
                     recipeDao.queryRecipe(this)?.let { devRecipe ->
@@ -136,10 +220,41 @@ class HomeViewModel : BaseViewModel() {
                     }
                 }
             }
-            val recipeCount = recipesList.size
-            val foodCount = foodList.size
-            allList.addAll(recipesList)
-            allList.addAll(foodList)
+            recipeCount = recipesList.size
+            foodCount = foodList.size
+            totalSearchLocalRecipes.addAll(recipesList)
+            totalSearchLocalRecipes.addAll(foodList)
+            totalSearchLocalSize = totalSearchLocalRecipes.size
+            searchLocalSize = recipeCount
+            foodSize = foodCount
+            searchLocalFood.addAll(foodList)
+
+            searchLocalRecipes.addAll(recipesList)
+            val allList: MutableList<DevRecipe> = if (totalSearchLocalSize < 12) {
+                hasMoreTotalSearchLocal = false
+                totalSearchLocalRecipes
+            } else {
+                hasMoreTotalSearchLocal = true
+                totalSearchLocalRecipes.subList(0, 12)
+            }
+            val localRecipesList = if (recipeCount < 12) {
+                hasMoreSearchLocal = false
+                searchLocalRecipes
+            } else {
+                hasMoreSearchLocal = true
+                searchLocalRecipes.subList(0, 12)
+            }
+
+            val fooShowList = if (foodSize < 12) {
+                hasMoreFoodLocal = false
+                foodList
+            } else {
+                hasMoreFoodLocal = true
+                foodList.subList(0, 12)
+            }
+
+            lastTotalLocalSearchRecipeList.clear()
+            lastTotalLocalSearchRecipeList.addAll(allList)
             result.add(CategoryModel(recipeCount + foodCount, recipeCount, foodCount))
             val foodContentList = mutableListOf<FoodContentModel>()
             when (categoryType) {
@@ -157,8 +272,9 @@ class HomeViewModel : BaseViewModel() {
                         )
                     }
                 }
+
                 CategoryType.Recipes -> {
-                    recipesList.forEach {
+                    localRecipesList.forEach {
                         foodContentList.add(
                             FoodContentModel(
                                 it.photoPath ?: "",
@@ -171,8 +287,9 @@ class HomeViewModel : BaseViewModel() {
                         )
                     }
                 }
+
                 CategoryType.Ingredients -> {
-                    foodList.forEach {
+                    fooShowList.forEach {
                         foodContentList.add(
                             FoodContentModel(
                                 it.photoPath ?: "",
@@ -186,11 +303,106 @@ class HomeViewModel : BaseViewModel() {
                     }
                 }
             }
-            result.add(FoodListModel(foodContentList,""))
+            result.add(FoodListModel(foodContentList, ""))
             hotWordSearchRecipesLiveData.postValue(result)
         }
     }
 
+    fun loadMoreForSearch(): Boolean {
+        if (hasMoreTotalSearchLocal) {
+            startSearchSize = endSearchSize
+            endSearchSize = startSearchSize + 12
+
+            startRecipesSearchSize = endRecipesSearchSize
+            endRecipesSearchSize = startRecipesSearchSize + 12
+
+            startFoodSearchSize = endFoodSearchSize
+            endFoodSearchSize = startFoodSearchSize + 12
+
+            if (endSearchSize > totalSearchLocalSize) {
+                endSearchSize = totalSearchLocalSize
+                hasMoreTotalSearchLocal = false
+            }
+            if (endRecipesSearchSize > searchLocalSize) {
+                endRecipesSearchSize = searchLocalSize
+                hasMoreSearchLocal = false
+            }
+            if (endFoodSearchSize > foodSize) {
+                endFoodSearchSize = foodSize
+                hasMoreFoodLocal = false
+            }
+            val newTotal = totalSearchLocalRecipes.subList(
+                startSearchSize, endSearchSize
+            )
+            lastTotalLocalSearchRecipeList.addAll(newTotal)
+            if (hasMoreSearchLocal) {
+                val newRecipes = searchLocalRecipes.subList(
+                    startRecipesSearchSize, endRecipesSearchSize
+                )
+                lastLocalSearchRecipeList.addAll(newRecipes)
+            }
+            if (hasMoreFoodLocal) {
+                val newFoods = searchLocalFood.subList(startFoodSearchSize, endFoodSearchSize)
+                lastLocalSearchFoodList.addAll(newFoods)
+            }
+            val result = mutableListOf<Any>()
+            result.add(FilterSortModel(""))
+            result.add(CategoryModel(recipeCount + foodCount, recipeCount, foodCount))
+            val foodContentList = mutableListOf<FoodContentModel>()
+            when (lastSearchCategoryType) {
+                CategoryType.All -> {
+                    lastTotalLocalSearchRecipeList.forEach {
+                        foodContentList.add(
+                            FoodContentModel(
+                                it.photoPath ?: "",
+                                it.name ?: "",
+                                3,
+                                getTime(it.makeHours ?: 0, it.makeMinutes ?: 0),
+                                it.difficultyLevel ?: "",
+                                foodId = it.number ?: ""
+                            )
+                        )
+                    }
+                }
+
+                CategoryType.Recipes -> {
+                    lastLocalRecipeList.forEach {
+                        foodContentList.add(
+                            FoodContentModel(
+                                it.photoPath ?: "",
+                                it.name ?: "",
+                                3,
+                                getTime(it.makeHours ?: 0, it.makeMinutes ?: 0),
+                                it.difficultyLevel ?: "",
+                                foodId = it.number ?: ""
+                            )
+                        )
+                    }
+                }
+
+                CategoryType.Ingredients -> {
+                    lastLocalSearchFoodList.forEach {
+                        foodContentList.add(
+                            FoodContentModel(
+                                it.photoPath ?: "",
+                                it.name ?: "",
+                                3,
+                                getTime(it.makeHours ?: 0, it.makeMinutes ?: 0),
+                                it.difficultyLevel ?: "",
+                                foodId = it.number ?: ""
+                            )
+                        )
+                    }
+                }
+            }
+            result.add(FoodListModel(foodContentList, ""))
+            hotWordSearchRecipesLiveData.postValue(result)
+        } else {
+            return false
+        }
+        return true
+    }
+
     /**获取线上的菜谱分类*/
     fun getOnLineCategoryList() {
         scopeNetLife {

+ 15 - 1
BusinessStep/src/main/java/com/develop/step/ui/recipes_detail/CookDetailActivity.kt

@@ -261,14 +261,17 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
                 binding.ivTab1.isSelected = true
                 replaceFragmentInstance(R.id.fl_tab_content, CookDetailSourceFragment())
             }
+
             TAB_DESC -> {
                 binding.ivTab2.isSelected = true
                 replaceFragmentInstance(R.id.fl_tab_content, CookDetailDescFragment())
             }
+
             TAB_TOOLS -> {
                 binding.ivTab3.isSelected = true
                 replaceFragmentInstance(R.id.fl_tab_content, CookDetailToolsFragment())
             }
+
             TAB_SERVE -> {
                 binding.ivTab4.isSelected = true
                 replaceFragmentInstance(R.id.fl_tab_content, CookDetailServeFragment())
@@ -308,7 +311,16 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
         binding.tvFoodTime.text = timeDescBuilder.toString()
         binding.tvEasy.text = detail.recipe.difficultyLevel
         binding.startLayout.setCommentNumber(detail.recipe.useNum.toString())
-        detail.recipe.score?.let { binding.startLayout.setStarCount(it.toInt()) }
+        FoodDataProvider.getUserDatabase().runInTransaction {
+           val result =  FoodDataProvider.getUserDatabase().userInfoDao()
+                .queryUserTag(CURRENT_USER_ID, detail.recipe.number ?: "")
+           runOnUiThread {
+               result?.starCount?.apply {
+                   binding.startLayout.setStarCount(this)
+               }
+           }
+        }
+//        detail.recipe.score?.let { binding.startLayout.setStarCount(it.toInt()) }
     }
 
     @Suppress("UNCHECKED_CAST")
@@ -327,6 +339,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
                 binding.viewIcon.setImageResource(com.develop.common.R.drawable.ic_detail_cook_download)
                 downloadFileDialog.showDialog(supportFragmentManager, "DownloadFailedDialog")
             }
+
             Resource.Status.LOADING -> {
                 val updateProgress = "${resource.data}%"
                 binding.tvDownload.setGone()
@@ -338,6 +351,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
                 binding.viewProgress.setButtonColor(Color.parseColor("#CC79C414"))
                 binding.viewIcon.setImageResource(com.develop.common.R.drawable.ic_detail_cook_download)
             }
+
             else -> {
                 binding.tvDownload.setVisible()
                 binding.viewIcon.setVisible()

+ 3 - 1
BusinessStep/src/main/java/com/develop/step/viewmodel/FoodListViewModel.kt

@@ -35,7 +35,9 @@ class FoodListViewModel : BaseViewModel() {
         val dataList = mutableListOf<FoodContentModel>()
         val favoriteRecipesIds = mutableListOf<String>()
         userDao.queryFavoriteRecipes(CURRENT_USER_ID).forEach {
-            recipesIdList.add(it.favoriteRecipesId)
+            if (foodListType == Favourite) {
+                recipesIdList.add(it.favoriteRecipesId)
+            }
             favoriteRecipesIds.add(it.favoriteRecipesId)
         }
         if (foodListType == History) {

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
-    android:sharedUserId="android.uid.system"
+
     package="com.develop.foodcooking">
 
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

+ 5 - 21
build.gradle

@@ -1,30 +1,14 @@
 buildscript {
-    ext.kotlin_version = "1.5.20"
-    repositories {
-        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
-        google()
-        mavenCentral()
-    }
     dependencies {
-        classpath "com.android.tools.build:gradle:4.2.2"
         classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
-        classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
+        classpath "org.jetbrains.kotlin:kotlin-serialization:1.7.20"
         classpath "com.alibaba:arouter-register:1.0.2"
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
     }
 }
-
-allprojects {
-    repositories {
-        google()
-        mavenCentral()
-        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
-        jcenter()
-        maven { url 'https://www.jitpack.io' }
-    }
-}
-
-task clean(type: Delete) {
-    delete rootProject.buildDir
+plugins {
+    id 'com.android.application' version '7.3.1' apply false
+    id 'com.android.library' version '7.3.1' apply false
+    id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
 }

+ 2 - 2
gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
-#Sat Sep 18 17:34:46 CST 2021
+#Mon Mar 06 15:28:11 CST 2023
 distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
 distributionPath=wrapper/dists
 zipStorePath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME

+ 21 - 0
settings.gradle

@@ -1,3 +1,24 @@
+pluginManagement {
+    repositories {
+        maven { url 'https://jitpack.io' }
+        maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
+        maven { url 'https://maven.aliyun.com/repository/public' }
+        gradlePluginPortal()
+        google()
+        mavenCentral()
+    }
+}
+dependencyResolutionManagement {
+    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+    repositories {
+        maven { url 'https://jitpack.io' }
+        maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
+        maven { url 'https://maven.aliyun.com/repository/public' }
+        google()
+        mavenCentral()
+    }
+}
+
 rootProject.name = "FoodCooking_Android"
 include ':app'
 include ':libBase'