|
@@ -3,9 +3,15 @@ package com.develop.main.ui
|
|
|
import android.os.Bundle
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.ViewGroup.LayoutParams
|
|
|
+import android.widget.ImageView
|
|
|
+import androidx.appcompat.widget.AppCompatTextView
|
|
|
import androidx.lifecycle.MutableLiveData
|
|
|
+import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
+import com.develop.base.ext.isNightTheme
|
|
|
import com.develop.base.ext.navigateTo
|
|
|
+import com.develop.base.ext.src
|
|
|
+import com.develop.base.ext.updateText
|
|
|
import com.develop.common.data_repo.FoodDataProvider
|
|
|
import com.develop.base.util.MMkvUtils
|
|
|
import com.develop.common.data_repo.db.DataFactory
|
|
@@ -21,6 +27,7 @@ import com.develop.common.widget.EntranceType
|
|
|
import com.develop.main.R
|
|
|
import com.develop.main.databinding.ActivityModeEntranceBinding
|
|
|
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 com.smarx.notchlib.utils.ScreenUtil
|
|
@@ -57,66 +64,128 @@ class ModeEntranceActivity : CommonBindingActivity<ActivityModeEntranceBinding>(
|
|
|
finish()
|
|
|
}
|
|
|
}
|
|
|
- binding.entranceRecycle.apply {
|
|
|
- grid(2)
|
|
|
- setup {
|
|
|
- addType<EntranceData>(R.layout.item_entrance)
|
|
|
- onBind {
|
|
|
- val itemView = findView<EntranceItemView>(R.id.entrance_item)
|
|
|
- val params = itemView.layoutParams as LayoutParams
|
|
|
- params.height = (ScreenUtil.getScreenSize(this@ModeEntranceActivity)[1] / 2)
|
|
|
- itemView.layoutParams = params
|
|
|
- itemView.setEntranceData(getModel())
|
|
|
|
|
|
- }
|
|
|
- R.id.entrance_item.onClick {
|
|
|
- val clickModel = getModel<EntranceData>()
|
|
|
- title = getString(clickModel.title2StrId)
|
|
|
- when (clickModel.type) {
|
|
|
- EntranceType.automatic_recipes -> {
|
|
|
- if (FoodDataProvider.checkDataExit()) {
|
|
|
+ if (isNightTheme()){
|
|
|
+ binding.entranceRecycle.apply {
|
|
|
+ linear(RecyclerView.HORIZONTAL)
|
|
|
+ setup {
|
|
|
+ addType<EntranceData>(com.develop.common.R.layout.item_entrance_night_view)
|
|
|
+ onBind {
|
|
|
+ val model = getModel<EntranceData>()
|
|
|
+ findView<ImageView>(com.develop.common.R.id.iv_bg).src = model.bgResId
|
|
|
+ findView<AppCompatTextView>(com.develop.common.R.id.tv_title).setText(model.titleStrId)
|
|
|
+ }
|
|
|
+ R.id.content_view.onClick {
|
|
|
+ val clickModel = getModel<EntranceData>()
|
|
|
+ title = getString(clickModel.title2StrId)
|
|
|
+ when (clickModel.type) {
|
|
|
+ EntranceType.automatic_recipes -> {
|
|
|
+ if (FoodDataProvider.checkDataExit()) {
|
|
|
+ val bundle = Bundle()
|
|
|
+ bundle.putInt(MODE_ENTRANCE, Recipes)
|
|
|
+ bundle.putInt(RECIPES_TYPE, LocalFood)
|
|
|
+ bundle.putString(HOME_TITLE, title)
|
|
|
+ navigateTo(Screens.Main.HOME) {
|
|
|
+ with(bundle)
|
|
|
+ }
|
|
|
+ finish()
|
|
|
+ } else {
|
|
|
+ showLoading()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ EntranceType.automatic_programmes -> {
|
|
|
+ val bundle = Bundle()
|
|
|
+ bundle.putInt(MODE_ENTRANCE, Mode)
|
|
|
+ bundle.putString(HOME_TITLE, title)
|
|
|
+ navigateTo(Screens.Main.HOME) {
|
|
|
+ with(bundle)
|
|
|
+ }
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ EntranceType.manual_cooking -> {
|
|
|
+ navigateTo(Screens.Cook.COOK_MODES) {
|
|
|
+ val bundle = Bundle()
|
|
|
+ bundle.putString(MODE_TYPE, "ADAPTED_COOKING")
|
|
|
+ with(bundle)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ EntranceType.download_new_recipes -> {
|
|
|
val bundle = Bundle()
|
|
|
bundle.putInt(MODE_ENTRANCE, Recipes)
|
|
|
- bundle.putInt(RECIPES_TYPE, LocalFood)
|
|
|
+ bundle.putInt(RECIPES_TYPE, NetFood)
|
|
|
bundle.putString(HOME_TITLE, title)
|
|
|
navigateTo(Screens.Main.HOME) {
|
|
|
with(bundle)
|
|
|
}
|
|
|
finish()
|
|
|
- } else {
|
|
|
- showLoading()
|
|
|
}
|
|
|
}
|
|
|
- EntranceType.automatic_programmes -> {
|
|
|
- val bundle = Bundle()
|
|
|
- bundle.putInt(MODE_ENTRANCE, Mode)
|
|
|
- bundle.putString(HOME_TITLE, title)
|
|
|
- navigateTo(Screens.Main.HOME) {
|
|
|
- with(bundle)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.models = DataFactory.getEntranceData()
|
|
|
+ } else {
|
|
|
+ binding.entranceRecycle.apply {
|
|
|
+ grid(2)
|
|
|
+ setup {
|
|
|
+ addType<EntranceData>(R.layout.item_entrance)
|
|
|
+ onBind {
|
|
|
+ val itemView = findView<EntranceItemView>(R.id.entrance_item)
|
|
|
+ val params = itemView.layoutParams as LayoutParams
|
|
|
+ params.height = (ScreenUtil.getScreenSize(this@ModeEntranceActivity)[1] / 2)
|
|
|
+ itemView.layoutParams = params
|
|
|
+ itemView.setEntranceData(getModel())
|
|
|
+
|
|
|
+ }
|
|
|
+ R.id.entrance_item.onClick {
|
|
|
+ val clickModel = getModel<EntranceData>()
|
|
|
+ title = getString(clickModel.title2StrId)
|
|
|
+ when (clickModel.type) {
|
|
|
+ EntranceType.automatic_recipes -> {
|
|
|
+ if (FoodDataProvider.checkDataExit()) {
|
|
|
+ val bundle = Bundle()
|
|
|
+ bundle.putInt(MODE_ENTRANCE, Recipes)
|
|
|
+ bundle.putInt(RECIPES_TYPE, LocalFood)
|
|
|
+ bundle.putString(HOME_TITLE, title)
|
|
|
+ navigateTo(Screens.Main.HOME) {
|
|
|
+ with(bundle)
|
|
|
+ }
|
|
|
+ finish()
|
|
|
+ } else {
|
|
|
+ showLoading()
|
|
|
+ }
|
|
|
}
|
|
|
- finish()
|
|
|
- }
|
|
|
- EntranceType.manual_cooking -> {
|
|
|
- navigateTo(Screens.Cook.COOK_MODES) {
|
|
|
+ EntranceType.automatic_programmes -> {
|
|
|
val bundle = Bundle()
|
|
|
- bundle.putString(MODE_TYPE, "ADAPTED_COOKING")
|
|
|
- with(bundle)
|
|
|
+ bundle.putInt(MODE_ENTRANCE, Mode)
|
|
|
+ bundle.putString(HOME_TITLE, title)
|
|
|
+ navigateTo(Screens.Main.HOME) {
|
|
|
+ with(bundle)
|
|
|
+ }
|
|
|
+ finish()
|
|
|
}
|
|
|
- }
|
|
|
- EntranceType.download_new_recipes -> {
|
|
|
- val bundle = Bundle()
|
|
|
- bundle.putInt(MODE_ENTRANCE, Recipes)
|
|
|
- bundle.putInt(RECIPES_TYPE, NetFood)
|
|
|
- bundle.putString(HOME_TITLE, title)
|
|
|
- navigateTo(Screens.Main.HOME) {
|
|
|
- with(bundle)
|
|
|
+ EntranceType.manual_cooking -> {
|
|
|
+ navigateTo(Screens.Cook.COOK_MODES) {
|
|
|
+ val bundle = Bundle()
|
|
|
+ bundle.putString(MODE_TYPE, "ADAPTED_COOKING")
|
|
|
+ with(bundle)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ EntranceType.download_new_recipes -> {
|
|
|
+ val bundle = Bundle()
|
|
|
+ bundle.putInt(MODE_ENTRANCE, Recipes)
|
|
|
+ bundle.putInt(RECIPES_TYPE, NetFood)
|
|
|
+ bundle.putString(HOME_TITLE, title)
|
|
|
+ navigateTo(Screens.Main.HOME) {
|
|
|
+ with(bundle)
|
|
|
+ }
|
|
|
+ finish()
|
|
|
}
|
|
|
- finish()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- }.models = DataFactory.getEntranceData()
|
|
|
+ }.models = DataFactory.getEntranceData()
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
override fun onResume() {
|