diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/contab_doc_interni/DocInterniViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/contab_doc_interni/DocInterniViewModel.java index f686a216..a5e44b2f 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/contab_doc_interni/DocInterniViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/contab_doc_interni/DocInterniViewModel.java @@ -37,12 +37,12 @@ public class DocInterniViewModel { private List availableArts; private MutableLiveData> mDocsList = new MutableLiveData<>(); - public final MutableLiveData dtbTipi = new MutableLiveData<>(); - public final MutableLiveData mtbGrup = new MutableLiveData<>(); - public final MutableLiveData fornitore = new MutableLiveData<>(); - public final MutableLiveData dataDoc = new MutableLiveData<>(); - public final MutableLiveData numDoc = new MutableLiveData<>(); - public final MutableLiveData note = new MutableLiveData<>(); + public TipoDocDTO dtbTipi; + public GruppoArticoloDTO mtbGrup; + public FornitoreDTO fornitore; + public Date dataDoc; + public String numDoc; + public String note; public final BindableInteger artsSize = new BindableInteger(0); @Inject @@ -86,13 +86,13 @@ public class DocInterniViewModel { } public void setSelectedDocDetails(DialogSelectDocInfoResponseDTO selection) { - this.fornitore.postValue(selection.getFornitore()); - this.dtbTipi.postValue(selection.getTipoDoc()); + this.fornitore = selection.getFornitore(); + this.dtbTipi = selection.getTipoDoc(); - this.mtbGrup.postValue(selection.getGruppoArt()); - this.dataDoc.postValue(selection.getDataDoc()); - this.numDoc.postValue(selection.getNumDoc() != null ? selection.getNumDoc().toString() : null); - this.note.postValue(selection.getNote()); + this.mtbGrup = selection.getGruppoArt(); + this.dataDoc = selection.getDataDoc(); + this.numDoc = selection.getNumDoc() != null ? selection.getNumDoc().toString() : null; + this.note = selection.getNote(); this.sendOnLoadingStarted(); fetchProducts(() -> { @@ -118,7 +118,7 @@ public class DocInterniViewModel { String codAnag = null; String codVdes = null; - FornitoreDTO fornitore = this.fornitore.getValue(); + FornitoreDTO fornitore = this.fornitore; if (fornitore != null) { codAnag = fornitore.getCodAnag(); codVdes = fornitore.getCodVdes(); @@ -126,7 +126,7 @@ public class DocInterniViewModel { var docsList = documentRepository.getDocuments(this.getCodDtip(), - codAnag, codVdes, dataDoc.getValue(), numDoc.getValue()); + codAnag, codVdes, dataDoc, numDoc); docsList.observeForever(data -> { this.mDocsList.postValue(data); @@ -145,31 +145,28 @@ public class DocInterniViewModel { } private String getCodDtip() { - if (this.dtbTipi.getValue() == null) { + if (this.dtbTipi == null) { return null; } - return this.dtbTipi.getValue().getCodDtip(); + return this.dtbTipi.getCodDtip(); } public TipoDocDTO getTipoDoc() { - if (this.dtbTipi.getValue() == null) { - return null; - } - return this.dtbTipi.getValue(); + return this.dtbTipi; } private String getCodMgrp() { - if (this.mtbGrup.getValue() == null) { + if (this.mtbGrup == null) { return null; } - return this.mtbGrup.getValue().getCodMgrp(); + return this.mtbGrup.getCodMgrp(); } private String getCodAnagForn() { - if (this.fornitore.getValue() == null) { + if (this.fornitore == null) { return null; } - return this.fornitore.getValue().getCodAnag(); + return this.fornitore.getCodAnag(); } public void editDocument(SqlMtbColt document) { @@ -178,7 +175,7 @@ public class DocInterniViewModel { public void newDocument() { SqlMtbColt document = new SqlMtbColt(); - if (this.dtbTipi.getValue() == null) { + if (this.dtbTipi == null) { this.sendError(new NoDocTypeSelectedException()); return; } @@ -186,18 +183,18 @@ public class DocInterniViewModel { document.setCodMgrp(this.getCodMgrp()); document.setDataCollo(new Date()); document.setCodMdep(SettingsManager.i().getUserSession().getDepo().getCodMdep()); - document.setAnnotazioni(this.note.getValue()); + document.setAnnotazioni(this.note); document.setSegno(-1); document.setSerCollo("/"); document.setNumCollo(this.nextNumCollo); document.setGestione("L"); - document.setDataDoc(this.dataDoc.getValue()); - if (this.numDoc.getValue() != null) { - document.setNumDoc(Integer.parseInt(this.numDoc.getValue())); + document.setDataDoc(this.dataDoc); + if (this.numDoc != null) { + document.setNumDoc(Integer.parseInt(this.numDoc)); } - if (this.fornitore.getValue() != null) { - document.setCodAnag(this.fornitore.getValue().getCodAnag()); - document.setCodVdes(this.fornitore.getValue().getCodVdes()); + if (this.fornitore != null) { + document.setCodAnag(this.fornitore.getCodAnag()); + document.setCodVdes(this.fornitore.getCodVdes()); } documentRepository.insert(document, id -> { document.setId(id); @@ -206,7 +203,7 @@ public class DocInterniViewModel { } public boolean hasDocDetails() { - return this.dtbTipi.getValue() != null; + return this.dtbTipi != null; } public interface Listener extends ILoadingListener {