refs #5764 modify dayOfSale

This commit is contained in:
Sergio De la torre 2023-09-15 11:10:10 +02:00
parent cfe7a23ccd
commit eed96ea4eb
2 changed files with 82 additions and 64 deletions

View File

@ -10,17 +10,21 @@ import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import java.text.SimpleDateFormat
import java.util.*
import java.util.Date
class DayOfSaleAdapter(
private val items: List<ItemShelvingSaleDate>,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
private val onPasillerosItemClickListener: OnPasillerosItemClickListener?
) : RecyclerView.Adapter<DayOfSaleAdapter.ItemHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
return ItemHolder(
ItemShelvingdayofsaleRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
ItemShelvingdayofsaleRowBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
)
}
@ -41,18 +45,29 @@ class DayOfSaleAdapter (
val currentDate = sdf.format(Date())
if (currentDate == item.dated) {
saledate.setBackgroundColor(
ContextCompat.getColor(historicoDate.context,
R.color.verdnatura_pumpkin_orange))
ContextCompat.getColor(
historicoDate.context,
R.color.verdnatura_pumpkin_orange
)
)
} else {
saledate.setBackgroundColor(
ContextCompat.getColor(historicoDate.context,
R.color.verdnatura_black_5))
ContextCompat.getColor(
historicoDate.context,
R.color.verdnatura_black_5
)
)
}
historicoDate.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(
PasillerosItemVO(title = res.getString(
R.string.titleItemSearch)),item.itemFk.toString())
}
onPasillerosItemClickListener!!.onPasillerosItemClickListener(
PasillerosItemVO(
title = res.getString(
R.string.titleItemConsult
)
), item.itemFk
)
}
}
}
}

View File

@ -1,5 +1,6 @@
package es.verdnatura.presentation.view.feature.diadeventa.fragment
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Build
import android.view.View
@ -9,7 +10,6 @@ import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentItemdayofsaleCardBinding
import es.verdnatura.domain.notNull
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
@ -34,6 +34,10 @@ class DayOfSaleFragment(
fun newInstance(entryPoint: String) = DayOfSaleFragment(entryPoint)
}
override fun onAttach(context: Context) {
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
super.onAttach(context)
}
override fun getLayoutId(): Int = R.layout.fragment_itemdayofsale_card
@ -110,14 +114,12 @@ class DayOfSaleFragment(
override fun observeViewModel() {
with(viewModel) {
loadItemShelvingSaleDateList.observe(viewLifecycleOwner, Observer { event ->
event.getContentIfNotHandled().notNull {
itemShelvingSaleDateList.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
adapter = DayOfSaleAdapter(
it.list,
onPasillerosItemClickListener = pasillerosItemClickListener!!
)
binding.itemexpeditionstateRecyclerview.adapter = adapter
binding.itemexpeditionstateRecyclerview.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
@ -139,8 +141,9 @@ class DayOfSaleFragment(
}
}
}
})
response.observe(viewLifecycleOwner, Observer {
if (it.isError) {