Fix su handler in spedizione

This commit is contained in:
Giuseppe Scorrano 2025-03-18 12:16:41 +01:00
parent fa7d561189
commit a93d80b2e2
3 changed files with 143 additions and 90 deletions

View File

@ -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<SpedizioneListModel> mSpedizioneMutableData = new ObservableArrayList<>();
@ -715,6 +719,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
};
public void addExtraItem() {
handler.post(() -> {
DialogScanArtView
.newInstance(!mEnableFakeGiacenza, (status, mtbAart, ean128Model, mtbColr) -> {
if (status == DialogConsts.Results.YES) {
@ -725,9 +730,11 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
this.mViewmodel.executeEmptyMagazzinoAutomaticoRequest(pickMagazzinoAutomaticoPosizione, this::onLoadingEnded);
})
.show(getSupportFragmentManager(), "tag");
});
}
public void startManualSearch() {
handler.post(() -> {
BarcodeManager.disable();
DialogSimpleInputHelper.makeInputDialog(this, "Inserisci il codice a barre", codice -> {
@ -735,10 +742,13 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
BarcodeManager.enable();
}, BarcodeManager::enable).show();
});
}
public void removeListFilter() {
handler.post(() -> {
this.mViewmodel.resetMatchedRows();
});
}
@ -754,6 +764,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
public void trackPackaging() {
handler.post(() -> {
this.fabPopupMenu.dismiss();
DialogTracciamentoImballiView.newInstance(imballiData -> {
@ -765,15 +776,18 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
.show(getSupportFragmentManager(), DialogAskVettoreView.class.getName());
}
}).show(getSupportFragmentManager(), DialogTracciamentoImballiView.class.getName());
});
}
public void showCreatedUL() {
handler.post(() -> {
this.fabPopupMenu.dismiss();
ArrayList<MtbColt> createdMtbColts = this.mViewmodel.getCreatedMtbColts();
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) {
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))
.setBackgroundTint(getResources().getColor(R.color.green_500))
.show();
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(mtbColt);
});
}
@Override
public void onLUClosed() {
handler.post(() -> {
this.addExtraItemsEnabled.set(false);
noLUPresent.set(true);
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(null);
if (this.mShouldCloseActivity) super.onBackPressed();
});
}
@Override
public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete) {
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() {
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<Boolean> onComplete) {
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,18 +869,23 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
@Override
public void onFilterApplied(String newValue) {
handler.post(() -> {
this.mBindings.filteredArtsInListExpandableLayout.expand(true);
this.mBindings.descriptionFilterText.setText(!UtilityString.isNullOrEmpty(newValue) ? newValue : "");
});
}
@Override
public void onFilterRemoved() {
handler.post(() -> {
this.mBindings.filteredArtsInListExpandableLayout.collapse(true);
this.mBindings.descriptionFilterText.setText("");
});
}
@Override
public void onMtbColrDeleteRequest(RunnableArgs<Boolean> onComplete) {
handler.post(() -> {
String text = getResources().getString(R.string.alert_delete_mtb_colr);
DialogSimpleMessageView.makeWarningDialog(new SpannableString(text),
null,
@ -864,22 +893,25 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
() -> onComplete.run(false)
)
.show(getSupportFragmentManager(), "tag");
});
}
@Override
public void onError(Exception ex, boolean useSnackbar) {
handler.post(() -> {
this.onLoadingEnded();
if (ex instanceof InvalidPesoKGException) {
UtilityToast.showToast(ex.getMessage());
} else {
if(useSnackbar)
if (useSnackbar)
Snackbar.make(mBindings.getRoot(), Objects.requireNonNull(ex.getMessage()), Snackbar.LENGTH_LONG).show();
else
UtilityExceptions.defaultException(this, ex);
}
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();
}

View File

@ -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);
}
}

View File

@ -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);
@ -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() {
handler.post(() -> {
for (PickingObjectDTO pickingObjectDTO : this.mPickingList.getValue()) {
pickingObjectDTO.setTempPickData(null).setHidden(false);
}
this.mPickingList.postValue(this.mPickingList.getValue());
this.sendFilterRemoved();
});
}
public void closeOrder() {