diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumer.java index d869846f..7e3927f3 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumer.java @@ -16,6 +16,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; import javax.inject.Singleton; @@ -311,15 +313,47 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { }); } + public void fillMtbAartsOfMtbColrs(List mtbColrs, RunnableArgs> onComplete, RunnableArgs onFailed) { + + List codMarts = new ArrayList<>(mtbColrs.stream() + .map(MtbColr::getCodMart) + .filter(Objects::nonNull) + .distinct() + .collect(Collectors.toUnmodifiableList())); + + mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> { + + if (arts != null && !arts.isEmpty()) { + for (MtbColr mtbColr : mtbColrs) { + + MtbAart foundMtbAart = null; + + List mtbAartStream = arts.stream() + .filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart())) + .collect(Collectors.toList()); + + if (!mtbAartStream.isEmpty()) { + foundMtbAart = mtbAartStream.get(0); + } + + mtbColr.setMtbAart(foundMtbAart); + } + } + + onComplete.run(mtbColrs); + }, onFailed); + + } + public void fillMtbAartsOfMtbColts(List mtbColts, RunnableArgs> onComplete, RunnableArgs onFailed) { List codMarts = new ArrayList<>(); for (MtbColt mtbColt : mtbColts) { - codMarts.addAll(Stream.of(mtbColt.getMtbColr()) + codMarts.addAll(mtbColt.getMtbColr().stream() .map(MtbColr::getCodMart) - .withoutNulls() + .filter(Objects::nonNull) .distinct() - .toList()); + .collect(Collectors.toUnmodifiableList())); } @@ -331,10 +365,11 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { MtbAart foundMtbAart = null; - List mtbAartStream = Stream.of(arts) - .filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart())).toList(); + List mtbAartStream = arts.stream() + .filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart())) + .collect(Collectors.toList()); - if (mtbAartStream != null && !mtbAartStream.isEmpty()) { + if (!mtbAartStream.isEmpty()) { foundMtbAart = mtbAartStream.get(0); } @@ -560,7 +595,9 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "spostaArtsTraUL", data -> { - onComplete.run(data.getGeneratedMtbColr()); + + fillMtbAartsOfMtbColrs(data.getGeneratedMtbColr(), onComplete, onFailed); + }, onFailed); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/utility/UtilityString.java b/app/src/main/java/it/integry/integrywmsnative/core/utility/UtilityString.java index fdd64cfa..2943c7c1 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/utility/UtilityString.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/utility/UtilityString.java @@ -111,9 +111,14 @@ public class UtilityString { public static boolean isNullOrEmpty(String stringToCheck){ return stringToCheck == null || stringToCheck.trim().isEmpty(); } - - public static String isNull(String stringToCheck, String alternativeString){ - return isNullOrEmpty(stringToCheck) ? alternativeString : stringToCheck; + + public static String isNull(String... strings) { + for (String string : strings) { + if (!isNullOrEmpty(string)) { + return string; + } + } + return null; } public static String empty2null(String stringToCheck) { diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java index 0c36446b..2ac77b46 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java @@ -373,10 +373,11 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme .setPartitaMag(resultDTO.getPartitaMag()) .setDataScad(resultDTO.getDataScad()); - this.onLoadingStarted(); onComplete.run(pickedQuantityDTO, shouldCloseLU); }) - .setOnAbort(this::onLoadingEnded) + .setOnAbort(() -> { + onComplete.run(null, false); + }) .show(requireActivity().getSupportFragmentManager(), "tag"); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoModule.java b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoModule.java index ebcd498d..43ddcd44 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoModule.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoModule.java @@ -1,9 +1,12 @@ package it.integry.integrywmsnative.gest.picking_libero; +import java.util.concurrent.ExecutorService; + import javax.inject.Singleton; import dagger.Module; import dagger.Provides; +import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService; import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer; @@ -18,22 +21,27 @@ public class PickingLiberoModule { @Provides @Singleton - PickingLiberoViewModel providesPickingLiberoViewModel(ArticoloRESTConsumer articoloRESTConsumer, + PickingLiberoViewModel providesPickingLiberoViewModel(ExecutorService executorService, + ArticoloRESTConsumer articoloRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, PosizioniRESTConsumer posizioniRESTConsumer, GiacenzaRESTConsumer giacenzaRESTConsumer, MagazzinoAutomaticoRESTConsumer magazzinoAutomaticoRESTConsumer, ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer, - ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer + ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer, + ColliDataRecoverService colliDataRecoverService ) { - return new PickingLiberoViewModel(articoloRESTConsumer, + return new PickingLiberoViewModel( + executorService, + articoloRESTConsumer, colliMagazzinoRESTConsumer, barcodeRESTConsumer, posizioniRESTConsumer, giacenzaRESTConsumer, magazzinoAutomaticoRESTConsumer, colliLavorazioneRESTConsumer, - colliSpedizioneRESTConsumer); + colliSpedizioneRESTConsumer, + colliDataRecoverService); } } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java index 1c9fb4dc..0c71ad4b 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java @@ -7,12 +7,16 @@ import com.annimon.stream.Stream; import java.math.BigDecimal; import java.time.LocalDate; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; import javax.inject.Inject; import it.integry.barcode_base_android_library.model.BarcodeScanDTO; +import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService; import it.integry.integrywmsnative.core.exception.InvalidCodMdepException; import it.integry.integrywmsnative.core.exception.NoArtsFoundException; import it.integry.integrywmsnative.core.exception.NoLUFoundException; @@ -66,12 +70,14 @@ public class PickingLiberoViewModel { private MtbColt mCurrentMtbColt = null; + private final ExecutorService executorService; private final ArticoloRESTConsumer mArticoloRESTConsumer; private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer; private final BarcodeRESTConsumer mBarcodeRESTConsumer; private final PosizioniRESTConsumer mPosizioniRESTConsumer; private final GiacenzaRESTConsumer mGiacenzaRESTConsumer; private final MagazzinoAutomaticoRESTConsumer mMagazzinoAutomaticoRESTConsumer; + private final ColliDataRecoverService mColliDataRecoverService; private ColliScaricoRESTConsumerInterface mColliScaricoRESTConsumer; private final ColliLavorazioneRESTConsumer mColliLavorazioneRESTConsumer; @@ -86,17 +92,21 @@ public class PickingLiberoViewModel { private Listener mListener; + private Integer mMtbColtSessionID; @Inject - public PickingLiberoViewModel(ArticoloRESTConsumer articoloRESTConsumer, + public PickingLiberoViewModel(ExecutorService executorService, + ArticoloRESTConsumer articoloRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, PosizioniRESTConsumer posizioniRESTConsumer, GiacenzaRESTConsumer giacenzaRESTConsumer, MagazzinoAutomaticoRESTConsumer mMagazzinoAutomaticoRESTConsumer, ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer, - ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer) { + ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer, + ColliDataRecoverService colliDataRecoverService) { + this.executorService = executorService; this.mArticoloRESTConsumer = articoloRESTConsumer; this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer; this.mBarcodeRESTConsumer = barcodeRESTConsumer; @@ -105,6 +115,7 @@ public class PickingLiberoViewModel { this.mMagazzinoAutomaticoRESTConsumer = mMagazzinoAutomaticoRESTConsumer; this.mColliLavorazioneRESTConsumer = colliLavorazioneRESTConsumer; this.mColliSpedizioneRESTConsumer = colliSpedizioneRESTConsumer; + this.mColliDataRecoverService = colliDataRecoverService; } @@ -186,26 +197,38 @@ public class PickingLiberoViewModel { .map(MvwSitArtUdcDetInventario::toMtbColr) .toList(); - this.sendArtSelectionRequest(mtbColrs, null, selectedMtbColrs -> { + List selectedMtbColrs = null; + try { + selectedMtbColrs = this.sendArtSelectionRequest(mtbColrs, null); + } catch (InterruptedException e) { + this.sendError(e); + return; + } - final List magazzinoAutomaticoPickItemRequestDTOList = new ArrayList<>(); - for (MtbColr selectedArt : selectedMtbColrs) { - MagazzinoAutomaticoPickItemRequestDTO itemDto = new MagazzinoAutomaticoPickItemRequestDTO(selectedArt.getCodMart()) - .setQtaTot(selectedArt.getQtaCol()) - .setNumCnf(selectedArt.getNumCnf()) - .setUntMis(selectedArt.getUntMis()); + if (selectedMtbColrs == null) { + this.sendOnLoadingEnded(); + return; + } - magazzinoAutomaticoPickItemRequestDTOList.add(itemDto); - } + final List magazzinoAutomaticoPickItemRequestDTOList = new ArrayList<>(); + for (MtbColr selectedArt : selectedMtbColrs) { + MagazzinoAutomaticoPickItemRequestDTO itemDto = new MagazzinoAutomaticoPickItemRequestDTO(selectedArt.getCodMart()) + .setQtaTot(selectedArt.getQtaCol()) + .setNumCnf(selectedArt.getNumCnf()) + .setUntMis(selectedArt.getUntMis()); - var magazzinoAutomaticoPickRequest = new MagazzinoAutomaticoPickItemsRequestDTO() - .setShouldCreateUDS(true) - .setDefaultGestioneOfNewUDS(mDefaultGestione.getText()) - .setItemsToPick(magazzinoAutomaticoPickItemRequestDTOList); + magazzinoAutomaticoPickItemRequestDTOList.add(itemDto); + } - mMagazzinoAutomaticoRESTConsumer.pickItems(mtbDepoPosizione, - magazzinoAutomaticoPickRequest, onComplete, this::sendError); - }, this::sendOnLoadingEnded); + var magazzinoAutomaticoPickRequest = new MagazzinoAutomaticoPickItemsRequestDTO() + .setShouldCreateUDS(true) + .setDefaultGestioneOfNewUDS(mDefaultGestione.getText()) + .setItemsToPick(magazzinoAutomaticoPickItemRequestDTOList); + + mMagazzinoAutomaticoRESTConsumer.pickItems(mtbDepoPosizione, + magazzinoAutomaticoPickRequest, onComplete, this::sendError); + + this.sendOnLoadingEnded(); }, this::sendError); @@ -382,6 +405,8 @@ public class PickingLiberoViewModel { mColliScaricoRESTConsumer.createUDS(createUDSRequest, mtbColt -> { + mMtbColtSessionID = mColliDataRecoverService.startNewSession(mtbColt, null); + mtbColt .setMtbColr(new ObservableArrayList<>()); @@ -526,6 +551,11 @@ public class PickingLiberoViewModel { true, true, (pickedQuantityDTO, shouldCloseLU) -> { + if (pickedQuantityDTO == null) { + this.sendOnLoadingEnded(); + return; + } + this.saveNewRow(pickingObjectDTO, pickedQuantityDTO.getNumCnf(), pickedQuantityDTO.getQtaCnf(), @@ -541,25 +571,40 @@ public class PickingLiberoViewModel { } private void pickMerceULtoUL(MtbColt sourceMtbColt, MtbAart mtbAart, Runnable onComplete) { - List mtbColrsToPick = Stream.of(sourceMtbColt.getMtbColr()) - .filter(x -> UtilityBigDecimal.greaterThan(x.getQtaCol(), BigDecimal.ZERO)) - .toList(); + executorService.execute(() -> { - this.sendArtSelectionRequest(mtbColrsToPick, mtbAart, pickedAarts -> { - List destNewMtbColr = new ArrayList<>(); + try { + List mtbColrsToPick = sourceMtbColt.getMtbColr().stream() + .filter(x -> UtilityBigDecimal.greaterThan(x.getQtaCol(), BigDecimal.ZERO)) + .collect(Collectors.toList()); - if (!pickedAarts.isEmpty()) { - askQuantities(pickedAarts.iterator(), destNewMtbColr, () -> { - if (!destNewMtbColr.isEmpty()) { + List pickedAarts = this.sendArtSelectionRequest(mtbColrsToPick, mtbAart); - if(this.mDefaultCommessa != null) - destNewMtbColr.forEach(x -> x.setCodJcom(this.mDefaultCommessa.getCodJcom())); + if (pickedAarts == null) { + this.sendOnLoadingEnded(); + return; + } - MtbColt clonedTestata = (MtbColt) sourceMtbColt.clone(); - clonedTestata.getMtbColr().clear(); - clonedTestata.getMtbColr().addAll(destNewMtbColr); + List mtbColrsToMove = new ArrayList<>(); - mColliMagazzinoRESTConsumer.spostaArtsTraUL(clonedTestata, + if (!pickedAarts.isEmpty()) { + for (var pickedArt : pickedAarts) { + var mtbColr = askSingleQuantity(pickedArt); + + if (mtbColr != null) + mtbColrsToMove.add(mtbColr); + } + + if (!mtbColrsToMove.isEmpty()) { + + if (this.mDefaultCommessa != null) + mtbColrsToMove.forEach(x -> x.setCodJcom(this.mDefaultCommessa.getCodJcom())); + + MtbColt clonedSourceTestata = (MtbColt) sourceMtbColt.clone(); + clonedSourceTestata.getMtbColr().clear(); + clonedSourceTestata.getMtbColr().addAll(mtbColrsToMove); + + mColliMagazzinoRESTConsumer.spostaArtsTraUL(clonedSourceTestata, this.mCurrentMtbColt, true, (generatedMtbColrs) -> { mCurrentMtbColt.getMtbColr().addAll(generatedMtbColrs); @@ -569,27 +614,24 @@ public class PickingLiberoViewModel { onComplete.run(); }, this::sendError); + } else { + onComplete.run(); + this.sendOnLoadingEnded(); } - }, onComplete); - } else { - onComplete.run(); + + } else { + onComplete.run(); + this.sendOnLoadingEnded(); + } + + } catch (InterruptedException e) { + this.sendError(e); } - }, this::sendOnLoadingEnded); + }); } - private void askQuantities(Iterator sourceMtbColrs, List destMtbColr, Runnable onComplete, Runnable onAbort) { - if (sourceMtbColrs.hasNext()) { - askSingleQuantity(sourceMtbColrs.next(), mtbColr -> { - destMtbColr.add(mtbColr); - askQuantities(sourceMtbColrs, destMtbColr, onComplete, onAbort); - }, onAbort); - } else { - onComplete.run(); - } - } - - private void askSingleQuantity(MtbColr mtbColr, RunnableArgs onComplete, Runnable onAbort) { + private MtbColr askSingleQuantity(MtbColr mtbColr) throws InterruptedException { MtbColt sourceMtbColt = new MtbColt() .setNumCollo(mtbColr.getNumCollo()) @@ -608,6 +650,8 @@ public class PickingLiberoViewModel { new PickDataDTO() .setSourceMtbColt(sourceMtbColt)); + CountDownLatch countDownLatch = new CountDownLatch(1); + AtomicReference result = new AtomicReference<>(); this.sendOnItemDispatched( pickingObjectDTO, @@ -627,6 +671,10 @@ public class PickingLiberoViewModel { false, false, (pickedQuantityDTO, shouldCloseLU) -> { + if (pickedQuantityDTO == null) { + countDownLatch.countDown(); + return; + } mtbColr .setPartitaMag(pickedQuantityDTO.getPartitaMag()) @@ -634,16 +682,21 @@ public class PickingLiberoViewModel { .setQtaCol(pickedQuantityDTO.getQtaTot()) .setQtaCnf(pickedQuantityDTO.getQtaCnf()) .setNumCnf(pickedQuantityDTO.getNumCnf()) - .setDatetimeRow(UtilityDate.getDateInstance()); + .setDatetimeRow(UtilityDate.getDateInstance()) + .setMtbAart(pickingObjectDTO.getMtbAart()); - onComplete.run(mtbColr); + result.set(mtbColr); + countDownLatch.countDown(); }); + + + countDownLatch.await(); + return result.get(); } public void saveNewRow(PickingObjectDTO pickingObjectDTO, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) { - new Thread(this::sendOnLoadingStarted).start(); - + this.sendOnLoadingStarted(); final MtbColr mtbColr = new MtbColr() .setCodMart(pickingObjectDTO.getMtbAart().getCodMart()) @@ -772,8 +825,12 @@ public class PickingLiberoViewModel { mtbColrToUpdate.getDataScadPartita(), false, false, - true, + false, (pickedQuantityDTO, shouldCloseLU) -> { + if (pickedQuantityDTO == null) { + this.sendOnLoadingEnded(); + return; + } this.saveEditedRow(mtbColrToUpdate, pickedQuantityDTO.getNumCnf(), @@ -872,6 +929,9 @@ public class PickingLiberoViewModel { mColliMagazzinoRESTConsumer.canULBeDeleted(mCurrentMtbColt, canBeDeleted -> { if (canBeDeleted) { deleteLU(() -> { + if (mMtbColtSessionID != null) + this.mColliDataRecoverService.closeSession(mMtbColtSessionID); + this.sendLUClosed(); this.sendOnLoadingEnded(); @@ -893,6 +953,9 @@ public class PickingLiberoViewModel { } this.mColliScaricoRESTConsumer.closeUDS(closeUDSRequest, response -> { + if (mMtbColtSessionID != null) + this.mColliDataRecoverService.closeSession(mMtbColtSessionID); + this.sendLUClosed(); this.sendOnLoadingEnded(); @@ -951,9 +1014,21 @@ public class PickingLiberoViewModel { if (this.mListener != null) mListener.onLUCommessaRequired(onComplete, onAbort); } - private void sendArtSelectionRequest(List mtbColrsToPick, MtbAart mtbAart, RunnableArgs> onComplete, Runnable onAbort) { + private List sendArtSelectionRequest(List mtbColrsToPick, MtbAart mtbAart) throws InterruptedException { + CountDownLatch countDownLatch = new CountDownLatch(1); + AtomicReference> result = new AtomicReference<>(); + + if (this.mListener != null) - mListener.onArtSelectionRequest(mtbColrsToPick, mtbAart, onComplete, onAbort); + mListener.onArtSelectionRequest(mtbColrsToPick, mtbAart, mtbColrs -> { + result.set(mtbColrs); + countDownLatch.countDown(); + }, countDownLatch::countDown); + else countDownLatch.countDown(); + + + countDownLatch.await(); + return result.get(); } private void sendOnItemDispatched(PickingObjectDTO pickingObjectDTO, @@ -973,6 +1048,7 @@ public class PickingLiberoViewModel { boolean canPartitaMagBeChanged, boolean canLUBeClosed, RunnableArgss onComplete) { + if (this.mListener != null) mListener.onItemDispatched(pickingObjectDTO, mtbAart, initialNumCnf, diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/DialogProgressView.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/DialogProgressView.java index 4c456019..dc04761d 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/DialogProgressView.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/DialogProgressView.java @@ -74,7 +74,12 @@ public class DialogProgressView extends DialogFragment { try { if (!manager.isDestroyed() && !isAdded()) { - //manager.executePendingTransactions(); + try { + manager.executePendingTransactions(); + } catch (IllegalStateException e) { + //ignore + String a = ""; + } showNow(manager, "loading-dialog"); mBindings.progressBar.setIndeterminate(isIndeterminateProgress()); @@ -91,7 +96,16 @@ public class DialogProgressView extends DialogFragment { handler.post(() -> { if (isAdded()) { dismissAllowingStateLoss(); + if (!getParentFragmentManager().isDestroyed()) { + try { + getParentFragmentManager().executePendingTransactions(); + } catch (IllegalStateException e) { + //ignore + String a = ""; + } + } } + }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity_v2/DialogInputQuantityV2View.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity_v2/DialogInputQuantityV2View.java index fe40362f..df2ec4b3 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity_v2/DialogInputQuantityV2View.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity_v2/DialogInputQuantityV2View.java @@ -267,8 +267,7 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia if (validated) { this.mAbort = false; - dismiss(); - this.mOnComplete.run(this.mViewModel.getResult(), false); + dismiss(this.mViewModel.getResult(), false); } }); }); @@ -278,14 +277,29 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia this.mViewModel.validate(validated -> { if (validated) { this.mAbort = false; - dismiss(); - this.mOnComplete.run(this.mViewModel.getResult(), true); + dismiss(this.mViewModel.getResult(), true); } else { this.onLoadingEnded(); } }); } + @Override + public void dismiss() { + dismiss(null, false); + } + + private void dismiss(DialogInputQuantityV2ResultDTO result, boolean shouldCloseLu) { + if (this.mOnComplete != null) { + if(result == null) { + mOnAbort.run(); + } else { + this.mOnComplete.run(result, shouldCloseLu); + } + } + super.dismiss(); + } + @Override public void onStart() { super.onStart();