diff --git a/app/build.gradle b/app/build.gradle index 72dec6d2..e5563154 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ apply plugin: 'com.google.gms.google-services' android { - def appVersionCode = 483 - def appVersionName = '1.45.01' + def appVersionCode = 484 + def appVersionName = '1.45.02' signingConfigs { release { diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneActivity.java b/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneActivity.java index b215b0e5..6de4b2ab 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneActivity.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneActivity.java @@ -5,6 +5,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; import android.os.Bundle; +import android.os.Handler; import android.text.Html; import android.text.SpannableString; import android.view.Gravity; @@ -96,6 +97,9 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo @Inject DialogInputQuantityV2View mDialogInputQuantityV2View; + @Inject + Handler handler; + private BottomSheetFragmentLUContentViewModel mBottomSheetFragmentLUContentViewModel; private final ObservableArrayList mSpedizioneMutableData = new ObservableArrayList<>(); @@ -715,30 +719,36 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo }; public void addExtraItem() { - DialogScanArtView - .newInstance(!mEnableFakeGiacenza, (status, mtbAart, ean128Model, mtbColr) -> { - if (status == DialogConsts.Results.YES) { - this.mViewmodel.dispatchExtraItem(mtbAart, ean128Model, mtbColr); - } - }, pickMagazzinoAutomaticoPosizione -> { - this.onLoadingStarted(); - this.mViewmodel.executeEmptyMagazzinoAutomaticoRequest(pickMagazzinoAutomaticoPosizione, this::onLoadingEnded); - }) - .show(getSupportFragmentManager(), "tag"); + handler.post(() -> { + DialogScanArtView + .newInstance(!mEnableFakeGiacenza, (status, mtbAart, ean128Model, mtbColr) -> { + if (status == DialogConsts.Results.YES) { + this.mViewmodel.dispatchExtraItem(mtbAart, ean128Model, mtbColr); + } + }, pickMagazzinoAutomaticoPosizione -> { + this.onLoadingStarted(); + this.mViewmodel.executeEmptyMagazzinoAutomaticoRequest(pickMagazzinoAutomaticoPosizione, this::onLoadingEnded); + }) + .show(getSupportFragmentManager(), "tag"); + }); } public void startManualSearch() { - BarcodeManager.disable(); - DialogSimpleInputHelper.makeInputDialog(this, "Inserisci il codice a barre", codice -> { + handler.post(() -> { + BarcodeManager.disable(); + DialogSimpleInputHelper.makeInputDialog(this, "Inserisci il codice a barre", codice -> { - this.onScanSuccessful.run(new BarcodeScanDTO().setStringValue(codice).setType(BarcodeType.CODE128)); - BarcodeManager.enable(); + this.onScanSuccessful.run(new BarcodeScanDTO().setStringValue(codice).setType(BarcodeType.CODE128)); + BarcodeManager.enable(); - }, BarcodeManager::enable).show(); + }, BarcodeManager::enable).show(); + }); } public void removeListFilter() { - this.mViewmodel.resetMatchedRows(); + handler.post(() -> { + this.mViewmodel.resetMatchedRows(); + }); } @@ -754,26 +764,30 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo public void trackPackaging() { - this.fabPopupMenu.dismiss(); + handler.post(() -> { + this.fabPopupMenu.dismiss(); - DialogTracciamentoImballiView.newInstance(imballiData -> { + DialogTracciamentoImballiView.newInstance(imballiData -> { - if (imballiData != null && !imballiData.isEmpty()) { - DialogAskVettoreView.newInstance(mViewmodel.getDefaultVettore(), vettoreData -> { - mViewmodel.registraImballi(vettoreData, imballiData); - }) - .show(getSupportFragmentManager(), DialogAskVettoreView.class.getName()); - } - }).show(getSupportFragmentManager(), DialogTracciamentoImballiView.class.getName()); + if (imballiData != null && !imballiData.isEmpty()) { + DialogAskVettoreView.newInstance(mViewmodel.getDefaultVettore(), vettoreData -> { + mViewmodel.registraImballi(vettoreData, imballiData); + }) + .show(getSupportFragmentManager(), DialogAskVettoreView.class.getName()); + } + }).show(getSupportFragmentManager(), DialogTracciamentoImballiView.class.getName()); + }); } public void showCreatedUL() { - this.fabPopupMenu.dismiss(); + handler.post(() -> { + this.fabPopupMenu.dismiss(); - ArrayList createdMtbColts = this.mViewmodel.getCreatedMtbColts(); + ArrayList createdMtbColts = this.mViewmodel.getCreatedMtbColts(); - Intent myIntent = ListaBancaliActivity.createIntent(this, createdMtbColts, true, false); - this.startActivityForResult(myIntent, PICK_UL_REQUEST); + Intent myIntent = ListaBancaliActivity.createIntent(this, createdMtbColts, true, false); + this.startActivityForResult(myIntent, PICK_UL_REQUEST); + }); } @@ -785,50 +799,60 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo @Override public void onLUOpened(MtbColt mtbColt) { - this.addExtraItemsEnabled.set(SettingsManager.iDB().isFlagCanAddExtraItemSpedizione()); - noLUPresent.set(false); + handler.post(() -> { + this.addExtraItemsEnabled.set(SettingsManager.iDB().isFlagCanAddExtraItemSpedizione()); + noLUPresent.set(false); - Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT) - .setBackgroundTint(getResources().getColor(R. color. green_500)) - .show(); + Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT) + .setBackgroundTint(getResources().getColor(R.color.green_500)) + .show(); - this.mBottomSheetFragmentLUContentViewModel.setMtbColt(mtbColt); + this.mBottomSheetFragmentLUContentViewModel.setMtbColt(mtbColt); + }); } @Override public void onLUClosed() { - this.addExtraItemsEnabled.set(false); - noLUPresent.set(true); - this.mBottomSheetFragmentLUContentViewModel.setMtbColt(null); + handler.post(() -> { + this.addExtraItemsEnabled.set(false); + noLUPresent.set(true); + this.mBottomSheetFragmentLUContentViewModel.setMtbColt(null); - if (this.mShouldCloseActivity) super.onBackPressed(); + if (this.mShouldCloseActivity) super.onBackPressed(); + }); } @Override public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss onComplete) { - DialogInputPesoLUView.newInstance(null, new BigDecimal(50), new BigDecimal(55), (newCodTcol, newNetWeight, newGrossWeight) -> { - onComplete.run(newCodTcol, netWeightKG, grossWeightKG); - }) - .show(getSupportFragmentManager(), "tag"); + handler.post(() -> { + DialogInputPesoLUView.newInstance(null, new BigDecimal(50), new BigDecimal(55), (newCodTcol, newNetWeight, newGrossWeight) -> { + onComplete.run(newCodTcol, netWeightKG, grossWeightKG); + }) + .show(getSupportFragmentManager(), "tag"); + }); } @Override public void onLUSuccessullyPrinted() { - Resources res = getResources(); - String errorMessage = res.getText(R.string.alert_print_completed_message).toString(); - DialogSimpleMessageView - .makeSuccessDialog(res.getText(R.string.completed).toString(), new SpannableString(errorMessage), null, null) - .show(getSupportFragmentManager(), "tag"); + handler.post(() -> { + Resources res = getResources(); + String errorMessage = res.getText(R.string.alert_print_completed_message).toString(); + DialogSimpleMessageView + .makeSuccessDialog(res.getText(R.string.completed).toString(), new SpannableString(errorMessage), null, null) + .show(getSupportFragmentManager(), "tag"); + }); } @Override public void onLUPrintRequest(RunnableArgs onComplete) { - DialogYesNoView.newInstance(getString(R.string.action_print), - String.format(getString(R.string.message_print_packing_list), "Packing List"), - result -> { - onComplete.run(result == DialogConsts.Results.YES); - }) - .show(getSupportFragmentManager(), "dialog-print"); + handler.post(() -> { + DialogYesNoView.newInstance(getString(R.string.action_print), + String.format(getString(R.string.message_print_packing_list), "Packing List"), + result -> { + onComplete.run(result == DialogConsts.Results.YES); + }) + .show(getSupportFragmentManager(), "dialog-print"); + }); } @Override @@ -845,41 +869,49 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo @Override public void onFilterApplied(String newValue) { - this.mBindings.filteredArtsInListExpandableLayout.expand(true); - this.mBindings.descriptionFilterText.setText(!UtilityString.isNullOrEmpty(newValue) ? newValue : ""); + handler.post(() -> { + this.mBindings.filteredArtsInListExpandableLayout.expand(true); + this.mBindings.descriptionFilterText.setText(!UtilityString.isNullOrEmpty(newValue) ? newValue : ""); + }); } @Override public void onFilterRemoved() { - this.mBindings.filteredArtsInListExpandableLayout.collapse(true); - this.mBindings.descriptionFilterText.setText(""); + handler.post(() -> { + this.mBindings.filteredArtsInListExpandableLayout.collapse(true); + this.mBindings.descriptionFilterText.setText(""); + }); } @Override public void onMtbColrDeleteRequest(RunnableArgs onComplete) { - String text = getResources().getString(R.string.alert_delete_mtb_colr); - DialogSimpleMessageView.makeWarningDialog(new SpannableString(text), - null, - () -> onComplete.run(true), - () -> onComplete.run(false) - ) - .show(getSupportFragmentManager(), "tag"); + handler.post(() -> { + String text = getResources().getString(R.string.alert_delete_mtb_colr); + DialogSimpleMessageView.makeWarningDialog(new SpannableString(text), + null, + () -> onComplete.run(true), + () -> onComplete.run(false) + ) + .show(getSupportFragmentManager(), "tag"); + }); } @Override public void onError(Exception ex, boolean useSnackbar) { - this.onLoadingEnded(); + handler.post(() -> { + this.onLoadingEnded(); - if (ex instanceof InvalidPesoKGException) { - UtilityToast.showToast(ex.getMessage()); - } else { - if(useSnackbar) - Snackbar.make(mBindings.getRoot(), Objects.requireNonNull(ex.getMessage()), Snackbar.LENGTH_LONG).show(); - else - UtilityExceptions.defaultException(this, ex); - } + if (ex instanceof InvalidPesoKGException) { + UtilityToast.showToast(ex.getMessage()); + } else { + if (useSnackbar) + Snackbar.make(mBindings.getRoot(), Objects.requireNonNull(ex.getMessage()), Snackbar.LENGTH_LONG).show(); + else + UtilityExceptions.defaultException(this, ex); + } - BarcodeManager.enable(); + BarcodeManager.enable(); + }); } @Override @@ -1057,7 +1089,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo @Override public void onRowSaved() { Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT) - .setBackgroundTint(getResources().getColor(R. color. green_500)) + .setBackgroundTint(getResources().getColor(R.color.green_500)) .show(); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneModule.java b/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneModule.java index e2f150e2..53ac380c 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneModule.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneModule.java @@ -1,5 +1,9 @@ package it.integry.integrywmsnative.gest.spedizione; +import android.os.Handler; + +import java.util.concurrent.ExecutorService; + import dagger.Module; import dagger.Provides; import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService; @@ -38,7 +42,9 @@ public class SpedizioneModule { ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer, MagazzinoAutomaticoRESTConsumer magazzinoAutomaticoRESTConsumer, ImballiRESTConsumer imballiRESTConsumer, - MagazzinoRESTConsumer magazzinoRESTConsumer) { + MagazzinoRESTConsumer magazzinoRESTConsumer, + ExecutorService executorService, + Handler handler) { return new SpedizioneViewModel(articoloRESTConsumer, barcodeRESTConsumer, colliDataRecoverService, @@ -51,7 +57,9 @@ public class SpedizioneModule { colliLavorazioneRESTConsumer, magazzinoAutomaticoRESTConsumer, imballiRESTConsumer, - magazzinoRESTConsumer); + magazzinoRESTConsumer, + executorService, + handler); } } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneViewModel.java index 0bea993f..7905910f 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneViewModel.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.gest.spedizione; +import android.os.Handler; + import androidx.databinding.ObservableArrayList; import androidx.lifecycle.MutableLiveData; @@ -14,6 +16,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; import javax.inject.Inject; @@ -140,9 +143,13 @@ public class SpedizioneViewModel { private final MagazzinoAutomaticoRESTConsumer mMagazzinoAutomaticoRESTConsumer; private final ImballiRESTConsumer mImballiRESTConsumer; + private final ExecutorService executorService; + private final Handler handler; + private ColliScaricoRESTConsumerInterface mColliScaricoRESTConsumer; private MagazzinoRESTConsumer magazzinoRESTConsumer; + @Inject public SpedizioneViewModel(ArticoloRESTConsumer articoloRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, @@ -156,7 +163,9 @@ public class SpedizioneViewModel { ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer, MagazzinoAutomaticoRESTConsumer mMagazzinoAutomaticoRESTConsumer, ImballiRESTConsumer imballiRESTConsumer, - MagazzinoRESTConsumer magazzinoRESTConsumer) { + MagazzinoRESTConsumer magazzinoRESTConsumer, + ExecutorService executorService, + Handler handler) { this.mArticoloRESTConsumer = articoloRESTConsumer; this.mBarcodeRESTConsumer = barcodeRESTConsumer; this.mColliDataRecoverService = colliDataRecoverService; @@ -170,6 +179,8 @@ public class SpedizioneViewModel { this.mMagazzinoAutomaticoRESTConsumer = mMagazzinoAutomaticoRESTConsumer; this.mImballiRESTConsumer = imballiRESTConsumer; this.magazzinoRESTConsumer = magazzinoRESTConsumer; + this.executorService = executorService; + this.handler = handler; } @@ -674,7 +685,7 @@ public class SpedizioneViewModel { this.executeEtichettaLU(ean128Model.Sscc, onComplete); } else { - if(SettingsManager.iDB().isFlagSpedizioneEnableManualPick()) { + if (SettingsManager.iDB().isFlagSpedizioneEnableManualPick()) { PickDataDTO pickDataDTO = PickDataDTO.fromEan128(ean128Model); this.loadArticolo(barcodeProd, pickDataDTO, onComplete); @@ -1480,10 +1491,10 @@ public class SpedizioneViewModel { //Chiamato removeListFilter perché cosi mi cancella tutti i dati di pick temporanei if (removeFilters) - resetMatchedRows(); - else - //Refresh della lista forzato - this.mPickingList.postValue(this.mPickingList.getValue()); + resetMatchedRows(); + else + //Refresh della lista forzato + this.mPickingList.postValue(this.mPickingList.getValue()); this.sendOnRowSaved(); this.sendOnLoadingEnded(); @@ -1518,7 +1529,7 @@ public class SpedizioneViewModel { .findFirst() .orElse(null); - if(!UtilityString.isNullOrEmpty(newTipoUL) && newMtbTcol == null) { + if (!UtilityString.isNullOrEmpty(newTipoUL) && newMtbTcol == null) { this.sendError(new Exception("Impossibile riconoscere il tipo UL " + newTipoUL)); onComplete.run(); return; @@ -2015,12 +2026,14 @@ public class SpedizioneViewModel { } public void resetMatchedRows() { - for (PickingObjectDTO pickingObjectDTO : this.mPickingList.getValue()) { - pickingObjectDTO.setTempPickData(null).setHidden(false); - } + handler.post(() -> { + for (PickingObjectDTO pickingObjectDTO : this.mPickingList.getValue()) { + pickingObjectDTO.setTempPickData(null).setHidden(false); + } - this.mPickingList.postValue(this.mPickingList.getValue()); - this.sendFilterRemoved(); + this.mPickingList.postValue(this.mPickingList.getValue()); + this.sendFilterRemoved(); + }); } public void closeOrder() {