Version 9.8Beta_4897

This commit is contained in:
Sergio De la torre 2022-12-15 09:02:18 +01:00
parent 6b7b0c907a
commit 042979a8fe
12 changed files with 181 additions and 378 deletions

View File

@ -44,8 +44,8 @@
</shared> </shared>
</component> </component>
<component name="AndroidLogFilters"> <component name="AndroidLogFilters">
<option name="TOOL_WINDOW_CUSTOM_FILTER" value="verdnatura::" /> <option name="TOOL_WINDOW_CUSTOM_FILTER" value="verdnatura" />
<option name="TOOL_WINDOW_LOG_LEVEL" value="debug" /> <option name="TOOL_WINDOW_LOG_LEVEL" value="error" />
<option name="TOOL_WINDOW_CONFIGURED_FILTER" value="No Filters" /> <option name="TOOL_WINDOW_CONFIGURED_FILTER" value="No Filters" />
<option name="TOOL_WINDOW_REGEXP_FILTER" value="false" /> <option name="TOOL_WINDOW_REGEXP_FILTER" value="false" />
</component> </component>
@ -83,30 +83,19 @@
</select> </select>
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="fa688d1c-dbee-4864-9e33-4d84ef9afca8" name="Default Changelist" comment="Version 9.6Beta. TEST7"> <list default="true" id="fa688d1c-dbee-4864-9e33-4d84ef9afca8" name="Default Changelist" comment="Version 9.6Beta.Modificadas llamadas y fallo en checkItemScan">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/GetItemCardUserCase.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/GetItemCardUserCase.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/GetInventaryUserCase.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/GetInventaryUserCase.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/GetPaletizadoresUserCase.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/GetPaletizadoresUserCase.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/GetSacadorControladorUserCase.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/GetSacadorControladorUserCase.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/GetVehicleControlTimeUserCase.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/GetVehicleControlTimeUserCase.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragment.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/claim/fragment/ClaimViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/claim/fragment/ClaimViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapter.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapter.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoFragment.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/diadeventa/fragment/DayOfSaleViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/historicoarticulo/fragment/HistoricoArticuloViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/historicoarticulo/fragment/HistoricoArticuloViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/fragment/ItemShelvingLogViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelving/fragment/ItemShelvingLogViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/fragment/shelvingLogViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/fragment/shelvingLogViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/historicovehiculo/fragment/HistoricoVehiculoViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/historicovehiculo/fragment/HistoricoVehiculoViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/showticket/ShowTicketViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/showticket/ShowTicketViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemViewModel.kt" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -425,6 +414,13 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1618825571576</updated> <updated>1618825571576</updated>
</task> </task>
<task id="LOCAL-00056" summary="Version 8.2 Subida de ficheros que no estaban versionados">
<created>1651648467597</created>
<option name="number" value="00056" />
<option name="presentableId" value="LOCAL-00056" />
<option name="project" value="LOCAL" />
<updated>1651648467597</updated>
</task>
<task id="LOCAL-00057" summary="Version 8.3 Diseño grafico, llamadas a Salix y return &quot;Finish&quot;"> <task id="LOCAL-00057" summary="Version 8.3 Diseño grafico, llamadas a Salix y return &quot;Finish&quot;">
<created>1652788345754</created> <created>1652788345754</created>
<option name="number" value="00057" /> <option name="number" value="00057" />
@ -761,14 +757,7 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1670915898013</updated> <updated>1670915898013</updated>
</task> </task>
<task id="LOCAL-00105" summary="Version 9.6Beta. TEST7"> <option name="localTasksCounter" value="105" />
<created>1670944142191</created>
<option name="number" value="00105" />
<option name="presentableId" value="LOCAL-00105" />
<option name="project" value="LOCAL" />
<updated>1670944142191</updated>
</task>
<option name="localTasksCounter" value="106" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.History.Properties"> <component name="Vcs.Log.History.Properties">
@ -870,6 +859,7 @@
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" /> <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="Version 9.2Beta-Controlador sin animacion y vuelve al sitio" />
<MESSAGE value="Version 9 Arreglado vuelta atrás controlador" /> <MESSAGE value="Version 9 Arreglado vuelta atrás controlador" />
<MESSAGE value="Version 9.2.1 Refactor Inicio" /> <MESSAGE value="Version 9.2.1 Refactor Inicio" />
<MESSAGE value="Version 9.2.1 Refactor Inicio, pintar a través del rgb, modificado diseño,se añade shelvingLog y muestra colección a través de ticket" /> <MESSAGE value="Version 9.2.1 Refactor Inicio, pintar a través del rgb, modificado diseño,se añade shelvingLog y muestra colección a través de ticket" />
@ -894,32 +884,11 @@
<MESSAGE value="Version 9.6Beta. TEST6-final: Modificando llamadas con clase" /> <MESSAGE value="Version 9.6Beta. TEST6-final: Modificando llamadas con clase" />
<MESSAGE value="Version 9.6Beta. TEST6-final: Modificando llamadas a SilexCallback (AjustesFragment)" /> <MESSAGE value="Version 9.6Beta. TEST6-final: Modificando llamadas a SilexCallback (AjustesFragment)" />
<MESSAGE value="Version 9.6Beta. TEST6-13122022. Dos revisiones de ubicador." /> <MESSAGE value="Version 9.6Beta. TEST6-13122022. Dos revisiones de ubicador." />
<MESSAGE value="Version 9.6Beta. TEST7" /> <option name="LAST_COMMIT_MESSAGE" value="Version 9.6Beta. TEST6-13122022. Dos revisiones de ubicador." />
<option name="LAST_COMMIT_MESSAGE" value="Version 9.6Beta. TEST7" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
<breakpoints> <breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="kotlin-line">
<url>file://$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt</url>
<line>351</line>
<option name="timeStamp" value="10" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="kotlin-line">
<url>file://$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt</url>
<line>694</line>
<option name="timeStamp" value="13" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="kotlin-line">
<url>file://$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt</url>
<line>695</line>
<option name="timeStamp" value="14" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="kotlin-line">
<url>file://$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt</url>
<line>699</line>
<option name="timeStamp" value="15" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="kotlin-line"> <line-breakpoint enabled="true" suspend="THREAD" type="kotlin-line">
<url>file://$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/SilexCallback.kt</url> <url>file://$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/SilexCallback.kt</url>
<line>34</line> <line>34</line>

View File

@ -28,12 +28,12 @@ class GetInventaryUserCase(context: Context) : RestClient(context) {
val params: ArrayList<String> = ArrayList() val params: ArrayList<String> = ArrayList()
params.add(warehouseFk) params.add(warehouseFk)
return restClient!!.faultsReview( return restClient!!.faultsReview(
"json", /* "json",
"1", "1",
usuario, usuario,
password, password,
"application/json", "application/json",
params = params params = params*/
) )
} }
@ -47,12 +47,12 @@ class GetInventaryUserCase(context: Context) : RestClient(context) {
params.add(itemFk) params.add(itemFk)
params.add(warehouseFk) params.add(warehouseFk)
return restClient!!.faultsReview_isChecked( return restClient!!.faultsReview_isChecked(
"json", /* "json",
"1", "1",
usuario, usuario,
password, password,
"application/json", "application/json",
params = params params = params*/
) )
} }

View File

@ -579,23 +579,14 @@ interface VerdnaturaService {
@POST("almacennew/faultsReview")//REVISADA @POST("almacennew/faultsReview")//REVISADA
fun faultsReview( fun faultsReview(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String, @Body vararg params: Any
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
): ):
Call<List<ItemFaltasVO>> Call<List<ItemFaltasVO>>
@POST("almacennew/faultsReview_isChecked")//REVISADA @POST("almacennew/faultsReview_isChecked")//REVISADA
fun faultsReview_isChecked( fun faultsReview_isChecked(
@Header("aplicacion") aplicacion: String, @Body vararg params: Any
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
): ):
Call<Any> Call<Any>
@ -681,8 +672,7 @@ interface VerdnaturaService {
@POST("almacennew/itemShelvingMake_multi")//REVISADA @POST("almacennew/itemShelvingMake_multi")//REVISADA
fun itemShelvingMake_multi( fun itemShelvingMake_multi(
@Body vararg params: Any
@Body params: List<Any>
): ):
Call<Any> Call<Any>

View File

@ -59,11 +59,10 @@ class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) {
} else { } else {
_responseinsert.value = ResponseItemVO( _responseinsert.value = ResponseItemVO(
isError = true, isError = false,
errorMessage = getMessageFromAllResponse( errorMessage = getMessageFromAllResponse(
nameofFunction(this), nameofFunction(this),response.message()),
response.message() response=response.body().toString()
)
) )
} }

View File

@ -4,7 +4,7 @@ import android.content.Context
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetDayOfSaleUSerCase import es.verdnatura.domain.SilexCallback
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.base.nameofFunction
@ -13,14 +13,9 @@ import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDateList import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDateList
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
import timber.log.Timber.i
class DayOfSaleViewModel(context: Context) : BaseViewModel(context) {
private val GetDayOfSaleUSerCase: GetDayOfSaleUSerCase =
GetDayOfSaleUSerCase(context)
class DayOfSaleViewModel(val context: Context) : BaseViewModel(context) {
private val _response by lazy { MutableLiveData<ResponseItemVO>() } private val _response by lazy { MutableLiveData<ResponseItemVO>() }
val response: LiveData<ResponseItemVO> val response: LiveData<ResponseItemVO>
@ -35,8 +30,8 @@ class DayOfSaleViewModel(context: Context) : BaseViewModel(context) {
fun itemShelving_getSaleDate(vShelvingFK: String) { fun itemShelving_getSaleDate(vShelvingFK: String) {
silex.itemShelving_getSaleDate(vShelvingFK).enqueue(object : silex.itemShelving_getSaleDate(vShelvingFK).enqueue(object :
Callback<List<ItemShelvingSaleDate>> { SilexCallback<List<ItemShelvingSaleDate>>(context) {
override fun onFailure(call: Call<List<ItemShelvingSaleDate>>, t: Throwable) { override fun onError(t: Throwable) {
val listError: ArrayList<ItemShelvingSaleDate> = ArrayList() val listError: ArrayList<ItemShelvingSaleDate> = ArrayList()
listError.add( listError.add(
ItemShelvingSaleDate( ItemShelvingSaleDate(
@ -47,25 +42,17 @@ class DayOfSaleViewModel(context: Context) : BaseViewModel(context) {
_itemShelvingSaleDateList.value = ItemShelvingSaleDateList(listError) _itemShelvingSaleDateList.value = ItemShelvingSaleDateList(listError)
} }
override fun onResponse( override fun onSuccess(response: Response<List<ItemShelvingSaleDate>>) {
call: Call<List<ItemShelvingSaleDate>>,
response: Response<List<ItemShelvingSaleDate>>
) {
if (!response.isSuccessful) {
}
if (response.body() != null) { if (response.body() != null) {
_itemShelvingSaleDateList.value = response.body()?.let { _itemShelvingSaleDateList.value = response.body()?.let {
ItemShelvingSaleDateList(it) ItemShelvingSaleDateList(it)
} }
i("finalizada la lista ${response.body()}")
} else { } else {
if (!response.isSuccessful) { if (!response.isSuccessful) {
val listError: ArrayList<ItemShelvingSaleDate> = ArrayList() val listError: ArrayList<ItemShelvingSaleDate> = ArrayList()
listError.add( listError.add(
ItemShelvingSaleDate( ItemShelvingSaleDate(
@ -84,23 +71,21 @@ class DayOfSaleViewModel(context: Context) : BaseViewModel(context) {
}) })
} }
/* fun getListFromJSON(json: JsonObject): MutableList<itemsExpeditionDynamics> { /* fun getListFromJSON(json: JsonObject): MutableList<itemsExpeditionDynamics> {
val gson = Gson() val gson = Gson()
var list = mutableListOf<itemsExpeditionDynamics>() var list = mutableListOf<itemsExpeditionDynamics>()
var expeditionState: Map<String, Any> = gson.fromJson(json, object : TypeToken<Map<String, Any>>() {}.type) var expeditionState: Map<String, Any> = gson.fromJson(json, object : TypeToken<Map<String, Any>>() {}.type)
expeditionState.forEach { expeditionState.forEach {
list.add(itemsExpeditionDynamics(key=it.key,value=it.value.toString())) list.add(itemsExpeditionDynamics(key=it.key,value=it.value.toString()))
} }
return list return list
}*/ }*/
fun parking(scanItem: String, parking: String) { fun parking(scanItem: String, parking: String) {
GetDayOfSaleUSerCase.shelvingPark(scanItem, parking).enqueue(object : silex.shelvingPark(scanItem, parking).enqueue(object :
Callback<Any> { SilexCallback<Any>(context) {
override fun onFailure(call: Call<Any>, t: Throwable) { override fun onError(t: Throwable) {
_response.value = ResponseItemVO( _response.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
@ -108,21 +93,7 @@ class DayOfSaleViewModel(context: Context) : BaseViewModel(context) {
} }
override fun onResponse(call: Call<Any>, response: Response<Any>) { override fun onResponse(call: Call<Any>, response: Response<Any>) {
/*
if (response.isSuccessful == null){
_response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message()))
}else{*/
if (response.isSuccessful)
_response.value = ResponseItemVO(isError = false, response = response.message()) _response.value = ResponseItemVO(isError = false, response = response.message())
else
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
} }
}) })

View File

@ -3,8 +3,7 @@ package es.verdnatura.presentation.view.feature.faltas.fragment
import android.content.Context import android.content.Context
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetInventaryUserCase import es.verdnatura.domain.SilexCallback
import es.verdnatura.domain.GetItemCardUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.base.nameofFunction
@ -12,15 +11,9 @@ import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasListVO import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasListVO
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
class FaltasViewModel(context: Context) : BaseViewModel(context) { class FaltasViewModel(val context: Context) : BaseViewModel(context) {
private val getInventaryUserCase: GetInventaryUserCase = GetInventaryUserCase(context)
private val getItemCardUserCase: GetItemCardUserCase = GetItemCardUserCase(context)
private val _faltasList by lazy { MutableLiveData<ItemFaltasListVO>() } private val _faltasList by lazy { MutableLiveData<ItemFaltasListVO>() }
val faltasList: LiveData<ItemFaltasListVO> val faltasList: LiveData<ItemFaltasListVO>
@ -35,9 +28,9 @@ class FaltasViewModel(context: Context) : BaseViewModel(context) {
fun getFaltas(user: String, password: String, warehouseFk: String) { fun getFaltas(user: String, password: String, warehouseFk: String) {
getInventaryUserCase.faultsReview(user, password, warehouseFk).enqueue(object : silex.faultsReview(user, password, warehouseFk).enqueue(object :
Callback<List<ItemFaltasVO>> { SilexCallback<List<ItemFaltasVO>>(context) {
override fun onFailure(call: Call<List<ItemFaltasVO>>, t: Throwable) { override fun onError(t: Throwable) {
val listError: ArrayList<ItemFaltasVO> = ArrayList() val listError: ArrayList<ItemFaltasVO> = ArrayList()
listError.add( listError.add(
ItemFaltasVO( ItemFaltasVO(
@ -48,10 +41,7 @@ class FaltasViewModel(context: Context) : BaseViewModel(context) {
_faltasList.value = ItemFaltasListVO(listError) _faltasList.value = ItemFaltasListVO(listError)
} }
override fun onResponse( override fun onSuccess(response: Response<List<ItemFaltasVO>>) {
call: Call<List<ItemFaltasVO>>,
response: Response<List<ItemFaltasVO>>
) {
if (response.body() != null) { if (response.body() != null) {
_faltasList.value = response.body()?.let { ItemFaltasListVO(it) } _faltasList.value = response.body()?.let { ItemFaltasListVO(it) }
} else { } else {
@ -78,10 +68,10 @@ class FaltasViewModel(context: Context) : BaseViewModel(context) {
newValue: String, newValue: String,
isTrash: String isTrash: String
) { ) {
getItemCardUserCase.itemStockUpdate( itemFk, warehouseFk, newValue, isTrash) silex.itemTrash(itemFk, warehouseFk, newValue, isTrash)
.enqueue(object : .enqueue(object :
Callback<Any> { SilexCallback<Any>(context) {
override fun onFailure(call: Call<Any>, t: Throwable) { override fun onError(t: Throwable) {
_response.value = ResponseItemVO( _response.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
@ -113,29 +103,21 @@ class FaltasViewModel(context: Context) : BaseViewModel(context) {
itemFk: String, itemFk: String,
warehouseFk: String warehouseFk: String
) { ) {
getInventaryUserCase.faultsReview_isChecked(user, password, itemFk, warehouseFk) silex.faultsReview_isChecked(user, password, itemFk, warehouseFk)
.enqueue(object : .enqueue(object :
Callback<Any> { SilexCallback<Any>(context) {
override fun onFailure(call: Call<Any>, t: Throwable) { override fun onError(t: Throwable) {
_response.value = ResponseItemVO( _response.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
) )
} }
override fun onResponse(call: Call<Any>, response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
if (!response.isSuccessful) {
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
} else {
_response.value = _response.value =
ResponseItemVO(isError = false, response = response.message()) ResponseItemVO(isError = false, response = response.message())
}
} }
}) })

View File

@ -4,21 +4,16 @@ import android.content.Context
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetItemCardUserCase import es.verdnatura.domain.SilexCallback
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoListVO import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoListVO
import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoVO import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoVO
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
class HistoricoArticuloViewModel(context: Context) : BaseViewModel(context) { class HistoricoArticuloViewModel(val context: Context) : BaseViewModel(context) {
private val getItemCardUserCase: GetItemCardUserCase = GetItemCardUserCase(context)
private val _historicoList by lazy { MutableLiveData<ItemHistoricoListVO>() } private val _historicoList by lazy { MutableLiveData<ItemHistoricoListVO>() }
val historicoList: LiveData<ItemHistoricoListVO> val historicoList: LiveData<ItemHistoricoListVO>
@ -30,22 +25,32 @@ class HistoricoArticuloViewModel(context: Context) : BaseViewModel(context) {
fun itemDiary(itemFk: Int, vWarehouseFk: Int) { fun itemDiary(itemFk: Int, vWarehouseFk: Int) {
silex.itemDiary(itemFk, vWarehouseFk).enqueue(object : silex.itemDiary(itemFk, vWarehouseFk).enqueue(object :
Callback<List<ItemHistoricoVO>> { SilexCallback<List<ItemHistoricoVO>>(context) {
override fun onFailure(call: Call<List<ItemHistoricoVO>>, t: Throwable) { override fun onError(t: Throwable) {
val listError: ArrayList<ItemHistoricoVO> = ArrayList() val listError: ArrayList<ItemHistoricoVO> = ArrayList()
listError.add(ItemHistoricoVO(isError = true,errorMessage =getMessageFromAllResponse(nameofFunction(this),t.message!!))) listError.add(
ItemHistoricoVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
)
_historicoList.value = ItemHistoricoListVO(listError) _historicoList.value = ItemHistoricoListVO(listError)
} }
override fun onResponse( override fun onSuccess(response: Response<List<ItemHistoricoVO>>) {
call: Call<List<ItemHistoricoVO>>,
response: Response<List<ItemHistoricoVO>>
) {
if (response.body() != null) { if (response.body() != null) {
_historicoList.value = response.body()?.let { ItemHistoricoListVO(it) } _historicoList.value = response.body()?.let { ItemHistoricoListVO(it) }
} else { } else {
val listError: ArrayList<ItemHistoricoVO> = ArrayList() val listError: ArrayList<ItemHistoricoVO> = ArrayList()
listError.add(ItemHistoricoVO(isError = true,errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message()))) listError.add(
ItemHistoricoVO(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
)
_historicoList.value = ItemHistoricoListVO(listError) _historicoList.value = ItemHistoricoListVO(listError)
} }
} }

View File

@ -2,29 +2,18 @@ package es.verdnatura.presentation.view.feature.historicoshelving.fragment
import android.content.Context import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.itemShelvingLogUSerCase import es.verdnatura.domain.SilexCallback
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDateList
import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLogList
import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLog import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLog
import retrofit2.Call import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLogList
import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
import timber.log.Timber.i
class itemShelvingLogViewModel(context: Context) : BaseViewModel(context) {
private val itemShelvingLogUSerCase: itemShelvingLogUSerCase =
itemShelvingLogUSerCase(context)
class itemShelvingLogViewModel(val context: Context) : BaseViewModel(context) {
private val _itemShelvingLogList by lazy { MutableLiveData<ItemShelvingLogList>() } private val _itemShelvingLogList by lazy { MutableLiveData<ItemShelvingLogList>() }
@ -32,37 +21,27 @@ class itemShelvingLogViewModel(context: Context) : BaseViewModel(context) {
val loadItemShelvingLogList = Transformations.map(_itemShelvingLogList) { Event(it) } val loadItemShelvingLogList = Transformations.map(_itemShelvingLogList) { Event(it) }
fun itemShelvingLog_get(vShelvingFK: String) { fun itemShelvingLog_get(vShelvingFK: String) {
silex.itemShelvingLog_get(vShelvingFK).enqueue(object : silex.itemShelvingLog_get(vShelvingFK).enqueue(object :
Callback<List<ItemShelvingLog>> { SilexCallback<List<ItemShelvingLog>>(context) {
override fun onFailure(call: Call<List<ItemShelvingLog>>, t: Throwable) { override fun onError(t: Throwable) {
val listError: ArrayList<ItemShelvingLog> = ArrayList() val listError: ArrayList<ItemShelvingLog> = ArrayList()
listError.add(ItemShelvingLog(isError = true,errorMessage = getMessageFromAllResponse(nameofFunction(this),t.message!!))) listError.add(
ItemShelvingLog(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
)
_itemShelvingLogList.value = ItemShelvingLogList(listError) _itemShelvingLogList.value = ItemShelvingLogList(listError)
} }
override fun onResponse( override fun onSuccess(response: Response<List<ItemShelvingLog>>) {
call: Call<List<ItemShelvingLog>>,
response: Response<List<ItemShelvingLog>>
) {
if (!response.isSuccessful){ if (response.body() != null) {
val listError:ArrayList<ItemShelvingLog> = ArrayList()
listError.add(ItemShelvingLog(isError = true,errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())))
_itemShelvingLogList.value = ItemShelvingLogList(listError)
}else{
if (response.body() != null)
{
i("crea la lista %s", response.body())
_itemShelvingLogList.value = response.body()?.let { _itemShelvingLogList.value = response.body()?.let {
ItemShelvingLogList(it) ItemShelvingLogList(it)
} }
}
} }
} }
@ -71,7 +50,6 @@ class itemShelvingLogViewModel(context: Context) : BaseViewModel(context) {
} }
} }

View File

@ -4,83 +4,26 @@ package es.verdnatura.presentation.view.feature.historicoshelvinglog.fragment
import android.content.Context import android.content.Context
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.SilexCallback
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalix import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalix
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalixList import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalixList
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
class shelvingLogViewModel(context: Context) : BaseViewModel(context) { class shelvingLogViewModel(val context: Context) : BaseViewModel(context) {
/* private val itemShelvingLogUSerCase: itemShelvingLogUSerCase =
itemShelvingLogUSerCase(context)*/
/*private val _itemShelvingLogList by lazy { MutableLiveData<ShelvingLogList>() }
val loadShelvingLogList = Transformations.map(_itemShelvingLogList) { Event(it) }*/
private val _itemShelvingLogSalixList by lazy { MutableLiveData<ShelvingLogSalixList>() } private val _itemShelvingLogSalixList by lazy { MutableLiveData<ShelvingLogSalixList>() }
val loadShelvingLogSalixList = Transformations.map(_itemShelvingLogSalixList) { Event(it) } val loadShelvingLogSalixList = Transformations.map(_itemShelvingLogSalixList) { Event(it) }
/* private val _shelvingResponse by lazy { MutableLiveData<ShelvingLogSalix>() }
val shelvingResponse: LiveData<ShelvingLogSalix>
get() = _shelvingResponse*/
/*fun shelvingLog_get(usuario: String, password: String, vShelvingFK: String) {
itemShelvingLogUSerCase.shelvingLog_get(usuario, password, vShelvingFK).enqueue(object :
Callback<List<ShelvingLog>> {
override fun onFailure(call: Call<List<ShelvingLog>>, t: Throwable) {
val listError: ArrayList<ShelvingLog> = ArrayList()
listError.add(
ShelvingLog(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
)
_itemShelvingLogList.value = ShelvingLogList(listError)
}
override fun onResponse(
call: Call<List<ShelvingLog>>,
response: Response<List<ShelvingLog>>
) {
if (!response.isSuccessful) {
val listError: ArrayList<ShelvingLog> = ArrayList()
listError.add(
ShelvingLog(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
)
_itemShelvingLogList.value = ShelvingLogList(listError)
} else {
if (response.body() != null) {
_itemShelvingLogList.value = response.body()?.let {
ShelvingLogList(it)
}
}
}
}
})
}*/
fun Shelvings(vShelvingFK: String) { fun Shelvings(vShelvingFK: String) {
salix.Shelvings(vShelvingFK).enqueue(object : salix.Shelvings(vShelvingFK).enqueue(object :
Callback<List<ShelvingLogSalix>> { SilexCallback<List<ShelvingLogSalix>>(context) {
override fun onFailure(call: Call<List<ShelvingLogSalix>>, t: Throwable) { override fun onError(t: Throwable) {
val listError: ArrayList<ShelvingLogSalix> = ArrayList() val listError: ArrayList<ShelvingLogSalix> = ArrayList()
listError.add( listError.add(
ShelvingLogSalix( ShelvingLogSalix(
@ -91,33 +34,24 @@ class shelvingLogViewModel(context: Context) : BaseViewModel(context) {
_itemShelvingLogSalixList.value = ShelvingLogSalixList(listError) _itemShelvingLogSalixList.value = ShelvingLogSalixList(listError)
} }
override fun onResponse( override fun onSuccess(response: Response<List<ShelvingLogSalix>>) {
call: Call<List<ShelvingLogSalix>>,
response: Response<List<ShelvingLogSalix>>
) {
if (!response.isSuccessful) {
val listError: ArrayList<ShelvingLogSalix> = ArrayList()
listError.add(
ShelvingLogSalix(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
)
_itemShelvingLogSalixList.value = ShelvingLogSalixList(listError)
} else {
if (response.body() != null) { if (response.body() != null) {
_itemShelvingLogSalixList.value = response.body()?.let { _itemShelvingLogSalixList.value = response.body()?.let {
ShelvingLogSalixList(it) ShelvingLogSalixList(it)
} }
} else {
val listError: ArrayList<ShelvingLogSalix> = ArrayList()
} listError.add(
ShelvingLogSalix(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
)
_itemShelvingLogSalixList.value = ShelvingLogSalixList(listError)
} }

View File

@ -3,50 +3,49 @@ package es.verdnatura.presentation.view.feature.historicovehiculo.fragment
import android.content.Context import android.content.Context
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetVehicleControlTimeUserCase import es.verdnatura.domain.SilexCallback
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculoList import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculoList
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
import timber.log.Timber.d
import timber.log.Timber.i
class HistoricoVehiculoViewModel (context: Context) : BaseViewModel(context) {
private val GetVehicleControlTimeUserCase: GetVehicleControlTimeUserCase = GetVehicleControlTimeUserCase(context)
class HistoricoVehiculoViewModel(var context: Context) : BaseViewModel(context) {
private val _historicovehiculoList by lazy { MutableLiveData<ItemHistoricoVehiculoList>() } private val _historicovehiculoList by lazy { MutableLiveData<ItemHistoricoVehiculoList>() }
val loadHistoricoVehiculoList = Transformations.map(_historicovehiculoList) { Event(it) } val loadHistoricoVehiculoList = Transformations.map(_historicovehiculoList) { Event(it) }
fun machineWorker_getHistorical(plateNumber: String) { fun machineWorker_getHistorical(plateNumber: String) {
silex.machineWorker_getHistorical(plateNumber).enqueue(object : silex.machineWorker_getHistorical(plateNumber).enqueue(object :
Callback<List<ItemHistoricoVehiculo>> { SilexCallback<List<ItemHistoricoVehiculo>>(context) {
override fun onFailure(call: Call<List<ItemHistoricoVehiculo>>, t: Throwable) { override fun onError(t: Throwable) {
val listError: ArrayList<ItemHistoricoVehiculo> = ArrayList() val listError: ArrayList<ItemHistoricoVehiculo> = ArrayList()
listError.add(ItemHistoricoVehiculo(isError = true,errorMessage =getMessageFromAllResponse(nameofFunction(this),t.message!!))) listError.add(
ItemHistoricoVehiculo(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
)
_historicovehiculoList.value = ItemHistoricoVehiculoList(listError) _historicovehiculoList.value = ItemHistoricoVehiculoList(listError)
} }
override fun onResponse( override fun onSuccess(response: Response<List<ItemHistoricoVehiculo>>) {
call: Call<List<ItemHistoricoVehiculo>>,
response: Response<List<ItemHistoricoVehiculo>>
) {
if (response.body() != null) { if (response.body() != null) {
_historicovehiculoList.value =
_historicovehiculoList.value = response.body()?.let { ItemHistoricoVehiculoList(it) } response.body()?.let { ItemHistoricoVehiculoList(it) }
} else { } else {
val listError: ArrayList<ItemHistoricoVehiculo> = ArrayList() val listError: ArrayList<ItemHistoricoVehiculo> = ArrayList()
listError.add(ItemHistoricoVehiculo(isError = true,errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message()))) listError.add(
ItemHistoricoVehiculo(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
)
_historicovehiculoList.value = ItemHistoricoVehiculoList(listError) _historicovehiculoList.value = ItemHistoricoVehiculoList(listError)
} }

View File

@ -3,44 +3,43 @@ package es.verdnatura.presentation.view.feature.precontrol
import android.content.Context import android.content.Context
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.SilexCallback
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.domain.GetPreControladorUserCase
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.collection.mapper.map import es.verdnatura.presentation.view.feature.collection.mapper.map
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
class ShowTicketViewModel(context: Context) : BaseViewModel(context) { class ShowTicketViewModel(val context: Context) : BaseViewModel(context) {
private val contextApp=context
private val getPreControladorUserCase: GetPreControladorUserCase = GetPreControladorUserCase(context)
private val _collectionTicketList by lazy { MutableLiveData<CollectionVO>() } private val _collectionTicketList by lazy { MutableLiveData<CollectionVO>() }
val collectionTicketList: LiveData<CollectionVO> val collectionTicketList: LiveData<CollectionVO>
get() = _collectionTicketList get() = _collectionTicketList
private val _responseTicket by lazy { MutableLiveData<ResponseItemVO>() }
val responseTicket: LiveData<ResponseItemVO>
get() = _responseTicket
fun collectionTicketGet(collectionFk: Int, sectorFk: Int, print: String, type: String) { fun collectionTicketGet(collectionFk: Int, sectorFk: Int, print: String, type: String) {
silex.collection_getTickets(collectionFk, sectorFk, print, type).enqueue(object : silex.collection_getTickets(collectionFk, sectorFk, print, type).enqueue(object :
Callback<CollectionVO> { SilexCallback<CollectionVO>(context) {
override fun onFailure(call: Call<CollectionVO>, t: Throwable) { override fun onError(t: Throwable) {
_collectionTicketList.value = CollectionVO(0,isError = true,errorMessage =getMessageFromAllResponse(nameofFunction(this),t.message!!)) _collectionTicketList.value = CollectionVO(
0,
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
} }
override fun onResponse(
call: Call<CollectionVO>, override fun onSuccess(response: Response<CollectionVO>) {
response: Response<CollectionVO>
) {
if (response.body() != null) { if (response.body() != null) {
_collectionTicketList.value = response.body()?.let { it.map(contextApp) } _collectionTicketList.value = response.body()?.let { it.map(context) }
} else { } else {
_collectionTicketList.value = CollectionVO(0,isError = true,errorMessage = getMessageFromAllResponse(nameofFunction(this),response.message())) _collectionTicketList.value = CollectionVO(
0,
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
} }
} }
}) })

View File

@ -3,19 +3,15 @@ package es.verdnatura.presentation.view.feature.ubicador.fragment
import android.content.Context import android.content.Context
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetUbicadorUserCase import es.verdnatura.domain.SilexCallback
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
class AutomaticAddItemViewModel(context: Context) : BaseViewModel(context) { class AutomaticAddItemViewModel(val context: Context) : BaseViewModel(context) {
private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context)
private val _response by lazy { MutableLiveData<ResponseItemVO>() } private val _response by lazy { MutableLiveData<ResponseItemVO>() }
val response: LiveData<ResponseItemVO> val response: LiveData<ResponseItemVO>
get() = _response get() = _response
@ -26,10 +22,10 @@ class AutomaticAddItemViewModel(context: Context) : BaseViewModel(context) {
items: List<Int>, items: List<Int>,
warehouse: Int warehouse: Int
) { ) {
getUbicadorUserCase.itemShelvingMake_multi(shelving, items, warehouse) silex.itemShelvingMake_multi(shelving, items, warehouse)
.enqueue(object : .enqueue(object :
Callback<Any> { SilexCallback<Any>(context) {
override fun onFailure(call: Call<Any>, t: Throwable) { override fun onError(t: Throwable) {
_response.value = ResponseItemVO( _response.value = ResponseItemVO(
isError = true, errorMessage = getMessageFromAllResponse( isError = true, errorMessage = getMessageFromAllResponse(
nameofFunction(this), t.message!! nameofFunction(this), t.message!!
@ -37,19 +33,10 @@ class AutomaticAddItemViewModel(context: Context) : BaseViewModel(context) {
) )
} }
override fun onResponse(call: Call<Any>, response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
if (!response.isSuccessful) {
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()!!
)
)
} else {
_response.value = _response.value =
ResponseItemVO(isError = false, response = response.message()!!) ResponseItemVO(isError = false, response = response.message()!!)
}
} }
}) })
@ -67,8 +54,8 @@ class AutomaticAddItemViewModel(context: Context) : BaseViewModel(context) {
isChecking, isChecking,
warehouse warehouse
).enqueue(object : ).enqueue(object :
Callback<Any> { SilexCallback<Any>(context) {
override fun onFailure(call: Call<Any>, t: Throwable) { override fun onError(t: Throwable) {
_response.value = ResponseItemVO( _response.value = ResponseItemVO(
isError = true, errorMessage = getMessageFromAllResponse( isError = true, errorMessage = getMessageFromAllResponse(
nameofFunction(this), t.message!! nameofFunction(this), t.message!!
@ -76,19 +63,9 @@ class AutomaticAddItemViewModel(context: Context) : BaseViewModel(context) {
) )
} }
override fun onResponse(call: Call<Any>, response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
if (!response.isSuccessful) {
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()!!
)
)
} else {
_response.value = _response.value =
ResponseItemVO(isError = false, response = response.message()!!) ResponseItemVO(isError = false, response = response.message()!!)
}
} }
}) })