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()) { if (!binding.editMatricula.text.toString().isNullOrEmpty()) {
contador += 1 contador += 1
setSubtitle() setSubtitle()
binding.editMatricula.setText(textScanned_filterDouble(binding.editMatricula.text.toString())) // binding.editMatricula.setText(textScanned_filterDouble(binding.editMatricula.text.toString()))
try { try {
listItems.add( listItems.add(
0, ItemEscanerVO( 0, ItemEscanerVO(
itemScanValue( itemScanValue(
textScanned_filterDouble(binding.editMatricula.text.toString()),
binding.editMatricula.text.toString(),
"buy", "buy",
"more" "more"
).toString().toLong() ).toString().toLong()
) )
) )
adapter!!.notifyDataSetChanged() adapter!!.notifyItemInserted(listItems.size)
} catch (ex: Exception) { } catch (ex: Exception) {
ma.messageWithSound(ex.message.toString(), true, true) ma.messageWithSound(ex.message.toString(), true, true)
} }

View File

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

View File

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