refs lentitud al leer codigos y fallo al volver atrás

This commit is contained in:
Sergio De la torre 2023-05-31 16:01:54 +02:00
parent b1fd26327a
commit 22faafd907
3 changed files with 63 additions and 25 deletions

View File

@ -76,19 +76,18 @@ class AutomaticAddItemFragment(
if (!binding.editMatricula.text.toString().isNullOrEmpty()) {
contador += 1
setSubtitle()
binding.editMatricula.setText(textScanned_filterDouble(binding.editMatricula.text.toString()))
// binding.editMatricula.setText(textScanned_filterDouble(binding.editMatricula.text.toString()))
try {
listItems.add(
0, ItemEscanerVO(
itemScanValue(
binding.editMatricula.text.toString(),
textScanned_filterDouble(binding.editMatricula.text.toString()),
"buy",
"more"
).toString().toLong()
)
)
adapter!!.notifyDataSetChanged()
adapter!!.notifyItemInserted(listItems.size)
} catch (ex: Exception) {
ma.messageWithSound(ex.message.toString(), true, true)
}

View File

@ -82,7 +82,7 @@ class UbicadorFragment(
customDialogUbicador = CustomDialogUbicador(requireContext())
customDialogTwoButtons = CustomDialogTwoButtons(requireContext())
ma.hideBottomNavigation(View.GONE)
ma.hideBottomNavigation(GONE)
binding.mainToolbar.toolbarTitle.text = if (!isAutoSelf) {
getString(R.string.locator)
} else {
@ -224,6 +224,7 @@ class UbicadorFragment(
binding.mainToolbar.toolbarTitle.text =
binding.editMatricula.text.toString()
shelvingFk = binding.editMatricula.text.toString()
parking = ""
binding.editPrioridad.setText("")
binding.splashProgress.visibility = VISIBLE
isShelvinLogfromMainScreen = true
@ -560,22 +561,35 @@ class UbicadorFragment(
}
}
})
responseAddList.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE
if (it.isError) {
ma.messageWithSound(it.errorMessage, it.isError, false)
loadAddList.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
binding.splashProgress.visibility = GONE
if (it.isError) {
ma.messageWithSound(it.errorMessage, it.isError, false)
} else {
binding.splashProgress.visibility = VISIBLE
viewModel.itemShelvingList(shelvingFk)
} else {
binding.splashProgress.visibility = VISIBLE
viewModel.itemShelvingList(shelvingFk)
}
}
})
}
/* responseAddList.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE
if (it.isError) {
ma.messageWithSound(it.errorMessage, it.isError, false)
} else {
binding.splashProgress.visibility = VISIBLE
viewModel.itemShelvingList(shelvingFk)
}
})*/
response.observe(viewLifecycleOwner, Observer {
if (it.isError) {
binding.splashProgress.visibility = GONE
ma.messageWithSound(it.errorMessage, it.isError, false)
ma.messageWithSound(it.errorMessage, it.isError, true)
} else {
@ -595,16 +609,33 @@ class UbicadorFragment(
}
})
responseCode.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE
if (it.isError) {
ma.messageWithSound(it.errorMessage, true, true)
} else {
checkUbications(it.response.toInt())
loadResponseCode.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull {
binding.splashProgress.visibility = GONE
if (it.isError) {
ma.messageWithSound(it.errorMessage, it.isError, false)
} else {
if (it.response != "0") {
checkUbications(it.response.toInt())
} else {
ma.messageWithSound(getString(R.string.labelNovalid), true, true)
}
}
}
}
/* responseCode.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE
if (it.isError) {
ma.messageWithSound(it.errorMessage, true, true)
} else {
if (it.response!="0") {checkUbications(it.response.toInt())}else{
ma.messageWithSound(getString(R.string.labelNovalid), true, true)
}
}
})
})*/
responsepriority.observe(viewLifecycleOwner, Observer {
if (!isBack) {
binding.splashProgress.visibility = GONE
@ -648,9 +679,12 @@ class UbicadorFragment(
try {
if (customDialogInput.getValue().toInt() > 0) {
binding.splashProgress.visibility = VISIBLE
var quantity = if (item.visible.toInt()-customDialogInput.getValue().toInt()>0){
item.visible.toInt()-customDialogInput.getValue().toInt()
}else{ 0 }
var quantity =
if (item.visible.toInt() - customDialogInput.getValue().toInt() > 0) {
item.visible.toInt() - customDialogInput.getValue().toInt()
} else {
0
}
viewModel.itemShelving_selfConsumption(
shelvingFk,
item.item,

View File

@ -36,6 +36,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
val loadShelvingList = Transformations.map(_shelvingList) { Event(it) }
private val _reubicationList by lazy { MutableLiveData<ReubicationList>() }
val loadReubicationList = Transformations.map(_reubicationList) { Event(it) }
@ -43,9 +44,13 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
val responseCode: LiveData<ResponseItemVO>
get() = _responseCode
val loadResponseCode = Transformations.map(_responseCode) { Event(it) }
private val _responseAddList by lazy { MutableLiveData<ResponseItemVO>() }
val responseAddList: LiveData<ResponseItemVO> = _responseAddList
val loadAddList = Transformations.map(_responseAddList) { Event(it) }
private val _responseLog by lazy { MutableLiveData<ResponseItemVO>() }
val responseLog: LiveData<ResponseItemVO>
get() = _responseLog
@ -460,7 +465,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
)
} else {
_responseCode.value =
ResponseItemVO(isError = false, response = response.body()!!)
ResponseItemVO(isError = false, response = response.body()!!.toString())
}
}
})