Implementati suoni alla scansione dei barcode

This commit is contained in:
Marco Elefante 2024-02-16 09:26:52 +01:00
parent 7049552f16
commit f0e1cf7f0b
6 changed files with 66 additions and 5 deletions

View File

@ -43,6 +43,7 @@ import it.integry.integrywmsnative.core.rest.consumers.ProductionLinesRESTConsum
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.services.inventario.InventarioService;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.sound.SoundAlertService;
import it.integry.integrywmsnative.core.update.UpdatesManager;
import it.integry.integrywmsnative.gest.contab_doc_interni.rest.DocInterniRESTConsumer;
import it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.rest.ProdFabbisognoLineeProdRESTConsumer;
@ -291,4 +292,12 @@ public class MainApplicationModule {
return new MagazzinoBufferRESTConsumer();
}
@Provides
@Singleton
SoundAlertService provideSoundAlertService() {
SoundAlertService soundAlertService = new SoundAlertService(mApplication.getApplicationContext());
soundAlertService.init();
return soundAlertService;
}
}

View File

@ -0,0 +1,40 @@
package it.integry.integrywmsnative.core.sound;
import android.content.Context;
import android.media.MediaPlayer;
import it.integry.integrywmsnative.R;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class SoundAlertService {
private final Context mApplicationContext;
private MediaPlayer successPlayer;
private MediaPlayer warningPlayer;
public SoundAlertService(Context context) {
this.mApplicationContext = context;
}
@Inject
public void init() {
successPlayer = MediaPlayer.create(this.mApplicationContext, R.raw.success_sound);
warningPlayer = MediaPlayer.create(this.mApplicationContext, R.raw.warning_sound);
}
public void success() {
if (successPlayer != null) {
successPlayer.start();
}
}
public void warning() {
if (warningPlayer != null) {
warningPlayer.start();
}
}
}

View File

@ -7,13 +7,14 @@ import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsume
import it.integry.integrywmsnative.core.rest.consumers.GiacenzaRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoAutomaticoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
import it.integry.integrywmsnative.core.sound.SoundAlertService;
@Module(subcomponents = ProdRiposizionamentoDaProdComponent.class)
public class ProdRiposizionamentoDaProdModule {
@Provides
ProdRiposizionamentoDaProdViewModel providesProdRiposizionamentoDaProdViewModel(GiacenzaRESTConsumer giacenzaRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer) {
return new ProdRiposizionamentoDaProdViewModel(giacenzaRESTConsumer, barcodeRESTConsumer, colliMagazzinoRESTConsumer);
ProdRiposizionamentoDaProdViewModel providesProdRiposizionamentoDaProdViewModel(GiacenzaRESTConsumer giacenzaRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, SoundAlertService soundAlertService) {
return new ProdRiposizionamentoDaProdViewModel(giacenzaRESTConsumer, barcodeRESTConsumer, colliMagazzinoRESTConsumer, soundAlertService);
}
}

View File

@ -13,6 +13,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.inject.Inject;
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
import it.integry.integrywmsnative.core.exception.ScannedPositionNotExistException;
@ -25,13 +27,14 @@ import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.GiacenzaRESTConsumer;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.sound.SoundAlertService;
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.dto.ArtsInGiacenzaDTO;
public class ProdRiposizionamentoDaProdViewModel {
private final SoundAlertService mSoundAlertService;
private final GiacenzaRESTConsumer mGiacenzaRESTConsumer;
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
@ -40,10 +43,11 @@ public class ProdRiposizionamentoDaProdViewModel {
private final MutableLiveData<List<MvwSitArtUdcDetInventario>> mMvwSitArtUdcDetInventarioLiveData = new MutableLiveData<>();
private Listener mListener;
public ProdRiposizionamentoDaProdViewModel(GiacenzaRESTConsumer giacenzaRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer) {
public ProdRiposizionamentoDaProdViewModel(GiacenzaRESTConsumer giacenzaRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, SoundAlertService soundAlertService) {
this.mGiacenzaRESTConsumer = giacenzaRESTConsumer;
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
this.mSoundAlertService = soundAlertService;
}
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
@ -72,6 +76,7 @@ public class ProdRiposizionamentoDaProdViewModel {
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) {
this.executeEtichettaLU(ean128Model.Sscc, false, onBarcodeScanComplete);
} else {
this.mSoundAlertService.warning();
this.sendError(new NoLUFoundException());
}
@ -86,6 +91,7 @@ public class ProdRiposizionamentoDaProdViewModel {
private void executeEtichettaLU(String sscc, boolean isAnonima, Runnable onComplete) {
this.mColliMagazzinoRESTConsumer.getBySSCC(sscc, true, false, mtbColt -> {
if (mtbColt == null && !isAnonima) {
this.mSoundAlertService.warning();
this.sendError(new NoLUFoundException());
} else {
List<MvwSitArtUdcDetInventario> mvwSitArtUdcDetInventario = Stream.of(Objects.requireNonNull(itemsInventario.getValue()))
@ -102,10 +108,12 @@ public class ProdRiposizionamentoDaProdViewModel {
x.getNumCollo().equals(mtbColt.getNumCollo()));
if (isPresent && mtbColt != null) {
this.mSoundAlertService.success();
mtbColt.setDisablePrint(true);
onComplete.run();
this.onLUOpened(mtbColt);
} else {
this.mSoundAlertService.warning();
this.sendError(new NoLUFoundException());
}
}
@ -171,7 +179,10 @@ public class ProdRiposizionamentoDaProdViewModel {
this.sendOnDataSaved();
}
}, this::sendError);
} else this.sendError(new NoLUFoundException());
} else {
this.mSoundAlertService.warning();
this.sendError(new NoLUFoundException());
}
}
}

Binary file not shown.

Binary file not shown.