refs #6574 feat:modify screen
This commit is contained in:
parent
3cae4565da
commit
3b7b0291db
|
@ -6,12 +6,14 @@ import androidx.core.content.ContextCompat
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.ItemHistoricoRowBinding
|
||||
import es.verdnatura.presentation.common.OnClientHistoricItemClickListener
|
||||
import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoVO
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
class HistoricoAdapter(
|
||||
private val items: List<ItemHistoricoVO>
|
||||
private val items: List<ItemHistoricoVO>,
|
||||
private val onClientHistoricItemClickListener: OnClientHistoricItemClickListener
|
||||
) : RecyclerView.Adapter<HistoricoAdapter.ItemHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||
|
@ -47,14 +49,83 @@ class HistoricoAdapter(
|
|||
)
|
||||
)
|
||||
|
||||
val color = if (item.invalue != null && item.invalue!! > 0) {
|
||||
val colorIn = if ((item.invalue ?: 0) > 0) {
|
||||
R.color.verdnatura_dark_green_verdnatura
|
||||
} else {
|
||||
R.color.verdnatura_black_5
|
||||
}
|
||||
inQuantity.setBackgroundColor(ContextCompat.getColor(historicoDate.context, color))
|
||||
inQuantity.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
historicoDate.context, colorIn
|
||||
)
|
||||
)
|
||||
|
||||
val colorOut = if ((item.out ?: 0) < 0) {
|
||||
R.color.verdnatura_red_salix
|
||||
} else {
|
||||
R.color.verdnatura_black_5
|
||||
}
|
||||
outQuantity.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
historicoDate.context, colorOut
|
||||
)
|
||||
)
|
||||
|
||||
paintClientName(item.stateName, binding)
|
||||
|
||||
clientName.setOnClickListener {
|
||||
onClientHistoricItemClickListener.onClientHistoricItemClickListener(item)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun paintClientName(
|
||||
stateName: String?,
|
||||
binding: ItemHistoricoRowBinding,
|
||||
) {
|
||||
|
||||
when (stateName!!.lowercase()) {
|
||||
"preparado", "en preparación", "autoimpreso", "impreso" -> {
|
||||
binding.clientName.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
binding.root.context, R.color.verdnatura_pumpkin_orange
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"encajando", "encajado", "reparto", "en reparto", "entregado" -> {
|
||||
binding.clientName.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
binding.root.context, R.color.verdnatura_red_salix
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"revisado", "en revisión" -> {
|
||||
binding.clientName.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
binding.root.context, R.color.verdnatura_dark_green_verdnatura
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"previa", "previa revisado", "previa OK", "previa revisando", "previa impreso" -> {
|
||||
binding.clientName.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
binding.root.context, R.color.verdnatura_pink_salix
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
binding.clientName.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
binding.root.context, R.color.verdnatura_black_5
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
package es.verdnatura.presentation.view.feature.historicoarticulo.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.ContextCompat.getColor
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.gson.Gson
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.R.color.verdnatura_pumpkin_orange
|
||||
import es.verdnatura.R.color.verdnatura_white
|
||||
|
@ -15,11 +14,15 @@ import es.verdnatura.databinding.FragmentHistoricoBinding
|
|||
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
||||
import es.verdnatura.domain.notNull
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnClientHistoricItemClickListener
|
||||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
import es.verdnatura.presentation.view.feature.historicoarticulo.adapter.HistoricoAdapter
|
||||
import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoListVO
|
||||
import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoVO
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
|
@ -33,6 +36,8 @@ class HistoricoArticuloFragment(
|
|||
private var listHistoric: ArrayList<ItemHistoricoVO> = ArrayList()
|
||||
private var listHistoryAux: ArrayList<ItemHistoricoVO> = ArrayList()
|
||||
private var filter: String = ""
|
||||
private var onpasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||
private lateinit var customDialog: CustomDialog
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: Int) = HistoricoArticuloFragment(entryPoint)
|
||||
|
@ -49,12 +54,18 @@ class HistoricoArticuloFragment(
|
|||
it, mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
|
||||
)
|
||||
}
|
||||
binding.mainToolbar.toolbarTitle.text = getString(R.string.itemdiary) + ":" + itemFk
|
||||
binding.mainToolbar.toolbarTitle.text =
|
||||
getString(R.string.itemDiarySelected, itemFk.toString())
|
||||
setToolBar()
|
||||
setEvents()
|
||||
super.init()
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
if (context is OnPasillerosItemClickListener) onpasillerosItemClickListener = context
|
||||
super.onAttach(context)
|
||||
}
|
||||
|
||||
private fun setToolBar() {
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
|
@ -65,11 +76,9 @@ class HistoricoArticuloFragment(
|
|||
val iconFault = ImageView(context)
|
||||
iconFault.setImageResource(R.drawable.alpha_f_circle_outline)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
iconReload.tooltipText = getTooltip(R.drawable.ic_info_refresh)
|
||||
iconGargabe.tooltipText = getTooltip(R.drawable.alpha_b_circle_outline)
|
||||
iconFault.tooltipText = getTooltip(R.drawable.alpha_f_circle_outline)
|
||||
}
|
||||
iconReload.tooltipText = getTooltip(R.drawable.ic_info_refresh)
|
||||
iconGargabe.tooltipText = getTooltip(R.drawable.alpha_b_circle_outline)
|
||||
iconFault.tooltipText = getTooltip(R.drawable.alpha_f_circle_outline)
|
||||
|
||||
listIcons.add(iconGargabe)
|
||||
listIcons.add(iconFault)
|
||||
|
@ -122,9 +131,9 @@ class HistoricoArticuloFragment(
|
|||
}
|
||||
|
||||
binding.filterNameordateitem.setOnKeyListener { v, keyCode, event ->
|
||||
if (binding.filterNameordateitem.text.toString().isNullOrEmpty()) {
|
||||
if (binding.filterNameordateitem.text.toString().isEmpty()) {
|
||||
if (listHistoric.size != listHistoryAux.size) {
|
||||
listHistoric.removeAll(listHistoryAux)
|
||||
listHistoric.removeAll(listHistoryAux.toSet())
|
||||
listHistoryAux.forEach {
|
||||
listHistoric.add(it)
|
||||
}
|
||||
|
@ -132,7 +141,7 @@ class HistoricoArticuloFragment(
|
|||
}
|
||||
|
||||
} else {
|
||||
listHistoric.removeAll(listHistoryAux)
|
||||
listHistoric.removeAll(listHistoryAux.toSet())
|
||||
listHistoryAux.forEach {
|
||||
|
||||
if (it.name?.contains(
|
||||
|
@ -147,38 +156,89 @@ class HistoricoArticuloFragment(
|
|||
|
||||
}
|
||||
|
||||
|
||||
adapter!!.notifyDataSetChanged()
|
||||
return@setOnKeyListener false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
loadHistoricoList.observe(viewLifecycleOwner, Observer { event ->
|
||||
loadHistoricoList.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
listToAdapter(it.list, filter)
|
||||
navigateToToday(it)
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
private fun listToAdapter(lista: List<ItemHistoricoVO>, filter: String) {
|
||||
|
||||
listHistoric.clear()
|
||||
listHistoryAux.clear()
|
||||
lista.forEach {
|
||||
if (filter == "all" || (filter == "falta" && it.name?.contains(filter, true) == true) || (filter != "falta" && it.name?.contains("merma", true) == true && !it.name?.contains("falta", true)!!)) {
|
||||
if (filter == "all" || (filter == "falta" && it.name?.contains(
|
||||
filter,
|
||||
true
|
||||
) == true) || (filter != "falta" && it.name?.contains(
|
||||
"merma",
|
||||
true
|
||||
) == true && !it.name?.contains("falta", true)!!)
|
||||
) {
|
||||
listHistoric.add(it)
|
||||
}
|
||||
}
|
||||
listHistoric.sortWith { item1, item2 ->
|
||||
val compareShipped = item1.shipped.compareTo(item2.shipped)
|
||||
if (compareShipped == 0) {
|
||||
if (item1.order == null) {
|
||||
-1
|
||||
} else if (item2.order == null) {
|
||||
1
|
||||
} else {
|
||||
item2.order!!.compareTo(item1.order!!) // Invertir el orden
|
||||
}
|
||||
} else {
|
||||
compareShipped
|
||||
}
|
||||
}
|
||||
adapter = HistoricoAdapter(listHistoric, object : OnClientHistoricItemClickListener {
|
||||
|
||||
adapter = HistoricoAdapter(listHistoric)
|
||||
override fun onClientHistoricItemClickListener(item: ItemHistoricoVO) {
|
||||
|
||||
if (item.isTicket == 1) {
|
||||
ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = getString(R.string.titleWebViewer),
|
||||
), entryPoint = Gson().toJson(
|
||||
mutableMapOf(
|
||||
"entryPoint" to item.origin,
|
||||
"web" to "${
|
||||
mobileApplication.dataStoreApp.getServerSalix()
|
||||
}/#!/ticket/${item.origin}/summary"
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
customDialog = CustomDialog(requireContext())
|
||||
customDialog
|
||||
.setTitle(getString(R.string.entry))
|
||||
.setDescription(item.origin.toString())
|
||||
.setOkButton(
|
||||
getString(
|
||||
R.string.accept
|
||||
)
|
||||
) {
|
||||
customDialog.dismiss()
|
||||
}
|
||||
|
||||
.show()
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
binding.historicoRecyclerview.adapter = adapter
|
||||
binding.historicoRecyclerview.layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
|
@ -187,7 +247,6 @@ class HistoricoArticuloFragment(
|
|||
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
private fun navigateToToday(it: ItemHistoricoListVO) {
|
||||
var positionToday = 0
|
||||
val sdf = SimpleDateFormat(getString(R.string.dateFormat))
|
||||
|
|
|
@ -14,6 +14,8 @@ class ItemHistoricoVO(
|
|||
var invalue: Int? = null,
|
||||
var out: Int? = null,
|
||||
var balance: Int? = null,
|
||||
var isTicket: Int? = 0,
|
||||
var order: Int? = 0,
|
||||
var isError: Boolean = false,
|
||||
var errorMessage: String = ""
|
||||
) {
|
||||
|
|
|
@ -47,23 +47,24 @@
|
|||
android:layout_marginBottom="@dimen/layout_margin_1"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/layout_margin_min"
|
||||
android:paddingEnd="@dimen/layout_margin_min">
|
||||
android:paddingEnd="@dimen/layout_margin_min"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:gravity="start"
|
||||
android:text="@string/Fecha"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body2" />
|
||||
android:textSize="@dimen/body2"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/Cliente"
|
||||
android:layout_marginStart="@dimen/layout_margin_min"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body2" />
|
||||
|
||||
|
@ -72,8 +73,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/Entrada"
|
||||
android:text="@string/entry"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:layout_marginStart="@dimen/layout_margin_1"
|
||||
android:textSize="@dimen/body2" />
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
android:textSize="@dimen/body2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/clientName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -50,10 +51,12 @@
|
|||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@{String.valueOf(item.invalue)}"
|
||||
android:layout_marginStart="@dimen/layout_margin_min"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/outQuantity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
|
Loading…
Reference in New Issue