refs #5071 summaryFragment
This commit is contained in:
parent
c7807adb4c
commit
6c9e85c574
|
@ -863,4 +863,8 @@ interface VerdnaturaService {
|
|||
@Body vararg params: Any
|
||||
): Call<List<ExpeditionInfoLoadUnload>>
|
||||
|
||||
@POST("/delivery/route_getExpeditionSummary")
|
||||
fun route_getExpeditionSummary(
|
||||
@Body vararg params: Any
|
||||
): Call<List<ExpeditionInfoSummary>>
|
||||
}
|
|
@ -6,6 +6,7 @@ import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
|||
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemProposal
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary
|
||||
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
||||
import es.verdnatura.presentation.view.feature.login.model.WorkForms
|
||||
import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier
|
||||
|
@ -46,6 +47,14 @@ interface OnAjustesItemClickListener {
|
|||
interface OnItemCardRowClickListener {
|
||||
fun onItemCardRowClickListener(item: ItemCardRowVO)
|
||||
}
|
||||
|
||||
interface OnItemImageLoadRowClickListener {
|
||||
fun onItemImageLoadRowClickListener(item: ExpeditionInfoSummary)
|
||||
}
|
||||
interface OnAddressRowClickListener {
|
||||
fun onAddressRowClickListener(item: ExpeditionInfoSummary)
|
||||
}
|
||||
|
||||
/*interface OnItemExpeditionStateRowClickListener {
|
||||
fun OnItemExpeditionStateRowClickListener(item: ItemExpeditionStateRow)
|
||||
}*/
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
package es.verdnatura.presentation.view.feature.delivery.adapters
|
||||
|
||||
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.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,
|
||||
private val onItemImageLoadRowClickListener: OnItemImageLoadRowClickListener
|
||||
) : RecyclerView.Adapter<ExpeditionSummaryAdapter.ItemHolder>() {
|
||||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||
return ItemHolder(
|
||||
ItemExpeditionSummaryRowBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
|
||||
holder.bind(items[position])
|
||||
|
||||
holder.binding.root.setOnClickListener {
|
||||
onAddressRowClickListener.onAddressRowClickListener(items[position])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inner class ItemHolder(
|
||||
val binding: ItemExpeditionSummaryRowBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
private val res = binding.root.context.resources
|
||||
fun bind(item: ExpeditionInfoSummary) {
|
||||
binding.apply {
|
||||
|
||||
if (item.delivery != item.total || item.delivered == item.total)
|
||||
|
||||
{
|
||||
fondo.setBackgroundColor(
|
||||
res.getColor(R.color.verdnatura_pumpkin_light)
|
||||
)
|
||||
}else{
|
||||
res.getColor(R.color.verdnatura_black)
|
||||
}
|
||||
|
||||
|
||||
/* if (item.lost == item.total || (item.lost!! > 0 && item.lost == item.total))
|
||||
{
|
||||
fondo.setBackgroundColor(
|
||||
res.getColor(R.color.verdnatura_pumpkin_orange)
|
||||
)
|
||||
}
|
||||
if (item.delivered != null && item.delivered == item.total
|
||||
) {
|
||||
fondo.setBackgroundColor(
|
||||
res.getColor(R.color.verdnatura_black)
|
||||
)
|
||||
}*/
|
||||
showExp.setOnClickListener {
|
||||
onItemImageLoadRowClickListener.onItemImageLoadRowClickListener(item)
|
||||
}
|
||||
this.item = item
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,438 @@
|
|||
package es.verdnatura.presentation.view.feature.delivery.fragments
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.gson.Gson
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentExpeditionSummaryBinding
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.*
|
||||
import es.verdnatura.presentation.view.feature.delivery.adapters.ExpeditionSummaryAdapter
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary
|
||||
import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
|
||||
|
||||
class SummaryFragment(
|
||||
var title: String = "",
|
||||
var state: String = "",
|
||||
var route: Int = 0,
|
||||
) : BaseFragment<FragmentExpeditionSummaryBinding, DeliveryViewModel>(
|
||||
DeliveryViewModel::class
|
||||
) {
|
||||
|
||||
private var adapter: ExpeditionSummaryAdapter? = null
|
||||
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||
private var originalItem: Int = 0
|
||||
private lateinit var myList: MutableList<ExpeditionInfoLoadUnload>
|
||||
private lateinit var myListSummary: List<ExpeditionInfoSummary>
|
||||
private var counterCalls = 0
|
||||
private var counterResponse = 0
|
||||
private var positionOnScreen = 0
|
||||
private var addressFkSelected = 0
|
||||
private var routeSelected = 161059
|
||||
private var isScanning = false
|
||||
private var positionSelected = -1
|
||||
|
||||
|
||||
companion object {
|
||||
fun newInstance(title: String, state: String) = SummaryFragment(title, state)
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.fragment_expedition_summary
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun init() {
|
||||
setEvents()
|
||||
setToolBar()
|
||||
binding.scanInput.requestFocus()
|
||||
callBack(viewModel.route_getExpeditionSummary(routeSelected))
|
||||
setViews()
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
fun onLoadSelected(view: View) {
|
||||
println("Pulsado")
|
||||
}
|
||||
|
||||
private fun callBack(routeGetexpeditionsummary: Unit) {
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
routeGetexpeditionsummary
|
||||
}
|
||||
|
||||
private fun setViews() {
|
||||
binding.expeditionSummaryRecyclerview.addOnScrollListener(object :
|
||||
RecyclerView.OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
positionOnScreen =
|
||||
(recyclerView.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition()
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
private fun setToolBar() {
|
||||
ma.hideBottomNavigation(View.GONE)
|
||||
binding.mainToolbar.toolbarTitle.visibility = View.VISIBLE
|
||||
binding.mainToolbar.toolbarSubtitle.visibility = View.VISIBLE
|
||||
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
|
||||
binding.mainToolbar.toolbarTitle.text = title
|
||||
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
val iconLoad = ImageView(context)
|
||||
val iconExit = ImageView(context)
|
||||
|
||||
iconLoad.setImageResource(R.drawable.camion)
|
||||
iconExit.setImageResource(R.drawable.exit)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
iconLoad.tooltipText = getTooltip(R.drawable.camion)
|
||||
iconExit.tooltipText = getTooltip(R.drawable.exit)
|
||||
}
|
||||
listIcons.add(iconLoad)
|
||||
listIcons.add(iconExit)
|
||||
|
||||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||
|
||||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
|
||||
when (item) {
|
||||
iconLoad.drawable -> {
|
||||
openLoadUnLoad(0)
|
||||
}
|
||||
|
||||
iconExit.drawable -> {
|
||||
ma.onBackPressed()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
binding.mainToolbar.toolbarIcons.layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
private fun openLoadUnLoad(adress:Int) {
|
||||
|
||||
var entryPoint = Gson().toJson(
|
||||
mutableMapOf(
|
||||
"route" to routeSelected,
|
||||
"address" to adress
|
||||
)
|
||||
)
|
||||
|
||||
ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(title = getString(R.string.titleLoadTruck)),
|
||||
entryPoint
|
||||
)
|
||||
}
|
||||
|
||||
private fun setExpeditionsState(
|
||||
list: MutableList<ExpeditionInfoLoadUnload>,
|
||||
state: String,
|
||||
address: Int
|
||||
) {
|
||||
|
||||
|
||||
if (list.filter { it.addressFk == address }
|
||||
.filter { it.code == state }.size == list.filter { it.addressFk == address }.size) {
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
callBack(viewModel.expeditionState_add(list.filter { it.addressFk == address }
|
||||
.filter { it.code == state }, state))
|
||||
counterCalls = 1
|
||||
isScanning = false
|
||||
} else {
|
||||
|
||||
val alertDialog = android.app.AlertDialog.Builder(requireContext()).create()
|
||||
alertDialog.setTitle("Información")
|
||||
alertDialog.setMessage("El total de expediciones escaneadas es diferente al total de la ruta. ¿ Quieres guardar las expediciones escaneadas o buscar la/s expedición/es ?")
|
||||
alertDialog.setButton(
|
||||
android.app.AlertDialog.BUTTON_POSITIVE, "GUARDAR"
|
||||
) { dialog, which ->
|
||||
counterCalls = 2
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
|
||||
viewModel.expeditionState_add(list.filter { it.addressFk == address }
|
||||
.filter { it.code == state }, state)
|
||||
viewModel.expeditionState_add(list.filter { it.addressFk == address }
|
||||
.filter { it.code != state }, "LOST")
|
||||
}
|
||||
alertDialog.setButton(
|
||||
android.app.AlertDialog.BUTTON_NEUTRAL, "BUSCAR"
|
||||
) { dialog, which ->
|
||||
//createList(list.sortedByDescending { it.code })
|
||||
}
|
||||
alertDialog.show()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun openAppDelivery() {
|
||||
val i = Intent()
|
||||
val manager: PackageManager = requireContext().packageManager
|
||||
val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0)
|
||||
val version = info.versionName
|
||||
|
||||
if (version.contains("Beta")) {
|
||||
i.setClassName(
|
||||
"verdnatura.es.repartoverdnatura.sfusion",
|
||||
"verdnatura.es.repartoverdnatura.ExpeditionSummaryActivity"
|
||||
)
|
||||
} else {
|
||||
i.setClassName(
|
||||
"verdnatura.es.repartoverdnatura",
|
||||
"verdnatura.es.repartoverdnatura.ExpeditionSummaryActivity"
|
||||
)
|
||||
}
|
||||
// i.putExtra("routeId", binding.route.text)
|
||||
i.putExtra("app", "picking")
|
||||
startActivity(i)
|
||||
}
|
||||
|
||||
private fun setEvents() {
|
||||
binding.mainToolbar.backButton.setOnClickListener {
|
||||
requireActivity().onBackPressed()
|
||||
/* val callback = object : OnBackPressedCallback(true /* enabled by default */) {
|
||||
override fun handleOnBackPressed() {
|
||||
println("volviendo antras")
|
||||
}
|
||||
}
|
||||
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)*/
|
||||
}
|
||||
|
||||
binding.scanInput.setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
if (!binding.scanInput.text.isNullOrEmpty()) {
|
||||
isScanning = true
|
||||
try {
|
||||
markExpedition(
|
||||
binding.scanInput.text.toString().toInt(),
|
||||
"ON DELIVERY"
|
||||
)
|
||||
|
||||
} catch (ex: Exception) {
|
||||
getString(R.string.errorExpedition).toast(context, Toast.LENGTH_SHORT)
|
||||
}
|
||||
binding.scanInput.setText("")
|
||||
}
|
||||
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun markExpedition(expedNumber: Int, state: String) {
|
||||
|
||||
var found = false
|
||||
if (myList.filter { it.addressFk == addressFkSelected }.filter { it.id == expedNumber }
|
||||
.filter { it.code == state }.isNotEmpty()) {
|
||||
ma.messageWithSound(getString(R.string.expeditionMarked), null, true)
|
||||
} else {
|
||||
for (exped in myList.filter { it.addressFk == addressFkSelected }) {
|
||||
if (exped.id == expedNumber) {
|
||||
found = true
|
||||
exped.code = state
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
ma.messageWithSound("", false, true, isToasted = false)
|
||||
} else {
|
||||
ma.messageWithSound("", true, true, isToasted = null)
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
updateCount(myList, state)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
|
||||
expeditionInfoLoadUnloadList.observe(viewLifecycleOwner) {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
createList(it.list as MutableList<ExpeditionInfoLoadUnload>)
|
||||
}
|
||||
|
||||
expeditionInfoSummary.observe(viewLifecycleOwner) {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
createListSummary(it.list)
|
||||
}
|
||||
|
||||
routeInfoList.observe(viewLifecycleOwner) {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
if (it.list.isNotEmpty()) {
|
||||
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
|
||||
binding.mainToolbar.switchButton.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.scanInput.setText("")
|
||||
binding.mainToolbar.toolbarIcons.visibility = View.GONE
|
||||
binding.mainToolbar.switchButton.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
responseStateAdd.observe(viewLifecycleOwner) {
|
||||
binding.splashProgress.visibility = View.GONE
|
||||
if (!it.isError) {
|
||||
counterResponse = counterResponse + 1
|
||||
if (counterResponse == counterCalls) {
|
||||
callBack(viewModel.route_getExpeditionSummary(routeSelected))
|
||||
counterResponse = 0
|
||||
counterCalls = 0
|
||||
checkNextAddress()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkNextAddress() {
|
||||
|
||||
if (myListSummary.size > positionSelected + 1) {
|
||||
|
||||
val startIndex = positionSelected
|
||||
|
||||
for ((indice, elemento) in myListSummary.withIndex()) {
|
||||
if (indice >= startIndex) {
|
||||
// Realiza las operaciones necesarias con el elemento
|
||||
if (myList.filter { it.addressFk == elemento.addressFk }
|
||||
.filter { it.code == state }.size != myList.filter { it.addressFk == elemento.addressFk }.size) {
|
||||
addressFkSelected = myListSummary[indice].addressFk
|
||||
positionSelected = indice
|
||||
break
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if (myList.filter { it.addressFk == addressFkSelected }
|
||||
.filter { it.code == state }.size == myList.filter { it.addressFk == addressFkSelected }.size) {
|
||||
*/
|
||||
/*println("la posision del adress" + positionSelected)
|
||||
println("el addressSelecttionado" + addressFkSelected)
|
||||
println("el nuevo addressSelecttionado" + myListSummary[positionSelected + 1].addressFk)*/
|
||||
|
||||
|
||||
} else {
|
||||
addressFkSelected = myListSummary[positionSelected].addressFk
|
||||
|
||||
}
|
||||
|
||||
|
||||
setTitleSummary()
|
||||
}
|
||||
|
||||
private fun createListSummary(list: List<ExpeditionInfoSummary>) {
|
||||
|
||||
myListSummary = list
|
||||
adapter = ExpeditionSummaryAdapter(list, object : OnAddressRowClickListener {
|
||||
override fun onAddressRowClickListener(item: ExpeditionInfoSummary) {
|
||||
|
||||
positionSelected = myListSummary.indexOf(item)
|
||||
println("la pos es " + positionSelected)
|
||||
binding.scanInput.isEnabled = true
|
||||
binding.scanInput.requestFocus()
|
||||
|
||||
if (addressFkSelected != item.addressFk && !isScanning) {
|
||||
|
||||
callBack(viewModel.getExpeditionFromRoute(routeSelected))
|
||||
|
||||
}
|
||||
if (addressFkSelected != item.addressFk && isScanning) {
|
||||
//actualiza el estado de las expediciones escaneadas
|
||||
setExpeditionsState(myList, state, addressFkSelected)
|
||||
|
||||
}
|
||||
addressFkSelected = item.addressFk
|
||||
isScanning = false
|
||||
callBack(viewModel.getExpeditionFromRoute(routeSelected))
|
||||
}
|
||||
|
||||
}, object : OnItemImageLoadRowClickListener {
|
||||
override fun onItemImageLoadRowClickListener(item: ExpeditionInfoSummary) {
|
||||
openLoadUnLoad(item.addressFk)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.expeditionSummaryRecyclerview.adapter = adapter
|
||||
binding.expeditionSummaryRecyclerview.layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
adapter!!.notifyDataSetChanged()
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun createList(list: MutableList<ExpeditionInfoLoadUnload>) {
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text = "R:" + routeSelected + " C:" + addressFkSelected +
|
||||
" ${
|
||||
list.filter { it.addressFk == addressFkSelected }
|
||||
.filter { it.code == "ON DELIVERY" }.size
|
||||
}/${list.filter { it.addressFk == addressFkSelected }.size}"
|
||||
myList = list
|
||||
|
||||
}
|
||||
|
||||
private fun setListPosition(list: MutableList<ExpeditionInfoLoadUnload>) {
|
||||
for (i in list.indices) {
|
||||
if (list[i].code != state) {
|
||||
binding.expeditionSummaryRecyclerview.scrollToPosition(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun updateCount(list: MutableList<ExpeditionInfoLoadUnload>, state: String) {
|
||||
val countMarked =
|
||||
list.filter { it.addressFk == addressFkSelected }.filter { it.code == state }.size
|
||||
// getString(R.string.summaryCount, countMarked, list.size)
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text = "R:${routeSelected} C:${addressFkSelected} ${
|
||||
countMarked
|
||||
}/${list.filter { it.addressFk == addressFkSelected }.size}"
|
||||
|
||||
if (countMarked == list.filter { it.addressFk == addressFkSelected }.size) {
|
||||
setExpeditionsState(list, state, addressFkSelected)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setTitleSummary() {
|
||||
val countMarked =
|
||||
myList.filter { it.addressFk == addressFkSelected }.filter { it.code == state }.size
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text = "R:${routeSelected} C:${addressFkSelected} ${
|
||||
countMarked
|
||||
}/${myList.filter { it.addressFk == addressFkSelected }.size}"
|
||||
}
|
||||
}
|
|
@ -8,10 +8,7 @@ import es.verdnatura.domain.SilexCallback
|
|||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.common.ResponseItemVO
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.*
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
import retrofit2.http.POST
|
||||
|
||||
class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
|
||||
|
||||
|
@ -21,6 +18,9 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
|
|||
private val _expeditionInfoLoadUnloadList by lazy { MutableLiveData<ExpeditionList>() }
|
||||
val expeditionInfoLoadUnloadList: LiveData<ExpeditionList> = _expeditionInfoLoadUnloadList
|
||||
|
||||
private val _expeditionInfoSummary by lazy { MutableLiveData<ExpeditionSummaryList>() }
|
||||
val expeditionInfoSummary: LiveData<ExpeditionSummaryList> = _expeditionInfoSummary
|
||||
|
||||
private val _routeInfoList by lazy { MutableLiveData<RouteDeliveryList>() }
|
||||
val routeInfoList: LiveData<RouteDeliveryList> = _routeInfoList
|
||||
|
||||
|
@ -136,7 +136,7 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
}
|
||||
|
||||
fun expeditionState_add(expeditions: Any?, state: String) {
|
||||
fun expeditionState_add(expeditions: Any?, state: String) {
|
||||
|
||||
silex.expeditionState_add(expeditions, state)
|
||||
.enqueue(object : SilexCallback<Void>(context) {
|
||||
|
@ -175,6 +175,32 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun route_getExpeditionSummary(
|
||||
route: Int
|
||||
) {
|
||||
silex.route_getExpeditionSummary(route)
|
||||
.enqueue(object : SilexCallback<List<ExpeditionInfoSummary>>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<List<ExpeditionInfoSummary>>) {
|
||||
|
||||
if (response.body() != null) {
|
||||
_expeditionInfoSummary.value =
|
||||
response.body()?.let { ExpeditionSummaryList(it) }
|
||||
} else {
|
||||
_expeditionInfoSummary.value = ExpeditionSummaryList()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
_expeditionInfoSummary.value = ExpeditionSummaryList()
|
||||
super.onError(t)
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlV
|
|||
import es.verdnatura.presentation.view.feature.delivery.fragments.InfoFragment
|
||||
import es.verdnatura.presentation.view.feature.delivery.fragments.LoadUnloadFragment
|
||||
import es.verdnatura.presentation.view.feature.delivery.fragments.LogExpeditionFragment
|
||||
import es.verdnatura.presentation.view.feature.delivery.fragments.SummaryFragment
|
||||
import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleFragment
|
||||
import es.verdnatura.presentation.view.feature.historicoarticulo.fragment.HistoricoArticuloFragment
|
||||
import es.verdnatura.presentation.view.feature.historicoshelving.fragment.itemShelvingLogFragment
|
||||
|
@ -614,6 +615,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
getString(R.string.titleInfo) -> {
|
||||
addFragmentOnTop(
|
||||
InfoFragment.newInstance(item.title),
|
||||
|
@ -640,9 +643,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
}
|
||||
|
||||
getString(R.string.titleLoadTruck) -> {
|
||||
|
||||
addFragmentOnTop(
|
||||
LoadUnloadFragment.newInstance(item.title, "ON DELIVERY"),
|
||||
LoadUnloadFragment.newInstance(item.title, "ON DELIVERY",entryPoint),
|
||||
if (comeFromDelivery == true) {
|
||||
getString(R.string.titleLoadTruck)
|
||||
} else {
|
||||
|
@ -655,7 +657,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
getString(R.string.titleUnLoadTruck) -> {
|
||||
|
||||
addFragmentOnTop(
|
||||
LoadUnloadFragment.newInstance(item.title, "DELIVERED"),
|
||||
LoadUnloadFragment.newInstance(item.title, "DELIVERED",entryPoint),
|
||||
if (comeFromDelivery == true) {
|
||||
getString(R.string.titleUnLoadTruck)
|
||||
} else {
|
||||
|
@ -665,6 +667,19 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
|
||||
}
|
||||
|
||||
getString(R.string.titleDeliverySummary) -> {
|
||||
|
||||
addFragmentOnTop(
|
||||
SummaryFragment.newInstance(item.title, "ON DELIVERY"),
|
||||
if (comeFromDelivery == true) {
|
||||
getString(R.string.titleDeliverySummary)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
getString(R.string.testing) -> {
|
||||
addFragmentOnTop(testPrint.newInstance(item.title))
|
||||
|
|
|
@ -490,7 +490,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
|||
)
|
||||
|
||||
//Tarea 4678
|
||||
/* _pasillerositem.add(
|
||||
_pasillerositem.add(
|
||||
PasillerosItemVO(
|
||||
6,
|
||||
R.drawable.ic_delivery_truck,
|
||||
|
@ -498,7 +498,8 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
|||
R.string.titleDelivery,
|
||||
contextApp.getString(R.string.titleDelivery)
|
||||
)
|
||||
)*/
|
||||
)
|
||||
|
||||
|
||||
//#tarea4679
|
||||
/* _pasillerositem.add(
|
||||
|
@ -599,5 +600,18 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
|||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
_pasillerositem.add(
|
||||
PasillerosItemVO(
|
||||
6,
|
||||
R.drawable.ic_delivery_truck,
|
||||
contextApp.getString(R.string.titleDeliverySummary),
|
||||
R.string.titleDeliverySummary,
|
||||
contextApp.getString(R.string.titleDeliverySummary)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
|
@ -0,0 +1,194 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/scan_input"
|
||||
style="@style/ScanLineTextSearch"
|
||||
android:layout_width="match_parent"
|
||||
android:hint="@string/titleExpeditionScan"
|
||||
android:inputType="text"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:enabled="false"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/main_toolbar"/>
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/txtDescriptions"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/scan_input">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtConsignatario"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Consign"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtRoute"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:text="Ruta"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtBox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Cajas"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtPacking"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Tipo"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtSc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Escan"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtLost"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Perdidas"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtDelivered"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Entregadas"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/verdnatura_white"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/txtDescriptions"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/itemcard_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="ExtraText"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+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"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:visibility="visible"
|
||||
tools:listitem="@layout/item_expedition_summary_row" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scroll_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<include
|
||||
android:id="@+id/main_toolbar"
|
||||
layout="@layout/toolbar_fragment"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/splash_progress"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/verdnatura_black_8_alpha_6"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:gravity="center">
|
||||
|
||||
<com.airbnb.lottie.LottieAnimationView
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/verdnatura_logo_large_height"
|
||||
app:lottie_autoPlay="true"
|
||||
app:lottie_loop="true"
|
||||
app:lottie_rawRes="@raw/orange_loading"
|
||||
app:lottie_speed="2" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
|
@ -0,0 +1,115 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="item"
|
||||
type="es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/fondo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="2dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingLeft="2dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtConsignatario"
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{Integer.toString(item.addressFk)}"
|
||||
android:layout_weight="1"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="522515"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtRoute"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{Integer.toString(item.routeFk)}"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtTotal"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@{Integer.toString(item.total)}"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="10"/>
|
||||
<TextView
|
||||
android:id="@+id/txtPacking"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@{item.itemPackingType}"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="H"/>
|
||||
<TextView
|
||||
android:id="@+id/txtScanned"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@{Integer.toString(item.delivery)}"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="5"/>
|
||||
<TextView
|
||||
android:id="@+id/txtLost"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@{Integer.toString(item.lost)}"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="5"/>
|
||||
<TextView
|
||||
android:id="@+id/txtDelivered"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@{Integer.toString(item.delivered)}"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="5"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/showExp"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:contentDescription=""
|
||||
android:tooltipText="Permite escanear expediciones del consigntario seleccionado"
|
||||
app:srcCompat="@drawable/camion" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
Loading…
Reference in New Issue