feat parkingShelving #refs 6382
This commit is contained in:
parent
b796623e13
commit
bf20906042
|
@ -41,6 +41,15 @@ fun EditText.toInt(): Int {
|
|||
return this.text.toString().toInt()
|
||||
}
|
||||
|
||||
fun String.isParking(): Boolean {
|
||||
val regex = Regex("[\\S-\\S]{5,}")
|
||||
return regex.matches(this)
|
||||
}
|
||||
fun String.isShelving(): Boolean {
|
||||
val regex = Regex("\\S{0,4}")
|
||||
return regex.matches(this)
|
||||
}
|
||||
|
||||
fun EditText.toLong(): Long {
|
||||
return this.text.toString().toLong()
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package es.verdnatura.presentation.view.feature.delivery.adapters
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.ItemExpeditionSummaryRowBinding
|
||||
import es.verdnatura.presentation.common.AdapterCallback
|
||||
import es.verdnatura.presentation.common.OnAddressRowClickListener
|
||||
import es.verdnatura.presentation.common.OnItemImageLoadRowClickListener
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary
|
||||
|
@ -12,10 +15,10 @@ import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSumm
|
|||
class ExpeditionSummaryAdapter(
|
||||
private val items: List<ExpeditionInfoSummary>,
|
||||
private val onAddressRowClickListener: OnAddressRowClickListener,
|
||||
private val onItemImageLoadRowClickListener: OnItemImageLoadRowClickListener
|
||||
private val onItemImageLoadRowClickListener: OnItemImageLoadRowClickListener,
|
||||
private val adapterCallBack: AdapterCallback
|
||||
) : RecyclerView.Adapter<ExpeditionSummaryAdapter.ItemHolder>() {
|
||||
|
||||
private var positionSelected: Int = -1
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||
return ItemHolder(
|
||||
ItemExpeditionSummaryRowBinding.inflate(
|
||||
|
@ -34,10 +37,7 @@ class ExpeditionSummaryAdapter(
|
|||
onAddressRowClickListener.onAddressRowClickListener(items[position])
|
||||
|
||||
}
|
||||
/* holder.binding.txtConsignatario.setOnClickListener {
|
||||
onAddressRowClickListener.onAddressRowClickListener(items[position])
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
inner class ItemHolder(
|
||||
|
@ -47,36 +47,39 @@ class ExpeditionSummaryAdapter(
|
|||
fun bind(item: ExpeditionInfoSummary) {
|
||||
binding.apply {
|
||||
|
||||
if (item.delivery != item.total) {
|
||||
fondo.setBackgroundColor(
|
||||
res.getColor(R.color.verdnatura_pumpkin_light)
|
||||
)
|
||||
} else {
|
||||
fondo.setBackgroundColor(res.getColor(R.color.verdnatura_black))
|
||||
}
|
||||
if (item.delivered == item.total) {
|
||||
fondo.setBackgroundColor(res.getColor(R.color.verdnatura_black))
|
||||
}
|
||||
val color = getColorBackground(item)
|
||||
fondo.setBackgroundColor(color)
|
||||
|
||||
showExp.setOnClickListener {
|
||||
onItemImageLoadRowClickListener.onItemImageLoadRowClickListener(item)
|
||||
}
|
||||
//tarea 7278
|
||||
/*binding.imgItemSelected.visibility =
|
||||
if (positionSelected == absoluteAdapterPosition) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
}*/
|
||||
|
||||
if (adapterCallBack.getPosition() == absoluteAdapterPosition) {
|
||||
val border = GradientDrawable()
|
||||
border.shape = GradientDrawable.RECTANGLE
|
||||
border.setStroke(2, Color.WHITE)
|
||||
border.setColor(color)
|
||||
fondo.background = border
|
||||
}
|
||||
|
||||
|
||||
this.item = item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun changePositionSelected(position: Int) {
|
||||
notifyItemChanged(positionSelected)
|
||||
positionSelected = position
|
||||
notifyItemChanged(position)
|
||||
private fun getColorBackground(item: ExpeditionInfoSummary): Int {
|
||||
var color: Int
|
||||
if (item.delivery != item.total) {
|
||||
color = res.getColor(R.color.verdnatura_pumpkin_light)
|
||||
} else {
|
||||
color = res.getColor(R.color.verdnatura_black)
|
||||
}
|
||||
|
||||
if (item.delivered == item.total) {
|
||||
color = res.getColor(R.color.verdnatura_black)
|
||||
}
|
||||
return color
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue