|
|
@@ -1,9 +1,12 @@
|
|
|
package com.yingyang.workbenches.adapter
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
+import android.text.TextUtils
|
|
|
import com.yingyang.workbenches.R
|
|
|
import com.yingyang.workbenches.databinding.ItemDateBinding
|
|
|
import com.yingyang.workbenches.entity.DayBean
|
|
|
import com.yingyangfly.baselib.adapter.BaseDataBindingAdapter
|
|
|
+import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
|
import com.yingyangfly.baselib.ext.setTextColorResource
|
|
|
|
|
|
/**
|
|
|
@@ -11,13 +14,31 @@ import com.yingyangfly.baselib.ext.setTextColorResource
|
|
|
*/
|
|
|
class DateAdapter(override val layoutId: Int = R.layout.item_date) :
|
|
|
BaseDataBindingAdapter<DayBean, ItemDateBinding>() {
|
|
|
+
|
|
|
+ var currentDate = ""
|
|
|
+
|
|
|
+ var onDateClickListener: ((bean: DayBean) -> Unit)? = null
|
|
|
+
|
|
|
+ @SuppressLint("NotifyDataSetChanged")
|
|
|
override fun onBindViewHolder(binding: ItemDateBinding, item: DayBean, position: Int) {
|
|
|
binding.data = item
|
|
|
- if (item.isCurrentMonth) {
|
|
|
- binding.tvDate.setTextColorResource(R.color.color_FF333333)
|
|
|
+ if (TextUtils.equals(currentDate, item.time)) {
|
|
|
+ binding.tvDate.setTextColorResource(R.color.color_ffffff)
|
|
|
+ binding.tvDate.setBackgroundResource(R.drawable.bg_train_selected_date)
|
|
|
} else {
|
|
|
- binding.tvDate.setTextColorResource(R.color.color_FF9FA5B4)
|
|
|
+ if (item.isCurrentDay) {
|
|
|
+ binding.tvDate.setTextColorResource(R.color.color_ffffff)
|
|
|
+ binding.tvDate.setBackgroundResource(R.drawable.bg_train_currect_date)
|
|
|
+ } else {
|
|
|
+ if (item.isCurrentMonth) {
|
|
|
+ binding.tvDate.setTextColorResource(R.color.color_FF626B80)
|
|
|
+ } else {
|
|
|
+ binding.tvDate.setTextColorResource(R.color.color_FF9FA5B4)
|
|
|
+ }
|
|
|
+ binding.tvDate.setBackgroundResource(R.drawable.bg_train_none)
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
when (item.status) {
|
|
|
"1" -> {
|
|
|
binding.statusView.setBackgroundResource(R.drawable.bg_train_complete)
|
|
|
@@ -29,5 +50,11 @@ class DateAdapter(override val layoutId: Int = R.layout.item_date) :
|
|
|
binding.statusView.setBackgroundResource(R.drawable.bg_train_none)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ binding.dateLayout.setOnSingleClickListener {
|
|
|
+ currentDate = item.time
|
|
|
+ onDateClickListener?.invoke(item)
|
|
|
+ notifyDataSetChanged()
|
|
|
+ }
|
|
|
}
|
|
|
}
|