|
@@ -2,10 +2,7 @@ package com.develop.main.ui
|
|
|
|
|
|
|
|
|
import android.graphics.Color
|
|
|
-import android.media.metrics.Event
|
|
|
import android.os.Bundle
|
|
|
-import android.util.Log
|
|
|
-import android.util.SparseIntArray
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
@@ -13,14 +10,13 @@ import android.widget.RelativeLayout
|
|
|
import androidx.appcompat.widget.AppCompatTextView
|
|
|
import androidx.cardview.widget.CardView
|
|
|
import androidx.databinding.ViewDataBinding
|
|
|
-import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
+import androidx.recyclerview.widget.SimpleItemAnimator
|
|
|
import com.bumptech.glide.Glide
|
|
|
import com.develop.base.ext.background_color
|
|
|
import com.develop.base.ext.background_drawable
|
|
|
import com.develop.base.ext.globalApp
|
|
|
import com.develop.base.ext.isNightTheme
|
|
|
-import com.develop.base.ext.layout_width
|
|
|
import com.develop.base.ext.navigateTo
|
|
|
import com.develop.base.ext.resId2Dimension
|
|
|
import com.develop.base.ext.text_color
|
|
@@ -36,20 +32,16 @@ import com.develop.common.tag.*
|
|
|
import com.develop.common.ui.CommonBVMFragment
|
|
|
import com.develop.common.widget.*
|
|
|
import com.develop.main.R
|
|
|
-import com.develop.main.databinding.FoodGridViewBinding
|
|
|
import com.develop.main.databinding.ItemFilterAndSortViewBinding
|
|
|
import com.develop.main.viewmodel.HomeViewModel
|
|
|
import com.drake.brv.BindingAdapter
|
|
|
-import com.drake.brv.listener.OnMultiStateListener
|
|
|
import com.drake.brv.utils.*
|
|
|
-import com.drake.net.time.Interval
|
|
|
import com.drake.net.utils.scopeNet
|
|
|
-import com.scwang.smart.refresh.layout.api.RefreshLayout
|
|
|
-import com.scwang.smart.refresh.layout.listener.OnMultiListener
|
|
|
import kotlinx.coroutines.delay
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
|
|
|
+
|
|
|
class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewModel>() {
|
|
|
|
|
|
private var filterSortSearchView: HomeFilterSortSearchView? = null
|
|
@@ -155,6 +147,8 @@ 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
|
|
@@ -169,24 +163,29 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
|
|
|
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 {
|
|
|
- addType<FoodContentModel>(com.develop.common.R.layout.food_content_provider)
|
|
|
- onBind {
|
|
|
- if (isNightTheme()) {
|
|
|
- findView<CardView>(com.develop.common.R.id.recipes_layout).apply {
|
|
|
- cardElevation = 0f
|
|
|
- maxCardElevation = 0f
|
|
|
- }
|
|
|
+ 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()
|
|
|
+ )
|
|
|
}
|
|
|
-
|
|
|
- findView<FoodContentView>(com.develop.common.R.id.food_content_view).setFoodContent(
|
|
|
- getModel()
|
|
|
- )
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -253,6 +252,8 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
|
|
|
})
|
|
|
}
|
|
|
binding.page.apply {
|
|
|
+ setDisableContentWhenRefresh(true)
|
|
|
+ setDisableContentWhenLoading(true)
|
|
|
setEnableRefresh(false)
|
|
|
setEnableNestedScroll(false)
|
|
|
setOnLoadMoreListener {
|
|
@@ -282,6 +283,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
|
|
|
if (isNightTheme()){
|
|
|
binding.footer.apply {
|
|
|
setPrimaryColor(Color.parseColor("#1A1A1A"))
|
|
|
+ setFinishDuration(0)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -481,13 +483,13 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
|
|
|
}
|
|
|
|
|
|
moreLocalRecipeLiveData.observe(viewLifecycleOwner) {
|
|
|
- foodRecycle?.addModels(it)
|
|
|
binding.page.finishLoadMore(true)
|
|
|
+ foodRecycle?.addModels(it)
|
|
|
}
|
|
|
|
|
|
moreSearchLocalRecipeLiveData.observe(viewLifecycleOwner) {
|
|
|
- foodRecycle?.addModels(it)
|
|
|
binding.page.finishLoadMore(true)
|
|
|
+ foodRecycle?.addModels(it)
|
|
|
}
|
|
|
|
|
|
//获取线上分类回调
|