|
@@ -1,6 +1,7 @@
|
|
|
package com.develop.main.ui
|
|
|
|
|
|
|
|
|
+import android.media.metrics.Event
|
|
|
import android.os.Bundle
|
|
|
import android.util.SparseIntArray
|
|
|
import android.view.LayoutInflater
|
|
@@ -18,6 +19,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.event.RefreshDataEvent
|
|
|
import com.develop.common.router.Screens
|
|
|
import com.develop.common.tag.*
|
|
|
import com.develop.common.ui.CommonBVMFragment
|
|
@@ -30,6 +32,8 @@ import com.drake.brv.utils.grid
|
|
|
import com.drake.brv.utils.linear
|
|
|
import com.drake.brv.utils.models
|
|
|
import com.drake.brv.utils.setup
|
|
|
+import org.greenrobot.eventbus.EventBus
|
|
|
+import org.greenrobot.eventbus.Subscribe
|
|
|
|
|
|
class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewModel>() {
|
|
|
|
|
@@ -94,6 +98,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
|
|
|
override fun createViewBinding(
|
|
|
inflater: LayoutInflater, container: ViewGroup?
|
|
|
): FragmentCommeListBinding {
|
|
|
+ EventBus.getDefault().register(this)
|
|
|
return FragmentCommeListBinding.inflate(inflater, container, false)
|
|
|
}
|
|
|
|
|
@@ -104,6 +109,11 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
|
|
|
refreshOnLineOrLocalRecipes()
|
|
|
}
|
|
|
|
|
|
+ override fun onDestroy() {
|
|
|
+ super.onDestroy()
|
|
|
+ EventBus.getDefault().unregister(this)
|
|
|
+ }
|
|
|
+
|
|
|
private fun initView() {
|
|
|
sortDataList.addAll(DataFactory.genSortNameList(resources))
|
|
|
|
|
@@ -481,4 +491,9 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
|
|
|
var checkedColor = com.develop.common.R.color.color_F4A12E
|
|
|
var unCheckedColor = com.develop.common.R.color.color_6B6B6B
|
|
|
}
|
|
|
+
|
|
|
+ @Subscribe
|
|
|
+ fun refreshRecipes(event:RefreshDataEvent) {
|
|
|
+ refreshOnLineOrLocalRecipes()
|
|
|
+ }
|
|
|
}
|