优化设备配置提交菜品页面数据刷新和显示位置、未配置调料增加提示

This commit is contained in:
2025-09-16 14:35:49 +08:00
parent e269e75bc6
commit 7ac095c56e
20 changed files with 716 additions and 1468 deletions
@@ -9,6 +9,7 @@ import android.text.style.LineHeightSpan
import android.text.style.StyleSpan
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.graphics.toColorInt
@@ -68,35 +69,39 @@ class TextCellAdapter(var list: MutableList<SeasoningEntity>) :
var onCellClick: ((positon: Int) -> Unit)? = null
companion object {
fun loadLayout(frameLayout: FrameLayout, item: SeasoningEntity) {
val child: TextView = frameLayout.getChildAt(0) as TextView
child.text = getTextSpan(item)
}
fun loadCell(tvCell: TextView, item: SeasoningEntity) {
tvCell.text = getTextSpan(item)
}
fun loadCell2(tvCell: TextView, item: SeasoningEntity) {
if (item.goodsName.isNullOrBlank()) {
tvCell.run {
text = buildSpannableString {
appendText(
"未配置",
ForegroundColorSpan("#999999".toColorInt()),
StyleSpan(Typeface.BOLD),
AbsoluteSizeSpan(28, true),
LineHeightSpan { text, start, end, spanstartv, v, fm ->
fm.descent += 10.dp // 增加行间距
}
)}
//setTextColor(ContextCompat.getColor(context, R.color.black999))
}
} else {
// if (item.pageType == 1) {
// fun loadCell2(tvCell: TextView, item: SeasoningEntity) {
// if (item.goodsName.isNullOrBlank()) {
// tvCell.run {
// text = item.goodsName
// setTextColor(ContextCompat.getColor(context, R.color.black))
// text = buildSpannableString {
// appendText(
// "未配置",
// ForegroundColorSpan("#999999".toColorInt()),
// StyleSpan(Typeface.BOLD),
// AbsoluteSizeSpan(28, true),
// LineHeightSpan { text, start, end, spanstartv, v, fm ->
// fm.descent += 10.dp // 增加行间距
// }
// )}
// //setTextColor(ContextCompat.getColor(context, R.color.black999))
// }
// } else {
tvCell.text = getTextSpan(item)
//// if (item.pageType == 1) {
//// tvCell.run {
//// text = item.goodsName
//// setTextColor(ContextCompat.getColor(context, R.color.black))
//// }
//// } else {
// tvCell.text = getTextSpan(item)
//// }
// }
// }
}
}
fun getTextSpan(item: SeasoningEntity): SpannableStringBuilder {
val endIndex = if (item.sort == 9) 10 else 6
@@ -1,9 +1,25 @@
package com.shuwei.dish.match.base
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
open class BaseFragment : Fragment() {
abstract class BaseFragment<VB : ViewBinding> : Fragment() {
private var _binding: VB? = null
protected val binding get() = _binding!!
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
_binding = inflateBinding(inflater, container)
return binding.root
}
abstract fun inflateBinding(inflater: LayoutInflater, container: ViewGroup?): VB
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
@@ -2,6 +2,7 @@ package com.shuwei.dish.match.dialog
import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.View
@@ -14,8 +15,8 @@ import com.shuwei.dish.match.utils.ext.dp
import java.lang.ref.WeakReference
open class CommonDialog(
private var activity: FragmentActivity
) : Dialog(activity) {
context: Context
) : Dialog(context) {
private lateinit var binding: DialogCommonBinding
@@ -1,26 +1,38 @@
//package com.shuwei.dish.match.dialog
//
//import android.content.Context
//import android.view.LayoutInflater
//import androidx.fragment.app.FragmentActivity
//import com.shuwei.dish.match.databinding.LayoutFoodRemindBinding
//
//object DialogTool {
//
// fun load(activity: FragmentActivity, leftText:) {
// val layoutInflater = LayoutInflater.from(activity)
// val remindBinding = LayoutFoodRemindBinding.inflate(layoutInflater)
// CommonDialog(activity).apply {
// messageView = remindBinding.root
// leftText = "返回调整"
// rightText = "确认无误"
// onLeftClick = { dismiss() }
// onRightClick = {
// goToSubmit()
// dismiss()
// }
// onDismiss = { hideStatusBar() }
// }.show()
// }
//
//}
package com.shuwei.dish.match.dialog
import android.content.Context
import android.view.LayoutInflater
import com.shuwei.dish.match.databinding.LayoutFoodRemindBinding
object DialogTool {
fun load(
context: Context,
title:String,
content:String,
leftBtnText: String,
rightBtnText: String,
leftBtnClick: () -> Unit = {},
rightBtnClick: () -> Unit = {}
) {
val layoutInflater = LayoutInflater.from(context)
val remindBinding = LayoutFoodRemindBinding.inflate(layoutInflater)
remindBinding.tvDialogTitle.text = title
remindBinding.tvDialogContent.text = content
CommonDialog(context).apply {
messageView = remindBinding.root
leftText = leftBtnText
rightText = rightBtnText
onLeftClick = {
leftBtnClick()
dismiss()
}
onRightClick = {
rightBtnClick()
dismiss()
}
onDismiss = { }
}.show()
}
}
@@ -29,12 +29,16 @@ object Loading {
}
fun dismiss() {
try {
dialog?.let {
if (it.isShowing) {
it.dismiss()
}
}
dialog = null
} catch (e: Exception) {
e.printStackTrace()
}
}
}
@@ -1,21 +1,15 @@
package com.shuwei.dish.match.http
import android.annotation.SuppressLint
import android.os.Handler
import android.os.Looper
import android.util.Log
import com.google.gson.reflect.TypeToken
import com.shuwei.dish.match.base.BaseApp
import com.shuwei.dish.match.base.BaseReq
import com.shuwei.dish.match.http.HttpUtil.runMainThread
import com.shuwei.dish.match.utils.SpTool
import com.shuwei.dish.match.utils.ext.put
import com.shuwei.dish.match.utils.ext.toType
import com.shuwei.dish.match.utils.ext.toast
import kotlinx.coroutines.Runnable
import okhttp3.Call
import okhttp3.Callback
import okhttp3.HttpUrl
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
@@ -41,7 +35,7 @@ object HttpUtil {
doFailure: (code: Int?, msg: String?) -> Unit
) {
val request = Request.Builder()
.url(url)
.url(if (url.isHttpApi()) url else UrlConfig.BASE_URL + url)
.apply {
if (header != null) {
header.forEach {
@@ -111,7 +105,7 @@ object HttpUtil {
.toRequestBody("application/json; charset=utf-8".toMediaTypeOrNull())
val token = getToken()
Request.Builder()
.url(url)
.url(if (url.isHttpApi()) url else UrlConfig.BASE_URL + url)
.apply {
if (token.isNotBlank()) {
addHeader("X-Access-Token", token)
@@ -198,3 +192,5 @@ object HttpUtil {
}
}
fun String.isHttpApi() = this.startsWith("http://") || this.startsWith("https://")
@@ -7,7 +7,9 @@ import android.text.style.AbsoluteSizeSpan
import android.text.style.ForegroundColorSpan
import android.text.style.LineHeightSpan
import android.text.style.StyleSpan
import android.util.Log
import android.util.SparseIntArray
import android.widget.FrameLayout
import android.widget.TextView
import androidx.core.graphics.toColorInt
import androidx.core.view.forEach
@@ -137,25 +139,27 @@ class DeviceConfigActivity : BaseActivity() {
private fun addWeighListener() {
WeightUtil.addWeightListener { address, state, weight ->
// Log.d(TAG, "addWeighListener: address=$address,stat=$state,weight=$weight")
weightArray.put(address, weight)
val item = seasoningItems.firstOrNull { address == addressArray[it.sort]}
item?.useWeight = weight.toDouble()
setGridData(seasoningItems)
item?.let {
it.useWeight = weight.toDouble()
updateGridData(it)
}
//setGridData(seasoningItems)
}
}
private var seasoningItems = mutableListOf<SeasoningEntity>()
private fun addGridItemListener() {
binding.include.root.forEach { child ->
(child as TextView).run {
clickWithDebounce {
val sort = tag.toString().toInt()
child.clickWithDebounce {
val sort = child.tag.toString().toInt()
val entity = seasoningItems.firstOrNull { it.sort == sort } ?: SeasoningEntity()
clickGridItem(sort, entity)
}
}
}
}
val detector = MultiClickDetector(targetCount = 10, intervalMs = 800)
@@ -224,11 +228,18 @@ class DeviceConfigActivity : BaseActivity() {
val gridLayout = binding.include.root
list.forEach { entity ->
val tag = entity.sort.toString()
val child = gridLayout.findViewWithTag<TextView>(tag)
TextCellAdapter.loadCell(child, entity)
val frameLayout = gridLayout.findViewWithTag<FrameLayout>(tag)
TextCellAdapter.loadLayout(frameLayout , entity)
}
}
private fun updateGridData(entity:SeasoningEntity) {
val gridLayout = binding.include.root
val tag = entity.sort.toString()
val frameLayout = gridLayout.findViewWithTag<FrameLayout>(tag)
TextCellAdapter.loadLayout(frameLayout , entity)
}
private fun clickGridItem(sort: Int, entity: SeasoningEntity) {
val currentAddress = AddressUtil.getWeighAddressArray().get(sort)
// val seasoningEntity = list.first{it.sort == sort}
@@ -242,8 +253,10 @@ class DeviceConfigActivity : BaseActivity() {
entity.materialType = 3
entity.sort = sort
saveSeasoning(entity) {
val child = binding.include.root.findViewWithTag<TextView>(sort.toString())
TextCellAdapter.loadCell(child, entity)
val tag = sort.toString()
val gridLayout = binding.include.root
val frameLayout = gridLayout.findViewWithTag<FrameLayout>(tag)
TextCellAdapter.loadLayout(frameLayout, entity)
}
}
}
@@ -1,246 +0,0 @@
//package com.shuwei.dish.match.ui
//
//import android.graphics.Typeface
//import android.os.Bundle
//import android.text.SpannableStringBuilder
//import android.text.style.AbsoluteSizeSpan
//import android.text.style.ForegroundColorSpan
//import android.text.style.LineHeightSpan
//import android.text.style.StyleSpan
//import androidx.core.graphics.toColorInt
//import androidx.lifecycle.ViewModelProvider
//import com.shuwei.dish.match.adapter.SeasoningCellTool
//import com.shuwei.dish.match.base.BaseActivity
//import com.shuwei.dish.match.base.BaseApp
//import com.shuwei.dish.match.databinding.ActivityDeviceSettingBinding
//import com.shuwei.dish.match.databinding.LayoutFoodRemindBinding
//import com.shuwei.dish.match.db.AppRepository
//import com.shuwei.dish.match.dialog.CommonDialog
//import com.shuwei.dish.match.entity.SeasoningEntity
//import com.shuwei.dish.match.entity.ResetReasoningRecord
//import com.shuwei.dish.match.utils.DataUtil
//import com.shuwei.dish.match.utils.JsonAssetsLoader
//import com.shuwei.dish.match.utils.MultiClickDetector
//import com.shuwei.dish.match.utils.WeightUtil
//import com.shuwei.dish.match.utils.ext.appendText
//import com.shuwei.dish.match.utils.ext.buildSpannableString
//import com.shuwei.dish.match.utils.ext.dp
//import com.shuwei.dish.match.utils.ext.startActivity
//import com.shuwei.dish.match.utils.ext.toast
//import com.shuwei.dish.match.utils.ext.visible
//import com.shuwei.dish.match.viewmodel.AppViewModel
//import com.shuwei.dish.match.viewmodel.factory.AppFactory
//import com.shuwei.dish.match.R
//
//class DeviceSettingActivity : BaseActivity() {
//
// companion object {
//
// const val TAG = "DeviceSettingActivity"
//
// const val COOK_MODE = "cookMode"
//
// val modeList = listOf<ModeBean>(
// ModeBean("制作模式", "菜品快速制作,记录熟重"),
// ModeBean("采样模式", "菜品快速制作,记录熟重"),
// ModeBean("品控模式", "菜品快速制作,记录熟重")
// )
// }
//
// data class ModeBean(
// var modeName: String,
// var modeDesc: String
// )
//
// private lateinit var binding: ActivityDeviceSettingBinding
//
// private lateinit var appViewModel: AppViewModel
//
// private var cookMode: Int = 0
//
// override fun onCreate(savedInstanceState: Bundle?) {
// super.onCreate(savedInstanceState)
// binding = ActivityDeviceSettingBinding.inflate(layoutInflater)
// setContentView(binding.root)
// cookMode = intent.getIntExtra(COOK_MODE, 0)
// initViewModel()
// setHeaderBackground()
// setTitleBar(titleBarAction = {
// it.visible()
// }, titleAction = {
// it.text = "设备配置"
// }, rightIconActon = {
// it.visible()
// it.alpha = 0.0F
// it.setImageResource(R.drawable.ic_setting)
// it.setOnClickListener {
//// appViewModel.clearAllSeasoning{
//// loadSeasoning()
//// }
// detector.setOnDelayedMultiClickListener(it) {
// defaultDataSettingDialog()
// }
// }
// })
//
// loadQualitySpan(isEnable = false)
// when (cookMode) {
// 1 -> {
// binding.rbModeCook.isChecked = true
// binding.rbModeSampling.isChecked = false
// loadCookSpan(isClicked = true)
// loadSamplingSpan()
// }
//
// 2 -> {
// binding.rbModeCook.isChecked = false
// binding.rbModeSampling.isChecked = true
// loadCookSpan()
// loadSamplingSpan(isClicked = true)
// }
//
// else -> 0
// }
//
// binding.rbModeCook.setOnClickListener {
// binding.rbModeCook.isChecked = true
// binding.rbModeSampling.isChecked = false
// loadCookSpan(isClicked = true)
// loadSamplingSpan()
// startActivity<SelectDishActivity> { }
// finish()
// }
// binding.rbModeSampling.setOnClickListener {
// binding.rbModeCook.isChecked = false
// binding.rbModeSampling.isChecked = true
// loadCookSpan()
// loadSamplingSpan(isClicked = true)
// startActivity<SamplingListActivity> { }
// finish()
// }
// }
//
// val detector = MultiClickDetector(targetCount = 10, intervalMs = 800)
//
// private fun defaultDataSettingDialog() {
// val remindBinding = LayoutFoodRemindBinding.inflate(layoutInflater)
// remindBinding.tvDialogTitle.text = "温馨提示"
// remindBinding.tvDialogContent.text = "您好,使用默认配置作为您的调料数据,则已有配置将被清除,确认吗?"
// CommonDialog(this).apply {
// messageView = remindBinding.root
// leftText = "取消"
// rightText = "确认"
// onLeftClick = { dismiss() }
// onRightClick = {
// dismiss()
// resetList()
// }
// onDismiss = { hideStatusBar() }
// }.show()
// }
//
// private fun resetList() {
// runCatching {
// val record = JsonAssetsLoader.parseJsonFromAssets<ResetReasoningRecord>(this,"default_seasoning_list.json")
// val addressArray = DataUtil.getWeighAddressArray()
// val weightArray = WeightUtil.weightArray
// appViewModel.clearAllSeasoning {
// record?.list?.forEach { entity ->
// entity.useWeight = weightArray[addressArray[entity.sort]].toDouble()
// appViewModel.saveSeasoning(entity){}
// }
// loadSeasoning()
// }
// }.onFailure { it.printStackTrace() }
// }
//
// private fun initViewModel() {
// val db = BaseApp.instance!!.database
// val factory =
// AppFactory(AppRepository(db.appDao()))
// appViewModel =
// ViewModelProvider(this, factory)[AppViewModel::class.java]
// }
//
// override fun onResume() {
// super.onResume()
// loadSeasoning()
// }
//
// private fun loadSeasoning() {
// appViewModel.loadSeasoning { it ->
// SeasoningCellTool.loadData(
// activity = this,
// initList = it,
// recyclerView = binding.rvSeasoning,
// tvCell = binding.tvRightBottomCell,
// pageType = 1
// )
// }
// }
//
//
// private fun loadQualitySpan(isClicked: Boolean = false, isEnable: Boolean = true) {
// binding.rbModeQuality.text =
// getModeTextSpan(
// topText = modeList[2].modeName,
// bottomText = modeList[2].modeDesc,
// topColor = if (isEnable) if (isClicked) "#00BC71" else "#000000" else "#B4B4B4",
// bottomColor = if (isEnable) "#8B8B8B" else "#B4B4B4"
// )
// }
//
// private fun loadSamplingSpan(isClicked: Boolean = false, isEnable: Boolean = true) {
// binding.rbModeSampling.text =
// getModeTextSpan(
// topText = modeList[1].modeName,
// bottomText = modeList[1].modeDesc,
// topColor = if (isEnable) if (isClicked) "#00BC71" else "#000000" else "#B4B4B4",
// bottomColor = if (isEnable) "#8B8B8B" else "#B4B4B4"
// )
// }
//
// private fun loadCookSpan(isClicked: Boolean = false, isEnable: Boolean = true) {
// binding.rbModeCook.text =
// getModeTextSpan(
// topText = modeList[0].modeName,
// bottomText = modeList[0].modeDesc,
// topColor = if (isEnable) if (isClicked) "#00BC71" else "#000000" else "#B4B4B4",
// bottomColor = if (isEnable) "#8B8B8B" else "#B4B4B4"
// )
// }
//
// private fun getModeTextSpan(
// topText: String,
// topColor: String,
// bottomText: String,
// bottomColor: String
// ): SpannableStringBuilder {
//
//
// return buildSpannableString {
// appendText(
// topText,
// ForegroundColorSpan(topColor.toColorInt()),
// StyleSpan(Typeface.BOLD),
// AbsoluteSizeSpan(36, true),
// LineHeightSpan { text, start, end, spanstartv, v, fm ->
// fm.descent += 10.dp // 增加行间距
// }
// )
// append("\n")
// appendText(
// bottomText,
// ForegroundColorSpan(bottomColor.toColorInt()),
// AbsoluteSizeSpan(26, true)
// )
// }
// }
//
// fun saveSeasoning(entity: SeasoningEntity) {
// appViewModel.saveSeasoning(entity) {
// toast("保存成功")
// }
// }
//
//}
@@ -143,18 +143,28 @@ class HomeActivity : BaseActivity() {
}
private fun goSampling() {
appViewModel.countCookFood(cookMode = 1) {
if (it > 0) {
appViewModel.loadSeasoning {
if (it.isEmpty()) {
//无调料信息打开采样历史列表页面,点击设置配置调料信息
startActivity<SamplingListActivity>()
finish()
return@loadSeasoning
}
appViewModel.countCookFood(cookMode = 1) { count ->
if (count > 0) {
//有烹饪中数据打开采样历史列表页面
startActivity<SamplingListActivity>()
finish()
return@countCookFood
}
//无烹饪数据打开新增采样页面
startActivity<DishSamplingActivity> {
putExtra(DishSamplingActivity.PAGE_FROM, DishSamplingActivity.HOME)
}
finish()
}
}
}
}
@@ -108,18 +108,28 @@ class InitActivity : BaseActivity() {
}
private fun goSampling() {
appViewModel.countCookFood(cookMode = 1) {
if (it > 0) {
appViewModel.loadSeasoning {
if (it.isEmpty()) {
//无调料信息打开采样历史列表页面,点击设置配置调料信息
startActivity<SamplingListActivity>()
finish()
return@loadSeasoning
}
appViewModel.countCookFood(cookMode = 1) { count ->
if (count > 0) {
//有烹饪中数据打开采样历史列表页面
startActivity<SamplingListActivity>()
finish()
return@countCookFood
}
//无烹饪数据打开新增采样页面
startActivity<DishSamplingActivity> {
putExtra(DishSamplingActivity.PAGE_FROM, DishSamplingActivity.HOME)
}
finish()
}
}
}
private fun countDown() {
lifecycleScope.launch {
@@ -16,6 +16,7 @@ import com.shuwei.dish.match.base.BaseApp
import com.shuwei.dish.match.databinding.ActivitySamplingBinding
import com.shuwei.dish.match.databinding.LayoutEmptyViewBinding
import com.shuwei.dish.match.db.AppRepository
import com.shuwei.dish.match.dialog.DialogTool
import com.shuwei.dish.match.entity.CookFoodEntity
import com.shuwei.dish.match.entity.FoodRecord
import com.shuwei.dish.match.entity.FoodRecordBean
@@ -64,9 +65,6 @@ class SamplingListActivity : BaseActivity() {
it.visible()
it.setImageResource(R.drawable.ic_setting)
it.setOnClickListener {
// startActivity<DeviceSettingActivity> {
// putExtra(DeviceSettingActivity.COOK_MODE, 2)
// }
startActivity<DeviceConfigActivity> {
putExtra(DeviceConfigActivity.COOK_MODE, 2)
}
@@ -116,24 +114,29 @@ class SamplingListActivity : BaseActivity() {
SamplingAdapter(list = list).apply {
isStateViewEnable = true
setOnItemClickListener { adapter, view, position ->
judgeDeviceConfig {
onItemClick(position)
}
}
}
}
private fun onItemClick(position:Int) {
val item = list[position]
if (item.isCooking) {
//烹饪中,跳到称熟重页面
// context.startActivity<SubmitDishActivity> {
context.startActivity<SubmitFoodActivity> {
startActivity<SubmitFoodActivity> {
putExtra(
SubmitFoodActivity.FOOD_ITEM,
item as Serializable
)
}
return@setOnItemClickListener
return
}
context.startActivity<DishSamplingActivity> {
startActivity<DishSamplingActivity> {
putExtra(DishSamplingActivity.FOOD_NAME, item.foodName)
}
}
}
}
@SuppressLint("NotifyDataSetChanged")
private fun initRecyclerView() {
@@ -163,8 +166,10 @@ class SamplingListActivity : BaseActivity() {
@SuppressLint("ClickableViewAccessibility")
private fun addViewListener() {
binding.btnAddSampling.setOnClickListener {
judgeDeviceConfig{
startActivity<DishSamplingActivity>()
}
}
binding.refreshLayout.setOnRefreshListener {
pageNo = 1
getSamplingList()
@@ -172,16 +177,6 @@ class SamplingListActivity : BaseActivity() {
binding.refreshLayout.setOnLoadMoreListener {
getSamplingList()
}
binding.dishRadioGroup.setOnCheckedChangeListener { group, checkedId ->
//Log.d(TAG, "addViewListener: checkId=${if (checkedId == R.id.rbSamplingCooking) "cooking" else "finish"}")
// if (!group.isPressed) return@setOnCheckedChangeListener
// if (checkedId == R.id.rbSamplingCooking) {
// refreshLocalData()
// } else {
// pageNo = 1
// getSamplingList()
// }
}
binding.rbSamplingCooking.setOnClickListener {
// Log.d(TAG, "addViewListener: cooking:${binding.rbSamplingCooking.isChecked}")
@@ -223,32 +218,7 @@ class SamplingListActivity : BaseActivity() {
HttpUtil.get(
url = sb.toString(),
doSuccess = {
binding.refreshLayout.run {
setEnableRefresh(true)
}
delayDismissLoading()
finishRefresh()
val json = it.toJsonString()
val recordBean: FoodRecordBean? = json.toObject<FoodRecordBean>()
if (recordBean == null || recordBean.records.isNullOrEmpty()) {
//toast("暂未搜索到相关菜品信息")
if (pageNo == 1) {
loadEmptyView()
}
return@get
}
val records = recordBean.records
if (pageNo == 1) {
list.clear()
}
list.addAll(records!!)
dishAdapter.notifyDataSetChanged()
val isLoadMoreEnable = records.size >= pageSize
binding.refreshLayout.setEnableLoadMore(isLoadMoreEnable)
binding.refreshLayout.setEnableRefresh(true)
if (isLoadMoreEnable) {
pageNo++
}
loadDishList(it)
}, doFailure = { code, msg ->
binding.refreshLayout.run {
setEnableRefresh(true)
@@ -361,4 +331,67 @@ class SamplingListActivity : BaseActivity() {
}
}
@SuppressLint("NotifyDataSetChanged")
private fun loadDishList(data: Any) {
binding.refreshLayout.run {
setEnableRefresh(true)
}
delayDismissLoading()
finishRefresh()
val json = data.toJsonString()
val recordBean: FoodRecordBean? = json.toObject<FoodRecordBean>()
if (recordBean == null || recordBean.records.isNullOrEmpty()) {
//toast("暂未搜索到相关菜品信息")
if (pageNo == 1) {
loadEmptyView()
}
return
}
val records = recordBean.records
if (pageNo == 1) {
list.clear()
}
list.addAll(records!!)
dishAdapter.notifyDataSetChanged()
val isLoadMoreEnable = records.size >= pageSize
binding.refreshLayout.setEnableLoadMore(isLoadMoreEnable)
binding.refreshLayout.setEnableRefresh(true)
if (isLoadMoreEnable) {
pageNo++
}
}
private var configFinished = false
fun judgeDeviceConfig(block:()-> Unit) {
if (configFinished) {
block()
return
}
appViewModel.loadSeasoning {
if (it.isEmpty()) {
showDeviceConfigDialog()
return@loadSeasoning
}
configFinished = true
block()
}
}
private fun showDeviceConfigDialog() {
DialogTool.load(
context = this,
title = "温馨提示",
content = "请先在设备配置页面进行调料设置",
leftBtnText = "取消",
rightBtnText = "去设置",
leftBtnClick = {},
rightBtnClick = {
startActivity<DeviceConfigActivity> {
putExtra(DeviceConfigActivity.COOK_MODE, 2)
}
}
)
}
}
@@ -11,6 +11,7 @@ import com.shuwei.dish.match.base.BaseActivity
import com.shuwei.dish.match.base.BaseApp
import com.shuwei.dish.match.databinding.ActivitySelectDishBinding
import com.shuwei.dish.match.db.AppRepository
import com.shuwei.dish.match.dialog.DialogTool
import com.shuwei.dish.match.entity.CookFoodEntity
import com.shuwei.dish.match.ui.fragment.DishListFragment
import com.shuwei.dish.match.utils.KeyboardUtil
@@ -54,9 +55,6 @@ class SelectDishActivity : BaseActivity() {
it.visible()
it.setImageResource(R.drawable.ic_setting)
it.setOnClickListener {
// startActivity<DeviceSettingActivity> {
// putExtra(DeviceSettingActivity.COOK_MODE, 1)
// }
startActivity<DeviceConfigActivity> {
putExtra(DeviceConfigActivity.COOK_MODE, 1)
}
@@ -81,6 +79,39 @@ class SelectDishActivity : BaseActivity() {
appViewModel.getCookFoodList(cookMode = 0, dinnerType = dinnerType) { action(it) }
}
private var configFinished = false
fun judgeDeviceConfig(block: () -> Unit) {
if (configFinished) {
block()
return
}
appViewModel.loadSeasoning {
if (it.isEmpty()) {
showDeviceConfigDialog()
return@loadSeasoning
}
configFinished = true
block()
}
}
private fun showDeviceConfigDialog() {
DialogTool.load(
context = this,
title = "温馨提示",
content = "请先在设备配置页面进行调料设置",
leftBtnText = "取消",
rightBtnText = "去设置",
leftBtnClick = {},
rightBtnClick = {
startActivity<DeviceConfigActivity> {
putExtra(DeviceConfigActivity.COOK_MODE, 1)
}
}
)
}
fun addViewListener() {
binding.dishRadioGroup.setOnCheckedChangeListener { _, checkedId ->
dinnerType = when (checkedId) {
@@ -1,429 +0,0 @@
//package com.shuwei.dish.match.ui
//
//import android.annotation.SuppressLint
//import android.os.Bundle
//import android.util.Log
//import android.util.SparseArray
//import android.util.SparseIntArray
//import androidx.core.util.forEach
//import androidx.lifecycle.ViewModelProvider
//import com.aithings.Weigher
//import com.google.gson.reflect.TypeToken
//import com.shuwei.dish.match.R
//import com.shuwei.dish.match.adapter.SeasoningCellTool
//import com.shuwei.dish.match.adapter.TextCellAdapter
//import com.shuwei.dish.match.base.BaseActivity
//import com.shuwei.dish.match.base.BaseApp
//import com.shuwei.dish.match.databinding.ActivitySubmitDishBinding
//import com.shuwei.dish.match.db.AppRepository
//
//import com.shuwei.dish.match.entity.CookFoodEntity
//import com.shuwei.dish.match.entity.CookFoodGoodsEntity
//import com.shuwei.dish.match.entity.FoodRecord
//import com.shuwei.dish.match.entity.SeasoningEntity
//import com.shuwei.dish.match.http.HttpUtil
//import com.shuwei.dish.match.http.UrlConfig
//import com.shuwei.dish.match.utils.DataUtil
//import com.shuwei.dish.match.utils.WeightUtil
//import com.shuwei.dish.match.utils.ext.clickWithDebounce
//import com.shuwei.dish.match.utils.ext.gone
//import com.shuwei.dish.match.utils.ext.startActivity
//import com.shuwei.dish.match.utils.ext.toJsonString
//import com.shuwei.dish.match.utils.ext.toType
//import com.shuwei.dish.match.utils.ext.toast
//import com.shuwei.dish.match.utils.ext.visible
//import com.shuwei.dish.match.viewmodel.AppViewModel
//import com.shuwei.dish.match.viewmodel.factory.AppFactory
//
//@SuppressLint("UseSparseArrays")
//class SubmitDishActivity : BaseActivity() {
//
// companion object {
// const val TAG = "SubmitDishActivity"
// const val FOOD_ITEM = "foodItem"
// const val GOODS_LIST = "goodsList"
// }
//
// private lateinit var binding: ActivitySubmitDishBinding
//
// private var food: FoodRecord? = null
// private var goodsList: MutableList<CookFoodGoodsEntity>? = null
//
// private var isCooking = false
//
// private val cookFoodEntity by lazy {
// CookFoodEntity().apply {
// food?.let {
// foodId = it.foodId ?: ""
// foodName = it.foodName
// cookMode = it.cookMode
// dinnerType = it.dinnerType
// }
// canteenId = BaseApp.canteenId
// }
// }
//
// @Suppress("unchecked_cast", "DEPRECATION")
// override fun onCreate(savedInstanceState: Bundle?) {
// super.onCreate(savedInstanceState)
// binding = ActivitySubmitDishBinding.inflate(layoutInflater)
// setContentView(binding.root)
// initViewModel()
// setHeaderBackground()
// intent.extras?.apply {
// food = getSerializable(FOOD_ITEM) as FoodRecord?
// Log.d(TAG, "onCreate: cookMode=${food?.cookMode}")
// isCooking = food?.isCooking ?: false
// if (isCooking) {
// //烹饪中,从本地查询数据
// loadSeasoningFromLocal()
// } else {
// //非烹饪中,从菜品主辅材配置页面带入数据
// goodsList = getSerializable(GOODS_LIST) as MutableList<CookFoodGoodsEntity>?
// }
// }
// setTitleBar(titleBarAction = {
// it.visible()
// }, titleAction = {
// it.text = food?.foodName
// }, rightIconActon = {
// it.gone()
// it.setImageResource(R.drawable.ic_setting)
// it.setOnClickListener {
// //startActivity<DeviceSettingActivity>()
// }
// })
// addViewListener()
// }
//
// private fun loadSeasoningFromLocal() {
// appViewModel.getCookFoodGoodsList(foodId = food!!.foodId!!, cookMode = food!!.cookMode) { it ->
// goodsList = mutableListOf()
// //设置主辅材数据
// goodsList?.addAll(it.filter { goods -> goods.materialType != 3 })
//
// //获取调料数据并展示
// val filterList: List<SeasoningEntity>? = it.filter { goods -> goods.materialType == 3 }
// .map { entity ->
// SeasoningEntity().also { se ->
// se.goodsId = entity.goodsId
// se.goodsName = entity.goodsName
// se.goodsOrRelationCode = entity.goodsOrRelationCode
// se.relateionType = entity.relateionType
// se.materialType = entity.materialType
// se.allEdible = entity.allEdible
// se.useWeight = entity.useWeight
// se.popularName = entity.popularName
// se.canteenId = entity.canteenId
// se.relateionType_dictText = entity.relateionType_dictText
// se.foodId = entity.foodId
// se.sort = entity.sort
// se.pageType = 0
// }
// }
// filterList?.toMutableList()?.let { cellData ->
// loadTextCell(cellData)
// }
// }
// }
//
//
// private lateinit var seasoningList: List<SeasoningEntity>
// private var isFirstSave = true
// fun updateSeasoningList(list: MutableList<SeasoningEntity>) {
// if (isFirstSave) {
// val json = list.toJsonString()
// val typeToken = object : TypeToken<List<SeasoningEntity>>() {}
// seasoningList = json.toType(typeToken = typeToken)
// isFirstSave = false
// }
// }
//
// private val seasoningArray by lazy {
// SparseArray<Double>()
// }
//
//
// private val firstGoodsArray by lazy {
// SparseArray<Int>()
// }
//
// private fun addViewListener() {
// addWeightListener()
// binding.btnWeightClear.setOnClickListener { Weigher.tareTwo(AddressUtil.TWO) }
//
// binding.btnCook.clickWithDebounce {
// cook()
// }
//
// binding.btnSubmit.clickWithDebounce {
// if (cookFoodEntity.foodWeight <= 0.toDouble()) {
// toast("未识别到菜品熟重")
// return@clickWithDebounce
// }
// submit()
// }
// }
//
// private fun addWeightListener() {
// WeightUtil.addWeightListener(getWeight = { address, state, weight ->
// if (address == 1) {
// cookFoodEntity.foodWeight = weight.toDouble()
// binding.tvTotalWeight.text = "${weight / 1000f}"
// }
//// if (state != SensorScale.STATE_STABLE) {
//// return@addWeightListener
//// }
// val firstWeight = firstGoodsArray.get(address, null)
//// if (firstWeight != weight) {
//// Log.d(
//// TAG,
//// "addViewListener: state=$state,address=$address,weight=$weight,firstWeight=$firstWeight"
//// )
//// }
// if (firstWeight == null) {
// //未设置数据
// firstGoodsArray.put(address, weight)
// return@addWeightListener
// }
//// val cookingWeight =
//// if (isCooking && seasoningList.isNullOrEmpty().not())
//// seasoningList?.get(weightRelateArray2.get(address))?.weight ?: 0
//// else 0
//// var realUseWeight = firstWeight - weight + cookingWeight
// var realUseWeight = firstWeight - weight
// realUseWeight = if (realUseWeight > 0) realUseWeight else 0
//// Log.d(
//// TAG,
//// "addViewListener: state=$state,address=$address,总共使用重量:$realUseWeight"
//// )
// seasoningArray.put(address, realUseWeight.toDouble())
//
// refreshSeasoningWeight()
// })
// }
//
// @SuppressLint("NotifyDataSetChanged")
// private fun refreshSeasoningWeight() {
// binding.rvSeasoning.adapter?.let { adapter ->
// if (adapter is TextCellAdapter) {
// adapter.list.let { items ->
// weightRelateArray.forEach { key, value ->
// items[key].useWeight =
// (seasoningArray.get(value) ?: 0.toDouble()) + getCookingSeasoning(value)
// }
// }
// adapter.notifyDataSetChanged()
// TextCellAdapter.loadCell(binding.tvRightBottomCell, adapter.list[14])
// }
// }
// }
//
// private fun getCookingSeasoning(address: Int): Double {
// if (isCooking.not()) return 0.toDouble()
// if (seasoningList.isEmpty()) return 0.toDouble()
// val weight = seasoningList[weightRelateArray2.get(address)].useWeight ?: 0.toDouble()
// //Log.i(TAG, "getCookingSeasoning: weight[${address}]=$weight,seasoningList=${seasoningList.toJsonString()}")
// return weight
// }
//
// private val weightRelateArray2 by lazy {
// SparseIntArray().apply {
// weightRelateArray.forEach { key, value ->
// if (value == 3) {
// put(3, 14)
// } else {
// put(value, key)
// }
// }
// }
// }
//
// private val weightRelateArray by lazy {
// DataUtil.getWeighAddressArray()
// }
//
//// private fun prepareData(acton: () -> Unit) {
////
//// //只有制作和采样列表页面才能进入设置页面,提交页面无法进行设置,不存在调料数据被修改的问题
//// val seasoningJson = realSeasoningData.toJsonString()
//// val typeToken = object : TypeToken<List<CookFoodGoodsEntity>>() {}
//// val tempSeasoningList = seasoningJson.toType(typeToken = typeToken)
//// goodsList?.addAll(tempSeasoningList)
//// acton()
////
//// }
//
// private fun cook() {
// if (food == null || goodsList.isNullOrEmpty()) {
// toast("未获取到菜品或构成信息")
// return
// }
// val realSeasoningData = (binding.rvSeasoning.adapter as TextCellAdapter).list
// if (realSeasoningData.isEmpty() && !isCooking) {
// toast("未获取到调料信息")
// return
// }
// if (realSeasoningData.isNotEmpty()&&realSeasoningData[0].goodsId.isNullOrBlank()) {
// toast("还未设置调料信息,请去设置页面操作")
// return
// }
// showLoading()
// //只有制作和采样列表页面才能进入设置页面,提交页面无法进行设置,不存在调料数据被修改的问题
// val seasoningJson = realSeasoningData.toJsonString()
// val typeToken = object : TypeToken<List<CookFoodGoodsEntity>>() {}
// val tempSeasoningList = seasoningJson.toType(typeToken = typeToken)
// goodsList?.addAll(tempSeasoningList)
// cookFoodEntity.let {
// it.dinnerType = when (it.dinnerType) {
// "早餐" -> "1"
// "午餐" -> "2"
// "晚餐" -> "3"
// else -> it.dinnerType
// }
// }
// val isSamplingData = food!!.cookMode == 1
// if (isSamplingData) {
// //生成临时foodId,解决采样模式没有foodId,无法关联数据的问题
// val tempFoodId = cookFoodEntity.foodId.ifBlank { "${System.currentTimeMillis()}" }
// cookFoodEntity.foodId = tempFoodId
// }
// //全部设置同一foodId
// goodsList?.forEach {
// it.foodId = cookFoodEntity.foodId
// }
// //保存菜品-保存主辅料调料
// appViewModel.saveCookFoodAndGoods(
// cookMode = food!!.cookMode,
// entity = cookFoodEntity,
// list = goodsList,
// onFinish = {
// runOnUiThread {
// dismissLoading()
// jumpPage(isSamplingData, true)
// }
// })
// }
//
// private fun submit() {
// if (food == null || goodsList.isNullOrEmpty()) {
// toast("未获取到菜品或构成信息")
// return
// }
// val realSeasoningData = (binding.rvSeasoning.adapter as TextCellAdapter).list
// if (realSeasoningData.isEmpty() && !isCooking) {
// toast("未获取到调料信息")
// return
// }
// if (realSeasoningData.isNotEmpty()&&realSeasoningData[0].goodsId.isNullOrBlank()) {
// toast("还未设置调料信息,请去设置页面操作")
// return
// }
// showLoading()
// //只有制作和采样列表页面才能进入设置页面,提交页面无法进行设置,不存在调料数据被修改的问题
// val seasoningJson = realSeasoningData.toJsonString()
// val typeToken = object : TypeToken<List<CookFoodGoodsEntity>>() {}
// val tempSeasoningList = seasoningJson.toType(typeToken = typeToken)
// tempSeasoningList.forEach { entity ->
// val realWeight = entity.useWeight ?: 0.toDouble()
// val filterData = goodsList?.firstOrNull { it.goodsId == entity.goodsId }
// //确保重量大于0,且无重复数据
// if (realWeight > 0.toDouble() && filterData == null) {
// goodsList?.add(entity)
// }
// }
//
// cookFoodEntity.let {
// it.stFoodInfoConstituteList = this@SubmitDishActivity.goodsList
// it.dinnerType = when(it.dinnerType) {
// "1" -> "早餐"
// "2" -> "午餐"
// "3" -> "晚餐"
// else -> null
// }
// }
//
// val isSamplingData = food!!.cookMode == 1
// if (isSamplingData) {
// //采样模式没有foodId
// cookFoodEntity.foodId = ""
// goodsList?.forEach { it.foodId = "" }
// }
// val json = cookFoodEntity.toJsonString()
// Log.d(TAG, "submit: json=$json")
// HttpUtil.postJson(
// url = UrlConfig.SUBMIT_DISH,
// json = json,
// doSuccess = {
// Log.d(TAG, "submit: postJson=$it")
// submitSuccess(isSamplingData)
// }, doFailure = { code, msg ->
// Log.d(TAG, "submit: postJson:code=$code,msg=$msg")
// toast(msg)
// dismissLoading()
// })
// }
//
// private fun submitSuccess(isSamplingData: Boolean) {
// if (food?.foodId.isNullOrBlank()) {
// //本地无删除数据直接跳转页面
// dismissLoading()
// jumpPage(isSamplingData, false)
// return
// }
// //删除本地数据
// appViewModel.deleteCookFoodAndGoods(
// cookMode = food!!.cookMode,
// foodId = food!!.foodId!!
// ) {
// dismissLoading()
// jumpPage(isSamplingData, false)
// }
// }
//
// private fun jumpPage(isSampling: Boolean, isCooking: Boolean) {
// if (isSampling) {
// startActivity<SamplingListActivity> {
// putExtra(SelectDishActivity.IS_COOKING, isCooking)
// }
// return
// }
// startActivity<SelectDishActivity> {
// putExtra(SelectDishActivity.IS_COOKING, isCooking)
// putExtra(SelectDishActivity.DINNER_TYPE, food?.dinnerType)
// }
// }
//
// private lateinit var appViewModel: AppViewModel
//
// private fun initViewModel() {
// val db = BaseApp.instance!!.database
// val factory =
// AppFactory(AppRepository(db.appDao()))
// appViewModel =
// ViewModelProvider(this, factory)[AppViewModel::class.java]
// }
//
// override fun onResume() {
// super.onResume()
// binding.tvRightBottomCell.visible()
// if (isCooking.not()) {
// //烹饪中使用本地数据,未烹饪则使用默认的调料配置数据
// appViewModel.loadSeasoning {
// Log.d(TAG, "onResume: loadSeasoning:${it.toJsonString()}")
// loadTextCell(it)
// }
// }
// }
//
// private fun loadTextCell(list: MutableList<SeasoningEntity>) {
// SeasoningCellTool.loadData(
// activity = this,
// initList = list,
// recyclerView = binding.rvSeasoning,
// tvCell = binding.tvRightBottomCell
// )
// }
//}
//
//
@@ -5,6 +5,7 @@ import android.os.Bundle
import android.util.Log
import android.util.SparseArray
import android.util.SparseIntArray
import android.widget.FrameLayout
import android.widget.TextView
import androidx.core.util.forEach
import androidx.lifecycle.ViewModelProvider
@@ -180,58 +181,53 @@ class SubmitFoodActivity : BaseActivity() {
realUseWeight = if (realUseWeight > 0) realUseWeight else 0
seasoningArray.put(address, realUseWeight.toDouble())
refreshSeasoningWeight()
// refreshSeasoningWeight()
val item = seasoningItems.firstOrNull { address == addressArray[it.sort]}
item?.let {
val lastWeight = seasoningArray.get(address) ?: 0.toDouble()
it.useWeight = lastWeight + getCookingSeasoning(address)
updateGridData(it)
}
})
}
@SuppressLint("NotifyDataSetChanged")
private fun refreshSeasoningWeight() {
if (seasoningItems.isEmpty()) {
return
}
seasoningItems.let { items ->
weightRelateArray.forEach { key, value ->
items[key].useWeight =
(seasoningArray.get(value) ?: 0.toDouble()) + getCookingSeasoning(value)
}
}
setGridData(seasoningItems)
// binding.rvSeasoning.adapter?.let { adapter ->
// if (adapter is TextCellAdapter) {
// adapter.list.let { items ->
// weightRelateArray.forEach { key, value ->
// private fun refreshSeasoningWeight() {
// if (seasoningItems.isEmpty()) {
// return
// }
// seasoningItems.let { items ->
// addressArray.forEach { key, value ->
// items[key].useWeight =
// (seasoningArray.get(value) ?: 0.toDouble()) + getCookingSeasoning(value)
// }
// }
// adapter.notifyDataSetChanged()
// }
// setGridData(seasoningItems)
// }
private fun updateGridData(entity:SeasoningEntity) {
val gridLayout = binding.include.root
val tag = entity.sort.toString()
val frameLayout = gridLayout.findViewWithTag<FrameLayout>(tag)
TextCellAdapter.loadLayout(frameLayout , entity)
}
private fun getCookingSeasoning(address: Int): Double {
if (isCooking.not()) return 0.toDouble()
if (seasoningItems.isEmpty()) return 0.toDouble()
// val weight = seasoningItems[weightRelateArray2.get(address)].useWeight ?: 0.toDouble()
val weight = seasoningCookingItems?.get(weightRelateArray2.get(address))?.useWeight ?: 0.toDouble()
//Log.i(TAG, "getCookingSeasoning: weight[${address}]=$weight,seasoningList=${seasoningList.toJsonString()}")
return weight
}
private val weightRelateArray2 by lazy {
SparseIntArray().apply {
weightRelateArray.forEach { key, value ->
addressArray.forEach { key, value ->
put(value, key)
// if (value == 3) {
// put(3, 14)
// } else {
// put(value, key)
// }
}
}
}
private val weightRelateArray by lazy {
private val addressArray by lazy {
AddressUtil.getWeighAddressArray()
}
@@ -431,8 +427,8 @@ class SubmitFoodActivity : BaseActivity() {
val gridLayout = binding.include.root
list.forEach { entity ->
val tag = entity.sort.toString()
val child = gridLayout.findViewWithTag<TextView>(tag)
TextCellAdapter.loadCell(child, entity)
val frameLayout = gridLayout.findViewWithTag<FrameLayout>(tag)
TextCellAdapter.loadLayout(frameLayout, entity)
}
}
}
@@ -5,12 +5,12 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import com.chad.library.adapter4.util.setOnDebouncedItemClick
import com.shuwei.dish.match.adapter.DishShowAdapter
import com.shuwei.dish.match.base.BaseApp
import com.shuwei.dish.match.base.BaseFragment
import com.shuwei.dish.match.databinding.FragmentDishListBinding
import com.shuwei.dish.match.databinding.LayoutEmptyViewBinding
@@ -28,7 +28,7 @@ import com.shuwei.dish.match.utils.ext.toObject
import com.shuwei.dish.match.utils.ext.toast
import java.io.Serializable
class DishListFragment : Fragment() {
class DishListFragment : BaseFragment<FragmentDishListBinding>() {
companion object {
private const val TAG = "DishListFragment"
@@ -42,34 +42,40 @@ class DishListFragment : Fragment() {
}
}
}
private var pageNo = 1
private val pageSize = 30
private lateinit var activity: SelectDishActivity
private lateinit var binding: FragmentDishListBinding
private var dinnerType = "0"
private lateinit var activity: SelectDishActivity
private var list: MutableList<FoodRecord> = mutableListOf()
private val dishAdapter by lazy {
DishShowAdapter(list = list).apply {
isStateViewEnable = true
setOnDebouncedItemClick { adapter, view, position ->
activity.judgeDeviceConfig {
onItemClick(position)
}
}
}
}
private fun onItemClick(position: Int) {
val item = list[position]
if (item.isCooking) {
//烹饪中,跳到称熟重页面
// context.startActivity<SubmitDishActivity> {
context.startActivity<SubmitFoodActivity> {
activity.startActivity<SubmitFoodActivity> {
putExtra(
SubmitFoodActivity.FOOD_ITEM,
item as Serializable
)
}
return@setOnDebouncedItemClick
return
}
item.dinnerType = dinnerType
context.startActivity<PrepareCookActivity> {
activity.startActivity<PrepareCookActivity> {
putExtra(
SubmitFoodActivity.FOOD_ITEM,
item as Serializable
@@ -77,16 +83,11 @@ class DishListFragment : Fragment() {
}
}
}
}
override fun onCreateView(
override fun inflateBinding(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentDishListBinding.inflate(inflater, container, false)
return binding.root
container: ViewGroup?
): FragmentDishListBinding {
return FragmentDishListBinding.inflate(inflater, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -1,187 +0,0 @@
//package com.shuwei.dish.match.ui.fragment
//
//import android.annotation.SuppressLint
//import android.content.Intent
//import android.os.Bundle
//import android.util.Log
//import android.view.LayoutInflater
//import android.view.View
//import android.view.ViewGroup
//import androidx.fragment.app.Fragment
//import androidx.recyclerview.widget.LinearLayoutManager
//import com.aithings.Weigher
//import com.shuwei.dish.match.R
//import com.shuwei.dish.match.adapter.DishPartAdapter
//import com.shuwei.dish.match.databinding.FragmentDishSamplingBinding
//import com.shuwei.dish.match.dialog.BottomDialog
//import com.shuwei.dish.match.entity.CookFoodGoodsEntity
//import com.shuwei.dish.match.entity.FoodRecord
//import com.shuwei.dish.match.ui.FoodSearchActivity
//import com.shuwei.dish.match.ui.DishSamplingActivity
//import com.shuwei.dish.match.ui.SubmitDishActivity
//import com.shuwei.dish.match.utils.KeyboardUtil
//import com.shuwei.dish.match.utils.WeightUtil
//import com.shuwei.dish.match.utils.ext.addOnActionSearchListener
//import com.shuwei.dish.match.utils.ext.clickWithDebounce
//import com.shuwei.dish.match.utils.ext.startActivity
//import com.shuwei.dish.match.utils.ext.toJsonString
//import com.shuwei.dish.match.utils.ext.toast
//import java.io.Serializable
//
//class DishSamplingFragment : Fragment() {
//
// private val TAG = "DishSamplingFragment"
//
// private lateinit var activity: DishSamplingActivity
// private lateinit var binding: FragmentDishSamplingBinding
//
// val list: MutableList<CookFoodGoodsEntity> = mutableListOf()
//
// private var tempDishEntity: CookFoodGoodsEntity? = null
//
// private var dishMaterialType = 1
//
// private val dishAdapter by lazy {
// DishPartAdapter(list).apply {
// addOnItemChildClickListener(R.id.ivOperateIcon) { _, _, positon ->
// //删除操作
// removeAt(positon)
// }
// }
// }
//
// override fun onCreateView(
// inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
// ): View {
// binding = FragmentDishSamplingBinding.inflate(inflater, container, false)
// return binding.root
// }
//
// override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
// super.onViewCreated(view, savedInstanceState)
// activity = requireActivity() as DishSamplingActivity
// addViewClickListener()
// foodName = activity.foodName
// binding.etInputDish.setText(foodName)
// }
//
// @SuppressLint("NotifyDataSetChanged")
// private fun addViewClickListener() {
// binding.rvDishPartList.run {
// layoutManager = LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)
// adapter = dishAdapter
// }
// binding.tvInputDishType.run {
// clickWithDebounce {
// BottomDialog(goodsType = 0).show(activity) { item ->
// val filterResult = list.firstOrNull { it.goodsName == item.goodsName }
// if (filterResult != null) {
// toast("不允许重复添加同一食材")
// return@show
// }
// text = item.goodsName
// tempDishEntity = CookFoodGoodsEntity().apply {
// goodsId = item.goodsId
// goodsName = item.goodsName
//
// relateionType = item.relateionType?:0
// goodsOrRelationCode = item.goodsOrRelationCode
//
// // TODO: 待定
// //allEdible = item.allEdible
// }
// }
// }
// }
//
// binding.ivWeightClear.setOnClickListener {
// Weigher.tareTwo(2)
// }
// WeightUtil.addWeightListener(getWeight = { address, state, weight ->
// Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
// if (address == 2) {
// tempDishEntity?.useWeight = weight
// binding.tvDishPartWeight.text = "${weight}"
// }
// })
// binding.ivWeightAdd.setOnClickListener {
// if (tempDishEntity == null) {
// activity.toast("请输入食材名称")
// return@setOnClickListener
// }
// if (binding.rgSampling.checkedRadioButtonId == -1) {
// activity.toast("请选择主辅材类型")
// return@setOnClickListener
// }
// if (tempDishEntity!!.useWeight == null) {
// activity.toast("请将食材放在称上称重")
// return@setOnClickListener
// }
// tempDishEntity!!.apply {
// isSamplingPage = true
// materialType = dishMaterialType
// }
// val result = list.firstOrNull { it.goodsId == tempDishEntity!!.goodsId }
// if (result != null) {
// activity.toast("${result.goodsName}食材已添加,请勿重复操作")
// return@setOnClickListener
// }
// list.add(tempDishEntity!!)
// dishAdapter.notifyDataSetChanged()
// tempDishEntity = null
// binding.tvInputDishType.text = ""
// binding.rgSampling.clearCheck()
// }
// binding.rgSampling.setOnCheckedChangeListener { group, checkedId ->
// dishMaterialType = if (checkedId == R.id.rbDishTypeFirst) 1 else 2
// }
// binding.ivDishSearch.setOnClickListener { v ->
// jumpSearch(v)
// }
// binding.btnCook.clickWithDebounce {
// val showFoodName = binding.etInputDish.text.toString().trim()
// if (showFoodName.isBlank()) {
// toast("菜品名称为空")
// return@clickWithDebounce
// }
// if (list.isEmpty()) {
// toast("菜品构成信息未设置")
// return@clickWithDebounce
// }
// val food = FoodRecord()
// food.foodId = foodId
// food.foodName = showFoodName
// food.cookMode = 1
// Log.d(TAG, "goToSubmit: goodsList:${list.toJsonString()}")
// activity.startActivity<SubmitDishActivity> {
// putExtra(SubmitDishActivity.GOODS_LIST, list as Serializable)
// putExtra(SubmitDishActivity.FOOD_ITEM, food as Serializable)
// }
// }
// binding.etInputDish.let { v ->
// v.addOnActionSearchListener {
// jumpSearch(v)
// }
// }
// }
//
// private fun jumpSearch(v: View) {
// activity.launch(Intent(activity, FoodSearchActivity::class.java).apply {
// putExtra(FoodSearchActivity.FOOD_NAME, binding.etInputDish.text.toString().trim() )
// }) { intent ->
// intent?.let {
// foodId = it.getStringExtra(FoodSearchActivity.FOOD_ID)
// foodName = it.getStringExtra(FoodSearchActivity.FOOD_NAME)
// binding.etInputDish.run {
// setText(foodName)
// setSelection(text.length)
// }
// }
// }
// KeyboardUtil.hideKeyboard(v.context, v)
// }
//
//
// private var foodId: String? = null
// private var foodName: String? = null
//}
@@ -1,254 +0,0 @@
//package com.shuwei.dish.match.ui.fragment
//
//import android.annotation.SuppressLint
//import android.os.Bundle
//import android.view.LayoutInflater
//import android.view.View
//import android.view.ViewGroup
//import androidx.fragment.app.Fragment
//import androidx.recyclerview.widget.ItemTouchHelper
//import androidx.recyclerview.widget.LinearLayoutManager
//import com.shuwei.dish.match.R
//import com.shuwei.dish.match.adapter.SamplingAdapter
//import com.shuwei.dish.match.databinding.FragmentSamplingListBinding
//import com.shuwei.dish.match.databinding.LayoutEmptyViewBinding
//
//import com.shuwei.dish.match.entity.FoodRecord
//import com.shuwei.dish.match.entity.FoodRecordBean
//import com.shuwei.dish.match.http.HttpUtil
//import com.shuwei.dish.match.http.UrlConfig
//import com.shuwei.dish.match.ui.DishSamplingActivity
//import com.shuwei.dish.match.ui.SamplingListActivity
//import com.shuwei.dish.match.ui.SubmitDishActivity
//import com.shuwei.dish.match.utils.DateTimeUtil
//import com.shuwei.dish.match.utils.SwipeCallback
//import com.shuwei.dish.match.utils.ext.startActivity
//import com.shuwei.dish.match.utils.ext.toJsonString
//import com.shuwei.dish.match.utils.ext.toObject
//import com.shuwei.dish.match.utils.ext.toast
//import java.io.Serializable
//
//class SamplingListFragment : Fragment() {
//
// companion object {
// private const val TAG = "SamplingListFragment"
// }
//
// private lateinit var activity: SamplingListActivity
// private lateinit var binding: FragmentSamplingListBinding
//
// private var list: MutableList<FoodRecord> = mutableListOf()
// private val dishAdapter by lazy {
// SamplingAdapter(list = list).apply {
// isStateViewEnable = true
// setOnItemClickListener { adapter, view, position ->
// val item = list[position]
// if (item.isCooking) {
// //烹饪中,跳到称熟重页面
// context.startActivity<SubmitDishActivity> {
// putExtra(
// SubmitDishActivity.FOOD_ITEM,
// item as Serializable
// )
// }
// return@setOnItemClickListener
// }
// context.startActivity<DishSamplingActivity> {
// putExtra(DishSamplingActivity.FOOD_NAME, item.foodName)
// }
// }
// }
// }
//
// @SuppressLint("NotifyDataSetChanged")
// private fun initRecyclerView() {
// binding.rvSamplingList.run {
// layoutManager =
// LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
// adapter = dishAdapter
// val itemTouchHelper = ItemTouchHelper(SwipeCallback(dishAdapter) { position ->
// if (list[position].isCooking.not()) {
// activity.toast("只能删除烹饪中的菜品")
// dishAdapter.notifyItemChanged(position)
// return@SwipeCallback
// }
// activity.deleteCookFoodAndGoods(foodId = list[position].foodId?:"") {
// if (list.size > 1) {
// dishAdapter.removeAt(position)
// } else {
// loadEmptyView()
// }
// activity.toast("已删除")
// }
// })
// itemTouchHelper.attachToRecyclerView(this)
// }
// }
//
// private fun addViewListener() {
// binding.btnAddSampling.setOnClickListener {
// activity.startActivity<DishSamplingActivity>()
// }
// binding.refreshLayout.setOnRefreshListener {
// pageNo = 1
// getSamplingList()
// }
// binding.refreshLayout.setOnLoadMoreListener {
// getSamplingList()
// }
// binding.dishRadioGroup.setOnCheckedChangeListener { group, checkedId ->
// if (checkedId == R.id.rbCooking) {
// refreshLocalData()
// } else {
// pageNo = 1
// getSamplingList()
// }
// }
// }
//
// override fun onCreateView(
// inflater: LayoutInflater,
// container: ViewGroup?,
// savedInstanceState: Bundle?
// ): View {
// binding = FragmentSamplingListBinding.inflate(inflater, container, false)
// return binding.root
// }
//
// @SuppressLint("NotifyDataSetChanged")
// override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
// super.onViewCreated(view, savedInstanceState)
// activity = requireActivity() as SamplingListActivity
// initRecyclerView()
// addViewListener()
// refreshLocalData()
// }
//
// var pageNo = 1
// private val pageSize = 30
//
// @SuppressLint("NotifyDataSetChanged")
// fun getSamplingList() {
// activity.showLoading()
// val map = mapOf(
//// "foodName" to input,
// "pageNo" to "$pageNo",
// "pageSize" to "$pageSize",
// "canteenId" to "0"
// )
// val sb = StringBuilder(UrlConfig.SAMPLING_LIST).apply {
// append("?")
// map.forEach { (key, value) -> append("$key=$value&") }
// }
// sb.deleteCharAt(sb.length - 1)
// HttpUtil.get(
// url = sb.toString(),
// doSuccess = {
// binding.refreshLayout.run {
// setEnableRefresh(true)
// }
// activity.delayDismissLoading()
// finishRefresh()
// val json = it.toJsonString()
// val recordBean: FoodRecordBean? = json.toObject<FoodRecordBean>()
// if (recordBean == null || recordBean.records.isNullOrEmpty()) {
// //toast("暂未搜索到相关菜品信息")
// if (pageNo == 1) {
// loadEmptyView()
// }
// return@get
// }
// val records = recordBean.records
// if (pageNo == 1) {
// list.clear()
// }
// list.addAll(records!!)
// dishAdapter.notifyDataSetChanged()
// val isLoadMoreEnable = records.size >= pageSize
// binding.refreshLayout.setEnableLoadMore(isLoadMoreEnable)
// binding.refreshLayout.setEnableRefresh(true)
// if (isLoadMoreEnable) {
// pageNo++
// }
// }, doFailure = { code, msg ->
// binding.refreshLayout.run {
// setEnableRefresh(true)
// }
// toast(msg)
// finishRefresh()
// binding.refreshLayout.setEnableRefresh(true)
// activity.delayDismissLoading()
// if (pageNo == 1) {
// loadEmptyView()
// }
// })
// }
//
// private fun finishRefresh() {
// if (pageNo == 1) {
// binding.refreshLayout.finishRefresh(1200)
// } else {
// binding.refreshLayout.finishLoadMore(1200)
// }
// }
//
// private var emptyViewBinding:LayoutEmptyViewBinding?=null
//
// @SuppressLint("NotifyDataSetChanged")
// private fun loadEmptyView() {
// list.clear()
// dishAdapter.notifyDataSetChanged()
// if (emptyViewBinding == null) {
// emptyViewBinding = LayoutEmptyViewBinding.inflate(LayoutInflater.from(requireContext()), binding.rvSamplingList, false)
// }
// emptyViewBinding!!.tvContent.text = "暂无数据"
// emptyViewBinding!!.tvSubContent.text = "今日暂无采样数据,点击下方按钮新增采样"
// dishAdapter.stateView = emptyViewBinding!!.root
// //dishAdapter.setStateViewLayout(requireContext(), R.layout-sw800dp.layout_empty_view)
//
// binding.refreshLayout.run {
// setEnableRefresh(false)
// setEnableLoadMore(false)
// }
// }
//
// fun refreshPage(isCooking: Boolean) {
// binding.dishRadioGroup.check(
// if (isCooking) R.id.rbCooking else R.id.rbFinished
// )
// }
//
// @SuppressLint("NotifyDataSetChanged")
// fun refreshLocalData() {
// activity.showLoading()
// //查询本地数据
// activity.getCookFoodList { cookFoodEntities ->
// activity.delayDismissLoading()
// if (cookFoodEntities.isNullOrEmpty()) {
// loadEmptyView()
// return@getCookFoodList
// }
// val tempList = mutableListOf<FoodRecord>()
//
// cookFoodEntities
// .sortedByDescending { DateTimeUtil.convert(dateStr = it.createTime) }
// .forEach { entity ->
// tempList.add(FoodRecord().apply {
// foodId = entity.foodId
// foodName = entity.foodName
// cookMode = 1
// isCooking = true
// })
// }
// list.clear()
// list.addAll(tempList)
// dishAdapter.notifyDataSetChanged()
// binding.refreshLayout.run {
// setEnableRefresh(false)
// setEnableLoadMore(false)
// }
// }
// }
//
//
//}
@@ -9,15 +9,15 @@ object AddressUtil {
fun getWeighAddressArray(): SparseIntArray {
return SparseIntArray().apply {
put(0, 12)
put(0, 14)
put(1, 13)
put(2, 14)
put(3, 9)
put(2, 12)
put(3, 11)
put(4, 10)
put(5, 11)
put(6, 6)
put(5, 9)
put(6, 8)
put(7, 7)
put(8, 8)
put(8, 6)
put(9, 3)
put(10, 5)
put(11, 4)
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/dish_green"/>
</shape>
+358 -127
View File
@@ -5,253 +5,484 @@
android:layout_width="match_parent"
android:layout_height="725dp"
android:paddingStart="23dp"
android:paddingEnd="22dp"
android:paddingTop="30dp"
android:paddingEnd="22dp"
android:paddingBottom="20dp"
app:columnCount="3"
app:orientation="vertical"
app:rowCount="5">
app:rowCount="5"
tools:ignore="HardcodedText">
<!-- 第1行 -->
<TextView
<FrameLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:tag="0"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_row="0">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:tag="0"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_row="0"
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="1"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:tag="1"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_row="0"
tools:text="1" />
app:layout_row="0">
<TextView
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="2"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:tag="2"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
app:layout_column="2"
app:layout_columnWeight="1"
app:layout_row="0"
tools:text="2" />
app:layout_row="0">
<TextView
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="3"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:tag="3"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_row="1"
tools:text="3" />
app:layout_row="1">
<TextView
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="4"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:tag="4"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_row="1"
tools:text="4" />
app:layout_row="1">
<TextView
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:tag="5"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="5"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:tag="5"
app:layout_column="2"
app:layout_columnWeight="1"
app:layout_row="1"
tools:text="5" />
app:layout_row="1">
<TextView
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:tag="6"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="6"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:tag="6"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_row="2"
tools:text="6" />
app:layout_row="2">
<TextView
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:tag="7"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="7"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:tag="7"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_row="2"
tools:text="7" />
app:layout_row="2">
<TextView
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:tag="8"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
app:layout_column="2"
app:layout_columnWeight="1"
app:layout_row="2"
tools:text="8" />
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="8"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:tag="8"
app:layout_column="2"
app:layout_columnWeight="1"
app:layout_row="2">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="9"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="255dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:tag="9"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
app:layout_column="0"
app:layout_columnSpan="2"
app:layout_columnWeight="1"
app:layout_gravity="fill_horizontal"
app:layout_row="3"
app:layout_rowSpan="2"
tools:text="9" />
app:layout_rowSpan="2">
<TextView
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="10"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:tag="10"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
app:layout_column="2"
app:layout_columnWeight="1"
app:layout_row="3"
tools:text="10" />
app:layout_row="3">
<TextView
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="7dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:tag="11"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="11"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="7dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/selector_text_cell"
android:tag="11"
app:layout_column="2"
app:layout_columnWeight="1"
app:layout_row="4"
tools:text="11" />
app:layout_row="4">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:textColor="@color/black"
android:textSize="28sp"
android:textStyle="bold"
tools:text="0" />
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|end"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_oval"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="12"
android:textColor="@color/white"
android:textSize="20sp" />
</FrameLayout>
</androidx.gridlayout.widget.GridLayout>