|
@@ -3,6 +3,7 @@ package com.develop.main.ui
|
|
|
|
|
|
import android.graphics.Color
|
|
|
import android.os.Bundle
|
|
|
+import android.util.Log
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
@@ -161,36 +162,6 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
|
|
|
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 {
|
|
|
- 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()
|
|
|
- )
|
|
|
- }
|
|
|
- } else {
|
|
|
- addType<FoodContentModel>(com.develop.common.R.layout.food_content_provider)
|
|
|
- onBind {
|
|
|
- findView<FoodContentView>(com.develop.common.R.id.food_content_view).setFoodContent(
|
|
|
- getModel()
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
onBind {
|
|
|
when (itemViewType) {
|
|
|
HOME_TITLE_PROVIDER -> {
|
|
@@ -202,8 +173,33 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
|
|
|
}
|
|
|
|
|
|
HOME_FOOD_LIST_PROVIDER -> {
|
|
|
- val foodListModel = getModel<FoodListModel>()
|
|
|
- foodRecycle?.models = foodListModel.foodList
|
|
|
+ val models = getModel<FoodListModel>()
|
|
|
+ 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 {
|
|
|
+ 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()
|
|
|
+ )
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ addType<FoodContentModel>(com.develop.common.R.layout.food_content_provider)
|
|
|
+ onBind {
|
|
|
+ findView<FoodContentView>(com.develop.common.R.id.food_content_view).setFoodContent(
|
|
|
+ getModel()
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }?.models = models.foodList
|
|
|
}
|
|
|
|
|
|
HOME_FUNCTION_PROVIDER -> {
|
|
@@ -485,13 +481,14 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
|
|
|
}
|
|
|
|
|
|
moreLocalRecipeLiveData.observe(viewLifecycleOwner) {
|
|
|
+ Log.d("------", "---222---")
|
|
|
binding.page.finishLoadMore(0)
|
|
|
- foodRecycle?.addModels(it, false)
|
|
|
+ foodRecycle?.bindingAdapter?.addModels(it, true)
|
|
|
}
|
|
|
|
|
|
moreSearchLocalRecipeLiveData.observe(viewLifecycleOwner) {
|
|
|
binding.page.finishLoadMore(0)
|
|
|
- foodRecycle?.addModels(it, false)
|
|
|
+ foodRecycle?.bindingAdapter?.addModels(it, true)
|
|
|
}
|
|
|
|
|
|
//获取线上分类回调
|
|
@@ -525,7 +522,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
|
|
|
}
|
|
|
loadingDialog.removeSelf()
|
|
|
}
|
|
|
- errorCallback.observe(viewLifecycleOwner){
|
|
|
+ errorCallback.observe(viewLifecycleOwner) {
|
|
|
GlobalToast.showToast(getString(com.develop.common.R.string.network_error))
|
|
|
loadingDialog.removeSelf()
|
|
|
}
|