refs #4676 delivery->picking

This commit is contained in:
Sergio De la torre 2023-07-20 11:52:33 +02:00
parent a068ed3f6c
commit 1771608eff
6 changed files with 64 additions and 32 deletions

View File

@ -6,12 +6,10 @@ import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.R
import es.verdnatura.databinding.ItemExpeditionSummaryRowBinding
import es.verdnatura.presentation.common.OnAddressRowClickListener
import es.verdnatura.presentation.common.OnItemCardRowClickListener
import es.verdnatura.presentation.common.OnItemImageLoadRowClickListener
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary
class ExpeditionSummaryAdapter(
private val items: List<ExpeditionInfoSummary>,
private val onAddressRowClickListener: OnAddressRowClickListener,
@ -47,15 +45,17 @@ class ExpeditionSummaryAdapter(
fun bind(item: ExpeditionInfoSummary) {
binding.apply {
if (item.delivery != item.total || item.delivered == item.total)
{
if (item.delivery != item.total) {
fondo.setBackgroundColor(
res.getColor(R.color.verdnatura_pumpkin_light)
)
}else{
res.getColor(R.color.verdnatura_black)
} else {
fondo.setBackgroundColor(res.getColor(R.color.verdnatura_black))
}
if (item.delivered == item.total){
fondo.setBackgroundColor(res.getColor(R.color.verdnatura_black))
}
showExp.setOnClickListener {
onItemImageLoadRowClickListener.onItemImageLoadRowClickListener(item)
}

View File

@ -83,11 +83,12 @@ class RouteAdapter(
}
if (item.header){
linearLayoutLoadVan.visibility
headerRoute.visibility= View.VISIBLE
headerRouteLayout.visibility = View.VISIBLE
headerRoute.text = toDateString(item.created)
}else{
headerRoute.visibility=View.GONE
headerRouteLayout.visibility = View.GONE
}
this.item = item

View File

@ -133,8 +133,24 @@ class LoadUnloadFragment(
android.app.AlertDialog.BUTTON_NEUTRAL, getString(R.string.save)
) { dialog, which ->
counterCalls = 2
viewModel.expeditionState_add(list.filter { it.code == state }, state)
viewModel.expeditionState_add(list.filter { it.code != state }, "LOST")
if (list.filter { it.code == state }.isEmpty()){
counterCalls--
}else{
viewModel.expeditionState_add(list.filter { it.code == state }, state)
}
if (list.filter { it.code != state && it.code != "FOUND" }.isEmpty()){
counterCalls--
}else{
viewModel.expeditionState_add(
list.filter { it.code != state && it.code != "FOUND" },
"LOST"
)
}
/*viewModel.expeditionState_add(list.filter { it.code == state }, state)
viewModel.expeditionState_add(
list.filter { it.code != state && it.code != "FOUND" },
"LOST"
)*/
}
alertDialog.setButton(
android.app.AlertDialog.BUTTON_POSITIVE, getString(R.string.ordenar)
@ -206,7 +222,7 @@ class LoadUnloadFragment(
false
}
binding.scanInput.requestFocus()
binding.scanInput.requestFocus()
}
private fun markExpedition(expedNumber: Int, state: String) {
@ -229,7 +245,14 @@ class LoadUnloadFragment(
ma.messageWithSound("", true, true, isToasted = null)
}
}
updateCount(myList, state)
if (binding.mainToolbar.switchButton.isChecked) {
counterCalls = 1
binding.splashProgress.visibility = View.VISIBLE
viewModel.expeditionState_add(myList.filter { it.code == state }, state)
} else {
updateCount(myList, state)
}
}
@RequiresApi(Build.VERSION_CODES.O)
@ -256,7 +279,11 @@ class LoadUnloadFragment(
counterResponse = counterResponse + 1
if (counterResponse == counterCalls) {
// viewModel.getExpeditionFromRoute(route)
requireActivity().onBackPressed()
if (!binding.mainToolbar.switchButton.isChecked) {
requireActivity().onBackPressed()
} else {
binding.mainToolbar.switchButton.isChecked = false
}
counterResponse = 0
counterCalls = 0
}
@ -271,16 +298,17 @@ class LoadUnloadFragment(
binding.mainToolbar.switchButton.tooltipText = getString(R.string.expeditionMarkLost)
binding.mainToolbar.switchButton.setOnCheckedChangeListener { buttonView, isChecked ->
binding.mainToolbar.switchButton.tooltipText = if (isChecked)
getString(R.string.expeditionMarkLost) else
getString(R.string.expeditionMarkFound)
getString(R.string.expeditionMarkFound) else
getString(R.string.expeditionMarkLost)
if (isChecked) {
binding.mainToolbar.toolbarTitle.text =
getString(R.string.loading)
} else {
binding.mainToolbar.toolbarTitle.text = if (isChecked) {
getString(R.string.unloading)
} else {
getString(R.string.loading)
}
getString(R.string.unloading)
}
}
@ -297,15 +325,15 @@ class LoadUnloadFragment(
lifecycleScope.launch {
withContext(Dispatchers.IO) {
db.expedicionDao().insert(list.filter { it.routeFk == route }
)
)
myList = db.expedicionDao().getAll(route) as MutableList<ExpeditionInfoLoadUnload>
// myList = list as MutableList<ExpeditionInfoLoadUnload>
}
if (addressFk != 0) {
myList =
myList.filter { it.addressFk == addressFk } as MutableList<ExpeditionInfoLoadUnload>
}else{
myList.filter{
} else {
myList.filter {
it.routeFk == route
}
}

View File

@ -118,21 +118,21 @@
<LinearLayout
android:id="@+id/itemcard_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="10dp"
android:orientation="vertical"
tools:ignore="ExtraText"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider">
app:layout_constraintTop_toTopOf="@+id/divider">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<!--android:id="@+id/itemexpeditionstate_recyclerview"-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/expeditionSummary_recyclerview"
android:layout_width="match_parent"

View File

@ -50,14 +50,16 @@
<LinearLayout
android:id="@+id/itemcard_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="5dp"
android:orientation="vertical"
tools:ignore="ExtraText"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider">
app:layout_constraintTop_toTopOf="@+id/divider"
>
<RelativeLayout
android:layout_width="match_parent"

View File

@ -17,8 +17,9 @@
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/headerRouteLayout"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"