feat issues refs #7636
This commit is contained in:
parent
6331fee2e1
commit
56fe4c3486
|
@ -71,17 +71,23 @@ abstract class SalixCallback<T>(val context: Context) : Callback<T> {
|
|||
}
|
||||
|
||||
private fun errorSalixMessage(response: Response<T>, errorBody: String?): String {
|
||||
val myErrorCodeBody = errorBody?.let { errorBodyString
|
||||
|
||||
var myErrorCodeBody = errorBody?.let { errorBodyString
|
||||
->
|
||||
JSONObject(errorBodyString).getJSONObject("error").getString("code")
|
||||
JSONObject(errorBodyString).getJSONObject("error").optString("code")
|
||||
}
|
||||
myErrorCodeBody += errorBody?.let { errorBodyString
|
||||
->
|
||||
JSONObject(errorBodyString).getJSONObject("error").optString("message")
|
||||
}
|
||||
return try {
|
||||
val messageResponse = response.errorBody()!!.string()
|
||||
val jsonObject = Gson().fromJson(messageResponse, JsonObject::class.java)
|
||||
var messageJson = jsonObject?.getAsJsonObject("error")?.get("message")?.asString
|
||||
messageJson ?: "${response.message()}.$myErrorCodeBody"
|
||||
var messageJsonCode = jsonObject?.getAsJsonObject("error")?.get("code")?.asString?:""
|
||||
messageJson ?: "${response.message()}.$myErrorCodeBody.$messageJsonCode"
|
||||
} catch (ex: Exception) {
|
||||
response.message() + ".$myErrorCodeBody"
|
||||
response.message() + ".$myErrorCodeBody."
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -159,7 +159,17 @@ class ControlVehiculoFragment(
|
|||
private fun checkControlTimeVehicle() {
|
||||
|
||||
if (!goBack) {
|
||||
viewModel.workerMachineryIsRegistered(mobileApplication.userId!!)
|
||||
try {
|
||||
viewModel.workerMachineryIsRegistered(mobileApplication.userId!!)
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorUserId),
|
||||
isError = true,
|
||||
isToasted = true,
|
||||
isPlayed = true
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,7 +307,7 @@ class ControlVehiculoFragment(
|
|||
|
||||
with(viewModel) {
|
||||
responseUpdate.observe(viewLifecycleOwner) {
|
||||
ma.openFragmentPickers(false)
|
||||
ma.openFragmentPickers(false)
|
||||
}
|
||||
|
||||
responseControl.observe(viewLifecycleOwner) {
|
||||
|
|
|
@ -79,40 +79,41 @@ class ControlVehiculoUsuarioFragment(
|
|||
|
||||
private fun setControlVehicleUser() {
|
||||
|
||||
userFk = mobileApplication.userId!!
|
||||
println("userFK $userFk")
|
||||
try {
|
||||
userFk = mobileApplication.userId!!
|
||||
|
||||
if (userFk == vUserFK) {
|
||||
val androidId: String = mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID)
|
||||
viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
|
||||
viewModel.deviceProductionGetnameDevice(
|
||||
androidId
|
||||
if (userFk == vUserFK) {
|
||||
val androidId: String = mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID)
|
||||
viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
|
||||
viewModel.deviceProductionGetnameDevice(
|
||||
androidId
|
||||
)
|
||||
viewModel.deviceProductionUserGetWorker(
|
||||
androidId
|
||||
)
|
||||
} else {
|
||||
userFk = vUserFK
|
||||
binding.userInformation.visibility = INVISIBLE
|
||||
binding.nameVehiclecontrol.visibility = INVISIBLE
|
||||
binding.userImage.setOnClickListener { binding.mainToolbar.backButton.performClick() }
|
||||
viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
|
||||
viewModel.getNameWorker(userFk)
|
||||
}
|
||||
|
||||
binding.userImage.loadUrl(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
ConstAndValues.BASEURLSALIX
|
||||
) + "/api/Images/user/160x160/$userFk/download?access_token=${
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
TOKEN
|
||||
)
|
||||
}"
|
||||
)
|
||||
viewModel.deviceProductionUserGetWorker(
|
||||
androidId
|
||||
)
|
||||
} else {
|
||||
userFk = vUserFK
|
||||
binding.userInformation.visibility = INVISIBLE
|
||||
binding.nameVehiclecontrol.visibility = INVISIBLE
|
||||
binding.userImage.setOnClickListener { binding.mainToolbar.backButton.performClick() }
|
||||
viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
|
||||
viewModel.getNameWorker(userFk)
|
||||
}catch (ex:Exception) {
|
||||
ma.messageWithSound(message = getString(R.string.errorUserId), isError = true, isToasted = true, isPlayed = true)
|
||||
}
|
||||
|
||||
binding.userImage.loadUrl(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
ConstAndValues.BASEURLSALIX
|
||||
) + "/api/Images/user/160x160/$userFk/download?access_token=${
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
TOKEN
|
||||
)
|
||||
}"
|
||||
)
|
||||
binding.nameVehiclecontrol.text = mobileApplication.userName
|
||||
binding.registeredVehiclecontrol.text = ""
|
||||
binding.deviceName.text = ""
|
||||
binding.assignedDevicename.text = ""
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -228,15 +228,23 @@ class LoadUnloadFragment(
|
|||
}
|
||||
|
||||
private fun openSignActivity() {
|
||||
val intent = Intent(requireContext(), SignedActivity::class.java)
|
||||
try {
|
||||
val intent = Intent(requireContext(), SignedActivity::class.java)
|
||||
intent.putExtra(
|
||||
"clientTicketList", clientTicketList!!.first()
|
||||
)
|
||||
intent.putExtra("objectSigned", "ticket") //cmr
|
||||
startActivity(intent)
|
||||
ma.onMyBackPressed()
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorSignActivity),
|
||||
isError = true,
|
||||
isToasted = true,
|
||||
isPlayed = true
|
||||
)
|
||||
}
|
||||
|
||||
intent.putExtra(
|
||||
"clientTicketList", clientTicketList!!.first()
|
||||
)
|
||||
|
||||
intent.putExtra("objectSigned", "ticket") //cmr
|
||||
startActivity(intent)
|
||||
ma.onMyBackPressed()
|
||||
}
|
||||
|
||||
private fun setEvents() {
|
||||
|
|
|
@ -852,5 +852,8 @@
|
|||
<string name="errorGetData">errorGetData</string>
|
||||
<string name="errorSector">No tienes sector seleccionado. Ve a pantalla ajustes y selecciona uno</string>
|
||||
<string name="errorBoxPicking">La expedición ya ha sido revisada. Pregunta encargado por si se ha preparado dos veces.</string>
|
||||
<string name="errorUserId">No se podido obtener tu id. Vuelve a intentarlo</string>
|
||||
<string name="errorScanItem">Error al escanea el artículo. Inténtalo de nuevo</string>
|
||||
<string name="errorSignActivity">Vuelve a pulsar para intentar firmar</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -852,5 +852,8 @@
|
|||
<string name="errorGetData">Fallo al intentar obtener datos. Avise a Informática</string>
|
||||
<string name="errorSector">No tienes sector seleccionado. Ve a pantalla ajustes y selecciona uno</string>
|
||||
<string name="errorBoxPicking">La expedición ya ha sido revisada. Pregunta encargado por si se ha preparado dos veces.</string>
|
||||
<string name="errorUserId">No se podido obtener tu id. Vuelve a intentarlo</string>
|
||||
<string name="errorScanItem">Error al escanea el artículo. Inténtalo de nuevo</string>
|
||||
<string name="errorSignActivity">Vuelve a pulsar para intentar firmar</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -852,5 +852,8 @@
|
|||
<string name="errorGetData">Fallo al intentar obtener datos. Avise a Informática</string>
|
||||
<string name="errorSector">No tienes sector seleccionado. Ve a pantalla ajustes y selecciona uno</string>
|
||||
<string name="errorBoxPicking">La expedición ya ha sido revisada. Pregunta encargado por si se ha preparado dos veces.</string>
|
||||
<string name="errorUserId">No se podido obtener tu id. Vuelve a intentarlo</string>
|
||||
<string name="errorScanItem">Error al escanea el artículo. Inténtalo de nuevo</string>
|
||||
<string name="errorSignActivity">Vuelve a pulsar para intentar firmar</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -854,5 +854,8 @@
|
|||
<string name="errorGetData">Fallo al intentar obtener datos. Avise a Informática</string>
|
||||
<string name="errorSector">No tienes sector seleccionado. Ve a pantalla ajustes y selecciona uno</string>
|
||||
<string name="errorBoxPicking">La expedición ya ha sido revisada. Pregunta encargado por si se ha preparado dos veces.</string>
|
||||
<string name="errorUserId">No se podido obtener tu id. Vuelve a intentarlo</string>
|
||||
<string name="errorScanItem">Error al escanea el artículo. Inténtalo de nuevo</string>
|
||||
<string name="errorSignActivity">Vuelve a pulsar para intentar firmar</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue