refs #6440: errorNaturPhotos
This commit is contained in:
parent
18dd98cf7d
commit
a9814013cb
|
@ -34,6 +34,10 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
||||||
val response: LiveData<ResponseItemVO>
|
val response: LiveData<ResponseItemVO>
|
||||||
get() = _response
|
get() = _response
|
||||||
|
|
||||||
|
private val _responseCode by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
|
val responseCode: LiveData<ResponseItemVO>
|
||||||
|
get() = _responseCode
|
||||||
|
|
||||||
private val _itemspackinglist by lazy { MutableLiveData<ItemPackingTypeList>() }
|
private val _itemspackinglist by lazy { MutableLiveData<ItemPackingTypeList>() }
|
||||||
val itemspackinglist: LiveData<ItemPackingTypeList>
|
val itemspackinglist: LiveData<ItemPackingTypeList>
|
||||||
get() = _itemspackinglist
|
get() = _itemspackinglist
|
||||||
|
@ -221,6 +225,23 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getIdFromCodeSalix(code: String) {
|
||||||
|
salix.barcodes_toitem(code)
|
||||||
|
.enqueue(object : SalixCallback<String?>(context) {
|
||||||
|
|
||||||
|
override fun onSuccess(response: Response<String?>) {
|
||||||
|
_responseCode.value =
|
||||||
|
ResponseItemVO(
|
||||||
|
isError = false,
|
||||||
|
response = if (response.body() == null) "" else {
|
||||||
|
response!!.body().toString()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fun barcodesEdit(
|
fun barcodesEdit(
|
||||||
itemFk: Int,
|
itemFk: Int,
|
||||||
value: String,
|
value: String,
|
||||||
|
|
|
@ -39,7 +39,7 @@ class PhotosFragment(
|
||||||
private val PICK_IMAGE_REQUEST = 1
|
private val PICK_IMAGE_REQUEST = 1
|
||||||
private val REQUEST_IMAGE_CAPTURE = 2
|
private val REQUEST_IMAGE_CAPTURE = 2
|
||||||
private val imageUri: Uri? = null
|
private val imageUri: Uri? = null
|
||||||
private var originalItem: Number = 0
|
private var originalItem: String = ""
|
||||||
|
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_photos
|
override fun getLayoutId(): Int = R.layout.fragment_photos
|
||||||
|
|
||||||
|
@ -108,20 +108,17 @@ class PhotosFragment(
|
||||||
binding.editItemFk.setOnEditorActionListener { _, actionId, _ ->
|
binding.editItemFk.setOnEditorActionListener { _, actionId, _ ->
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
if (!binding.editItemFk.text.toString().isEmpty()) {
|
if (!binding.editItemFk.text.toString().isEmpty()) {
|
||||||
|
|
||||||
originalItem = itemScanValue(
|
|
||||||
binding.editItemFk.text.toString(),
|
|
||||||
"buy",
|
|
||||||
"more"
|
|
||||||
).toString().toLong()
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
viewModel.getItemCard(
|
originalItem = itemScanValue(
|
||||||
originalItem, mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
|
binding.editItemFk.text.toString(),
|
||||||
)
|
"buy",
|
||||||
|
"more"
|
||||||
|
).toString()
|
||||||
|
|
||||||
} catch (Ex: Exception) {
|
viewModel.getIdFromCodeSalix(originalItem)
|
||||||
ma.messageWithSound(Ex.message.toString(), true, true)
|
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
ma.messageWithSound(ex.message.toString(), true, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.editItemFk.setText("")
|
binding.editItemFk.setText("")
|
||||||
|
@ -177,9 +174,22 @@ class PhotosFragment(
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
responseCode.observe(viewLifecycleOwner) {
|
||||||
|
if (it.response.isNotBlank()) {
|
||||||
|
viewModel.getItemCard(
|
||||||
|
it.response.toLong(),
|
||||||
|
mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
ma.messageWithSound(
|
||||||
|
getString(R.string.itemScanetNotFound),
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
getString(R.string.noResults)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun upLoadPhoto() {
|
private fun upLoadPhoto() {
|
||||||
|
@ -191,7 +201,7 @@ class PhotosFragment(
|
||||||
if (drawable is BitmapDrawable) {
|
if (drawable is BitmapDrawable) {
|
||||||
val bitmap = drawable.bitmap
|
val bitmap = drawable.bitmap
|
||||||
viewModel.uploadPhoto(
|
viewModel.uploadPhoto(
|
||||||
itemFK = originalItem,
|
itemFK = originalItem.toLong(),
|
||||||
urlImage = saveBitmapAsTempFile(requireContext(), bitmap)
|
urlImage = saveBitmapAsTempFile(requireContext(), bitmap)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue