diff --git a/app/src/main/java/it/integry/integrywmsnative/core/ean128/Ean128Service.java b/app/src/main/java/it/integry/integrywmsnative/core/ean128/Ean128Service.java index 9286180c..c5405de0 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/ean128/Ean128Service.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/ean128/Ean128Service.java @@ -228,13 +228,13 @@ public class Ean128Service { case SHIP_TO_POST -> model.ShipToPost = aiValue.toString(); case SHIP_TO_POST_ISO -> model.ShipToPostISO = convertToIsoValueModel(aiValue.toString(), 0, - new Callable() { + new Callable<>() { @Override public String call(String input) { return input; } }, - new CallableII() { + new CallableII<>() { @Override public String call(String input, Integer input2) { return input; @@ -300,7 +300,7 @@ public class Ean128Service { T value = castFunc.call(splitFunc.call(sourceString.substring(3), numberOfDecimalDigits)); - Ean128ISOValueModel isoModel = new Ean128ISOValueModel(); + Ean128ISOValueModel isoModel = new Ean128ISOValueModel<>(); isoModel.ISOCode = isoCode; isoModel.Value = value; diff --git a/app/src/main/java/it/integry/integrywmsnative/core/menu/MenuRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/menu/MenuRESTConsumer.java index 3d773ddf..c71503f9 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/menu/MenuRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/menu/MenuRESTConsumer.java @@ -1,14 +1,16 @@ package it.integry.integrywmsnative.core.menu; +import androidx.annotation.NonNull; + import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.StbMenu; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -16,15 +18,15 @@ public class MenuRESTConsumer extends _BaseRESTConsumer { public void retrieveMenu(String rootCodOpz, RunnableArgs onComplete, RunnableArgs onFailed) { MenuRESTConsumerService menuRESTConsumerService = RESTBuilder.getService(MenuRESTConsumerService.class); - menuRESTConsumerService.retrieveMenuConfig(rootCodOpz).enqueue(new Callback<>() { + menuRESTConsumerService.retrieveMenuConfig(rootCodOpz).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "retrieveMenu", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/model/MtbDepo.java b/app/src/main/java/it/integry/integrywmsnative/core/model/MtbDepo.java index bc720675..2c55daee 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/model/MtbDepo.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/model/MtbDepo.java @@ -103,7 +103,7 @@ public class MtbDepo extends EntityBase implements Parcelable { return 0; } - public static final Creator CREATOR = new Creator() { + public static final Creator CREATOR = new Creator<>() { @Override public MtbDepo createFromParcel(Parcel in) { return new MtbDepo(in); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/model/VtbDest.java b/app/src/main/java/it/integry/integrywmsnative/core/model/VtbDest.java index 45efd882..802c244c 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/model/VtbDest.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/model/VtbDest.java @@ -55,7 +55,7 @@ public class VtbDest extends EntityBase implements Parcelable { return 0; } - public static final Creator CREATOR = new Creator() { + public static final Creator CREATOR = new Creator<>() { @Override public VtbDest createFromParcel(Parcel in) { return new VtbDest(in); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ArticoloRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ArticoloRESTConsumer.java index 87db9581..4a326dd3 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ArticoloRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ArticoloRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; + import com.annimon.stream.Stream; import com.google.gson.reflect.TypeToken; @@ -17,6 +19,7 @@ import it.integry.integrywmsnative.core.model.MtbGrup; import it.integry.integrywmsnative.core.model.MtbUntMis; import it.integry.integrywmsnative.core.model.dto.StatoArticoloDTO; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.articolo.ArticoloDTO; import it.integry.integrywmsnative.core.rest.model.articolo.RetrieveArticoloByCodMartRequestDTO; @@ -27,7 +30,6 @@ import it.integry.integrywmsnative.core.rest.model.articolo.SearchArticoloByBarc import it.integry.integrywmsnative.core.rest.model.articolo.UpdateBarcodeImballoRequestDTO; import it.integry.integrywmsnative.core.utility.UtilityQuery; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -44,15 +46,15 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer { ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class); articoloRESTConsumerService .retrieveAvailableUntMis() - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswerList(response, "retrieveAvailableUntMis", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -61,15 +63,15 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer { ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class); articoloRESTConsumerService .retrieveAvailableGruppiMerceologici() - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswerList(response, "retrieveAvailableGruppiMerceologici", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -83,7 +85,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer { articoloRESTConsumerService .searchByBarcode(request) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "searchByBarcode", (m) -> { @@ -92,8 +94,8 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -114,15 +116,15 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer { articoloRESTConsumer .getByCodMart(new RetrieveArticoloByCodMartRequestDTO() .setCodMarts(codMarts)) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getByCodMart", onComplete, onFailed); } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -131,15 +133,15 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer { public void getStatoPartita(String codMart, String partitaMag, RunnableArgs> onComplete, RunnableArgs onFailed) { ArticoloRESTConsumerService articoloRESTConsumer = RESTBuilder.getService(ArticoloRESTConsumerService.class); - articoloRESTConsumer.getStatoPartita(codMart, partitaMag).enqueue(new Callback<>() { + articoloRESTConsumer.getStatoPartita(codMart, partitaMag).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getStatoPartita", onComplete, onFailed); } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -229,7 +231,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer { articoloRESTConsumerService .updateBarcodeImballo(request) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "updateBarcodeImballo", m -> { @@ -238,8 +240,8 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -253,7 +255,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer { articoloRESTConsumerService .saveArticolo(request) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "saveArticolo", data -> { @@ -262,8 +264,8 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/AziendaRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/AziendaRESTConsumer.java index b994b3db..8e723108 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/AziendaRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/AziendaRESTConsumer.java @@ -1,13 +1,15 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; + import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.Azienda; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -15,15 +17,15 @@ public class AziendaRESTConsumer extends _BaseRESTConsumer { public void retrieveAzienda(RunnableArgs onComplete, RunnableArgs onFailed) { AziendaRESTConsumerService aziendaRESTConsumerService = RESTBuilder.getService(AziendaRESTConsumerService.class); - aziendaRESTConsumerService.retrieveDefaultAzienda().enqueue(new Callback<>() { + aziendaRESTConsumerService.retrieveDefaultAzienda().enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "Retrieve default azienda", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliAccettazioneRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliAccettazioneRESTConsumer.java index dc07ca34..cf56f02f 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliAccettazioneRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliAccettazioneRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; + import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; @@ -7,6 +9,7 @@ import it.integry.integrywmsnative.core.model.MtbColr; import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliCaricoRESTConsumerInterface; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCResponseDTO; @@ -18,7 +21,6 @@ import it.integry.integrywmsnative.core.rest.model.udc.EditUDCRowResponseDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowResponseDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -28,15 +30,15 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); colliAccettazioneRESTConsumerService.createUDC(createUDCRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "accettazione/createUDC", data -> onComplete.run(data.getMtbColt()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -47,15 +49,15 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); colliAccettazioneRESTConsumerService.closeUDC(closeUDCRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "accettazione/closeUDC", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -65,15 +67,15 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); colliAccettazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "accettazione/insertUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -83,15 +85,15 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); colliAccettazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "accettazione/editUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -101,15 +103,15 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); colliAccettazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "accettazione/deleteUDCRow", data -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -118,15 +120,15 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); colliAccettazioneRESTConsumerService.checkIfBarcodeUlAlreadyRegistered(barcodeUl) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "accettazione/checkIfBarcodeUlAlreadyRegistered", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliLavorazioneRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliLavorazioneRESTConsumer.java index 0decfd3a..e4b568ed 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliLavorazioneRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliLavorazioneRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; + import java.math.BigDecimal; import javax.inject.Singleton; @@ -12,6 +14,7 @@ import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliCaricoRESTConsumerInterface; import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliScaricoRESTConsumerInterface; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCResponseDTO; @@ -34,7 +37,6 @@ import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowResponseDTO; import it.integry.integrywmsnative.core.settings.SettingsManager; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -52,15 +54,15 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); colliLavorazioneRESTConsumerService.createUDC(createUDCRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "lavorazione/createUDC", data -> onComplete.run(data.getMtbColt()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -70,15 +72,15 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); colliLavorazioneRESTConsumerService.closeUDC(closeUDCRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "lavorazione/closeUDC", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -88,15 +90,15 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); colliLavorazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "lavorazione/insertUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -106,15 +108,15 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); colliLavorazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "lavorazione/editUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -123,15 +125,15 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); colliLavorazioneRESTConsumerService.createUDS(createUDSRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "lavorazione/createUDS", data -> onComplete.run(data.getMtbColt()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -142,15 +144,15 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); colliLavorazioneRESTConsumerService.closeUDS(closeUDSRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "lavorazione/closeUDS", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -160,15 +162,15 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); colliLavorazioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "lavorazione/insertUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -177,15 +179,15 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); colliLavorazioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "lavorazione/editUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -195,15 +197,15 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); colliLavorazioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "lavorazione/deleteUDSRow", data -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -213,15 +215,15 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); colliLavorazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "lavorazione/deleteUDCRow", data -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -252,15 +254,15 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); colliLavorazioneRESTConsumerService.createUDSFromArt(createUDSFromArtRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "lavorazione/createUDSFromArt", data -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } 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 42080438..1c868fa7 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 @@ -1,5 +1,6 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; import androidx.databinding.ObservableArrayList; import com.annimon.stream.Optional; @@ -29,6 +30,7 @@ import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.model.secondary.GestioneEnum; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.RettificaULDTO; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULRequestDTO; @@ -46,7 +48,6 @@ import it.integry.integrywmsnative.core.utility.UtilityQuery; import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -82,7 +83,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { .setMtbPartitaMag(null)); } - this.mEntityRESTConsumer.processEntity(mtbColtToSaveClone, new ISimpleOperationCallback() { + this.mEntityRESTConsumer.processEntity(mtbColtToSaveClone, new ISimpleOperationCallback<>() { @Override public void onSuccess(MtbColt value) { if (onComplete != null) onComplete.run(value); @@ -285,7 +286,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { public void getBySSCC(String ssccString, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs onComplete, RunnableArgs onFailed) { ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); - colliMagazzinoRESTConsumerService.getColloByBarcode(ssccString, onlyResiduo, throwExcIfNull).enqueue(new Callback<>() { + colliMagazzinoRESTConsumerService.getColloByBarcode(ssccString, onlyResiduo, throwExcIfNull).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "GetBySSCC", mtbColt -> { @@ -302,8 +303,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -385,27 +386,28 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); - colliMagazzinoRESTConsumerService.getColloInGiac(onlyResiduo, throwExcIfNull, testata).enqueue(new Callback>() { - @Override - public void onResponse(Call> call, Response> response) { - analyzeAnswer(response, "getColloInGiac", mtbColt -> { + colliMagazzinoRESTConsumerService.getColloInGiac(onlyResiduo, throwExcIfNull, testata) + .enqueue(new ManagedErrorCallback<>() { + @Override + public void onResponse(Call> call, Response> response) { + analyzeAnswer(response, "getColloInGiac", mtbColt -> { - if (mtbColt != null && mtbColt.getMtbColr() != null && mtbColt.getMtbColr().size() > 0) { - List mtbColtList = new ArrayList<>(); - mtbColtList.add(mtbColt); - fillMtbAartsOfMtbColts(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed); - } else { - onComplete.run(mtbColt); + if (mtbColt != null && mtbColt.getMtbColr() != null && mtbColt.getMtbColr().size() > 0) { + List mtbColtList = new ArrayList<>(); + mtbColtList.add(mtbColt); + fillMtbAartsOfMtbColts(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed); + } else { + onComplete.run(mtbColt); + } + + }, onFailed); } - }, onFailed); - } - - @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); - } - }); + @Override + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); + } + }); } public void spostaUL(MtbColt mtbColtToMove, String codMdep, String posizione, boolean createDocAutomatically, Runnable onComplete, RunnableArgs onFailed) { @@ -426,7 +428,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); colliMagazzinoRESTConsumerService .spostaUL(spostaUlRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "spostaUL", mtbColts -> { @@ -435,8 +437,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); } @@ -461,7 +463,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); colliMagazzinoRESTConsumerService .updateTipoUL(updateTipoULRequest) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "updateTipoUL", mtbColts -> { @@ -470,8 +472,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); @@ -495,7 +497,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { public static void retrieveBasketColli(RunnableArgs> onComplete, RunnableArgs onFailed) { ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); - colliMagazzinoRESTConsumerService.getColliInBasket(SettingsManager.i().getUserSession().getDepo().getCodMdep()).enqueue(new Callback>>() { + colliMagazzinoRESTConsumerService.getColliInBasket(SettingsManager.i().getUserSession().getDepo().getCodMdep()).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getColliInBasket", mtbColts -> { @@ -504,8 +506,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); } @@ -524,15 +526,15 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { colliMagazzinoRESTConsumerService.creaRettificaCollo( SettingsManager.i().getUserSession().getDepo().getCodMdep(), rettificaULDTO - ).enqueue(new Callback<>() { + ).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "creaRettificaCollo", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); } @@ -556,7 +558,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { .setFlagForceUseRefs(flagForceUseRefs); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); - colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO).enqueue(new Callback<>() { + colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "spostaArtsTraUL", data -> { @@ -565,8 +567,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); }).start(); @@ -582,7 +584,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { } ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); - colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new Callback<>() { + colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "assegnaLottoSuColloScarico", data -> { @@ -591,8 +593,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); } @@ -607,7 +609,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { } ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); - colliMagazzinoRESTConsumerService.versamentoAutomaticoUL(sourceMtbColtClone).enqueue(new Callback<>() { + colliMagazzinoRESTConsumerService.versamentoAutomaticoUL(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "versamentoAutomaticoUL", data -> { @@ -644,8 +646,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); } @@ -655,7 +657,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { sourceMtbColtClone.setMtbColr(new ObservableArrayList<>()); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); - colliMagazzinoRESTConsumerService.confirmGiacenzaUL(sourceMtbColtClone).enqueue(new Callback<>() { + colliMagazzinoRESTConsumerService.confirmGiacenzaUL(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "confirmGiacenzaUL", data -> { @@ -665,8 +667,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); } @@ -705,15 +707,15 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); colliMagazzinoRESTConsumerService.canULBeDeleted(canULBeDeletedRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "generic/canULBeDeleted", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -723,15 +725,15 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); colliMagazzinoRESTConsumerService.deleteUL(deleteULRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "generic/deleteUL", Void -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -746,15 +748,15 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); colliMagazzinoRESTConsumerService.printUL(printULRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "generic/printUL", Void -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliSpedizioneRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliSpedizioneRESTConsumer.java index a44d8bc2..da54620c 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliSpedizioneRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliSpedizioneRESTConsumer.java @@ -9,6 +9,7 @@ import it.integry.integrywmsnative.core.model.MtbColr; import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliScaricoRESTConsumerInterface; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSResponseDTO; @@ -22,7 +23,6 @@ import it.integry.integrywmsnative.core.rest.model.uds.EditUDSRowResponseDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowResponseDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -33,15 +33,15 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); colliSpedizioneRESTConsumerService.createUDS(createUDSRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "spedizione/createUDS", data -> onComplete.run(data.getMtbColt()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -51,15 +51,15 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); colliSpedizioneRESTConsumerService.closeUDS(closeUDSRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "spedizione/closeUDS", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -69,15 +69,15 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); colliSpedizioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "spedizione/insertUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -86,15 +86,15 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); colliSpedizioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "spedizione/editUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -103,15 +103,15 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); colliSpedizioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "spedizione/deleteUDSRow", data -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -121,14 +121,14 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); colliSpedizioneRESTConsumerService.duplicateUDS(duplicateUDSRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(@NonNull Call> call, @NonNull Response> response) { analyzeAnswer(response, "spedizione/duplicateUDS", onComplete, onFailed); } @Override - public void onFailure(@NonNull Call> call, @NonNull Throwable t) { + public void onFailure(@NonNull Call> call, @NonNull final Exception e) { onFailed.run(new Exception()); } }); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/DocumentRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/DocumentRESTConsumer.java index 10ebd3ea..ee911b9e 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/DocumentRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/DocumentRESTConsumer.java @@ -2,7 +2,6 @@ package it.integry.integrywmsnative.core.rest.consumers; import androidx.annotation.NonNull; -import java.util.Date; import java.util.List; import javax.inject.Singleton; @@ -10,11 +9,11 @@ import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.DtbDoct; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.LoadColliDTO; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.documento.RetrieveDocumentoArtsResponseDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -23,30 +22,30 @@ public class DocumentRESTConsumer extends _BaseRESTConsumer { public void createDocsFromColli(List listColli, RunnableArgs> onComplete, RunnableArgs onFailed) { DocumentiRESTConsumerService documentiRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class); - documentiRESTConsumerService.createDocsFromColli(listColli).enqueue(new Callback<>() { + documentiRESTConsumerService.createDocsFromColli(listColli).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "createDocsFromColli", onComplete, onFailed); } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } public void createDocFromColli(LoadColliDTO loadColliDTO, RunnableArgs onComplete, RunnableArgs onFailed) { DocumentiRESTConsumerService documentiRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class); - documentiRESTConsumerService.createDocFromColli(loadColliDTO).enqueue(new Callback<>() { + documentiRESTConsumerService.createDocFromColli(loadColliDTO).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "createDocFromColli", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -54,15 +53,15 @@ public class DocumentRESTConsumer extends _BaseRESTConsumer { public void checkDocument(String fornitore, String numDoc, String dataDoc, String tipoDoc, RunnableArgs onComplete, RunnableArgs onFailed) { var inventarioRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class); inventarioRESTConsumerService.checkDocument(fornitore, numDoc,tipoDoc, dataDoc) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(@NonNull Call> call, @NonNull Response> response) { analyzeAnswer(response, "checkDocument", onComplete, onFailed); } @Override - public void onFailure(@NonNull Call> call, @NonNull Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(@NonNull Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -70,15 +69,15 @@ public class DocumentRESTConsumer extends _BaseRESTConsumer { public void loadDocumentAvailableArts(String codDtip, String codMgrp, String codAnagForn, RunnableArgs onComplete, RunnableArgs onFailed) { var inventarioRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class); inventarioRESTConsumerService.retrieveArts(codDtip, codMgrp, codAnagForn) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(@NonNull Call> call, @NonNull Response> response) { analyzeAnswer(response, "loadDocumentoArts", onComplete, onFailed); } @Override - public void onFailure(@NonNull Call> call, @NonNull Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(@NonNull Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/EntityRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/EntityRESTConsumer.java index 7ecfc092..a17f3de3 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/EntityRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/EntityRESTConsumer.java @@ -2,6 +2,8 @@ package it.integry.integrywmsnative.core.rest.consumers; import android.util.Log; +import androidx.annotation.NonNull; + import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -13,11 +15,11 @@ import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.EntityBase; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.EsitoType; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.utility.UtilityGson; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -33,7 +35,7 @@ public class EntityRESTConsumer extends _BaseRESTConsumer { EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class); service .processEntity(entityToSave) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { if (response.isSuccessful()) { @@ -59,9 +61,8 @@ public class EntityRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - Log.e("EntityRESTConsumer", t.toString()); - tmpFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + tmpFailed.run(e); } }); @@ -76,7 +77,7 @@ public class EntityRESTConsumer extends _BaseRESTConsumer { EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class); Call>> request = service.processEntityList(singleTransaction, entitiesToSave); - request.enqueue(new Callback<>() { + request.enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { if (response.isSuccessful()) { @@ -112,9 +113,8 @@ public class EntityRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - Log.e("EntityRESTConsumer", t.toString()); - tmpFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + tmpFailed.run(e); } }); @@ -126,7 +126,7 @@ public class EntityRESTConsumer extends _BaseRESTConsumer { EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class); Call> request = service.processEntity(entityToSave); - request.enqueue(new Callback<>() { + request.enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { if (response.isSuccessful()) { @@ -136,7 +136,7 @@ public class EntityRESTConsumer extends _BaseRESTConsumer { Gson gson = UtilityGson.createObject(); List jsons = response.body().getEntityList(); - List newList = new ArrayList(); + List newList = new ArrayList<>(); if (jsons != null) { for (int i = 0; i < jsons.size(); i++) { @@ -163,9 +163,8 @@ public class EntityRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - Log.e("EntityRESTConsumer", t.toString()); - callback.onFailed(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + callback.onFailed(e); } }); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GestSetupRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GestSetupRESTConsumer.java index fcd030f3..3fc1848e 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GestSetupRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GestSetupRESTConsumer.java @@ -1,6 +1,6 @@ package it.integry.integrywmsnative.core.rest.consumers; -import android.util.Log; +import androidx.annotation.NonNull; import java.util.List; import java.util.stream.Collectors; @@ -10,12 +10,11 @@ import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.StbGestSetup; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.GestSetupDTO; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.settings.StbGestSetupReader; -import it.integry.integrywmsnative.core.utility.UtilityLogger; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -25,17 +24,15 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer { GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class); service.getGestSetupValue(gestName, sectionName, keySection) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "GestSetup", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - Log.e("GestSetup", t.toString()); - // UtilityLogger.errorMe(new Exception(t)); - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); } @@ -52,17 +49,15 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer { public void getValue(String gestName, String sectionName, String keySection, String codMdep, RunnableArgs onComplete, RunnableArgs onFailed) { GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class); - service.getGestSetupValue(gestName, sectionName, keySection, codMdep).enqueue(new Callback>() { + service.getGestSetupValue(gestName, sectionName, keySection, codMdep).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "GestSetup", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - Log.e("PrintCollo", t.toString()); - UtilityLogger.error(new Exception(t)); - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); } @@ -82,7 +77,7 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer { var stbGestSetups = stbGestSetupList.stream().map(x -> (StbGestSetup) x).collect(Collectors.toList()); GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class); - service.getGestSetupValues(codMdep, stbGestSetups).enqueue(new Callback<>() { + service.getGestSetupValues(codMdep, stbGestSetups).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "GestSetup", data -> { @@ -100,9 +95,8 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - UtilityLogger.error(new Exception(t)); - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GiacenzaRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GiacenzaRESTConsumer.java index 0541f82c..3be25f19 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GiacenzaRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GiacenzaRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; + import com.annimon.stream.Optional; import com.annimon.stream.Stream; @@ -13,13 +15,13 @@ import it.integry.integrywmsnative.core.model.MtbAart; import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.model.MvwSitArtUdcDetInventario; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.giacenza.InstantItemSituationIncomingItemDto; import it.integry.integrywmsnative.core.rest.model.giacenza.InstantItemSituationResponseDto; import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.dto.ArtsInGiacenzaDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -34,7 +36,7 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer { public void getGiacenzeInPosizione(MtbDepoPosizione posizione, RunnableArgs> onComplete, RunnableArgs onFailed) { GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class); - giacenzaRESTConsumerService.retrieveAvailableItems(posizione.getPosizione()).enqueue(new Callback<>() { + giacenzaRESTConsumerService.retrieveAvailableItems(posizione.getPosizione()).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getGiacenzeInPosizione", inventarioList -> { @@ -68,15 +70,15 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } public void getGiacenzeInPosizione(List posizioni, boolean withTestataCollo, RunnableArgs> onComplete, RunnableArgs onFailed) { GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class); - giacenzaRESTConsumerService.retrieveAvailableItems(posizioni, withTestataCollo).enqueue(new Callback<>() { + giacenzaRESTConsumerService.retrieveAvailableItems(posizioni, withTestataCollo).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getGiacenzeInPosizione", inventarioList -> { @@ -110,8 +112,8 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -122,7 +124,7 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer { UtilityString.isNullOrEmpty(partitaMag) ? giacenzaRESTConsumerService.retrieveAvailableItemsByArt(codMart) : giacenzaRESTConsumerService.retrieveAvailableItemsByArt(codMart, partitaMag); - serviceRESTResponseCall.enqueue(new Callback<>() { + serviceRESTResponseCall.enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getGiacenzeByArticolo", inventarioList -> { @@ -153,8 +155,8 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -164,7 +166,7 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer { GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class); giacenzaRESTConsumerService.retrieveInstantItemSituation(codMdep, codMart, partitaMag, codJcom) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "getInstantItemSituation", data -> { @@ -174,8 +176,8 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumer.java index 10fb6f71..0aa40012 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumer.java @@ -9,12 +9,12 @@ import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.MtbInvent; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.inventario.InsertInventarioRequestDTO; import it.integry.integrywmsnative.core.rest.model.inventario.RetrieveInventarioArtsResponseDTO; import it.integry.integrywmsnative.core.rest.model.inventario.RetrieveInventarioResponseDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -24,15 +24,15 @@ public class InventarioRESTConsumer extends _BaseRESTConsumer { public void loadInventario(long inventoryId, RunnableArgs onComplete, RunnableArgs onFailed) { var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class); inventarioRESTConsumerService.retrieve(inventoryId) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(@NonNull Call> call, @NonNull Response> response) { analyzeAnswer(response, "loadInventario", onComplete, onFailed); } @Override - public void onFailure(@NonNull Call> call, @NonNull Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(@NonNull Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -41,15 +41,15 @@ public class InventarioRESTConsumer extends _BaseRESTConsumer { public void loadInventarioArts(long inventoryId, RunnableArgs onComplete, RunnableArgs onFailed) { var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class); inventarioRESTConsumerService.retrieveArts(inventoryId) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(@NonNull Call> call, @NonNull Response> response) { analyzeAnswer(response, "loadInventarioArts", onComplete, onFailed); } @Override - public void onFailure(@NonNull Call> call, @NonNull Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(@NonNull Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -73,15 +73,15 @@ public class InventarioRESTConsumer extends _BaseRESTConsumer { var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class, 300); inventarioRESTConsumerService .insert(inventarioToInsert.getIdInventario(), request) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "insertInventario", ignored -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoAutomaticoRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoAutomaticoRESTConsumer.java index 27807571..5d0cc52f 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoAutomaticoRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoAutomaticoRESTConsumer.java @@ -1,15 +1,17 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; + import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.magazzino_automatico.MagazzinoAutomaticoPickItemsRequestDTO; import it.integry.integrywmsnative.core.rest.model.magazzino_automatico.MagazzinoAutomaticoPutItemsRequestDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -18,15 +20,15 @@ public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer { public void pickItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPickItemsRequestDTO magazzinoAutomaticoPickItemsRequestDTO, Runnable onComplete, RunnableArgs onFailed) { MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = RESTBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class); magazzinoAutomaticoRESTConsumerService.pickItems(posizione.getPosizione(), magazzinoAutomaticoPickItemsRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "magazzino-automatico/pickItems", data -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -36,15 +38,15 @@ public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer { public void putItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPutItemsRequestDTO magazzinoAutomaticoPutItemsRequestDTO, Runnable onComplete, RunnableArgs onFailed) { MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = RESTBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class); magazzinoAutomaticoRESTConsumerService.putItems(posizione.getPosizione(), magazzinoAutomaticoPutItemsRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "magazzino-automatico/putItems", data -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoBufferRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoBufferRESTConsumer.java index 5ba6535c..98f4f3e9 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoBufferRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoBufferRESTConsumer.java @@ -1,15 +1,17 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; + import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.magazzino_buffer.MagazzinoBufferVersamentoMaterialeCloseRequestDTO; import it.integry.integrywmsnative.core.rest.model.magazzino_buffer.MagazzinoBufferVersamentoMaterialeRequestDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -18,15 +20,15 @@ public class MagazzinoBufferRESTConsumer extends _BaseRESTConsumer { public void isVersamentoStarted(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeRequestDTO magazzinoBufferVersamentoMaterialeRequestDTO, RunnableArgs onComplete, RunnableArgs onFailed) { MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = RESTBuilder.getService(MagazzinoBufferRESTConsumerService.class); magazzinoBufferRESTConsumerService.isVersamentoStarted(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "magazzino-buffer/isVersamentoStarted", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -34,15 +36,15 @@ public class MagazzinoBufferRESTConsumer extends _BaseRESTConsumer { public void startVersamentoMateriale(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeRequestDTO magazzinoBufferVersamentoMaterialeRequestDTO, Runnable onComplete, RunnableArgs onFailed) { MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = RESTBuilder.getService(MagazzinoBufferRESTConsumerService.class); magazzinoBufferRESTConsumerService.startVersamentoMateriale(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "magazzino-buffer/startVersamentoMateriale", data -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -50,15 +52,15 @@ public class MagazzinoBufferRESTConsumer extends _BaseRESTConsumer { public void endVersamentoMateriale(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeCloseRequestDTO magazzinoBufferVersamentoMaterialeCloseRequestDTO, Runnable onComplete, RunnableArgs onFailed) { MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = RESTBuilder.getService(MagazzinoBufferRESTConsumerService.class); magazzinoBufferRESTConsumerService.endVersamentoMateriale(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeCloseRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "magazzino-buffer/endVersamentoMateriale", data -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoRESTConsumer.java index 602ce4b0..fb0b7ef6 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MagazzinoRESTConsumer.java @@ -9,14 +9,13 @@ import java.util.concurrent.ExecutorService; import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; -import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbPartitaMag; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -33,15 +32,15 @@ public class MagazzinoRESTConsumer extends _BaseRESTConsumer { public void saveTerminalinoWMS(SaveDTO saveDTO, Runnable onComplete, RunnableArgs onFailed) { MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class); service.saveTerminalinoWMS(saveDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "saveTerminalinoWMS", data -> onComplete.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -69,15 +68,15 @@ public class MagazzinoRESTConsumer extends _BaseRESTConsumer { public void retrieveAllPartitaMag(List codMarts, Date dataScad, RunnableArgs> onComplete, RunnableArgs onFailed) { MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class); service.retrieveAllPartitaMag(codMarts, UtilityDate.formatDate(dataScad, UtilityDate.COMMONS_DATE_FORMATS.YMD_SLASH)) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(@NonNull Call>> call, @NonNull Response>> response) { analyzeAnswer(response, "retrieveAllPartitaMag", onComplete, onFailed); } @Override - public void onFailure(@NonNull Call>> call, @NonNull Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(@NonNull Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MesRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MesRESTConsumer.java index 53c70d65..eb394b2a 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MesRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/MesRESTConsumer.java @@ -1,10 +1,11 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; + import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.ArrayList; -import java.util.Date; import java.util.List; import javax.inject.Singleton; @@ -12,12 +13,11 @@ import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.JtbFasi; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.utility.UtilityDB; -import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -33,15 +33,15 @@ public class MesRESTConsumer extends _BaseRESTConsumer { MesRESTConsumerService mesRESTConsumerService = RESTBuilder.getService(MesRESTConsumerService.class); mesRESTConsumerService.getOrdiniLavorazioneMateriale(codJfas, idMateriale) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getOrdiniLavorazioneMateriale", (m) -> onComplete.run(response.body().getDto()), onFailed); } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -50,15 +50,15 @@ public class MesRESTConsumer extends _BaseRESTConsumer { MesRESTConsumerService mesRESTConsumerService = RESTBuilder.getService(MesRESTConsumerService.class); mesRESTConsumerService.getOrdiniLavorazione(null, flagEvaso, codJfas, codAnag) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getOrdiniLavorazione", (m) -> onComplete.run(response.body().getDto()), onFailed); } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -68,15 +68,15 @@ public class MesRESTConsumer extends _BaseRESTConsumer { MesRESTConsumerService mesRESTConsumerService = RESTBuilder.getService(MesRESTConsumerService.class); mesRESTConsumerService.getOrdiniLavorazione(flagEvaso) - .enqueue(new Callback>>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getOrdiniLavorazione", (m) -> onComplete.run(response.body().getDto()), onFailed); } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/OrdiniRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/OrdiniRESTConsumer.java index 03262225..c3b17aa5 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/OrdiniRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/OrdiniRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; + import com.annimon.stream.Optional; import com.annimon.stream.Stream; import com.google.gson.reflect.TypeToken; @@ -21,17 +23,16 @@ import it.integry.integrywmsnative.core.model.MtbPartitaMag; import it.integry.integrywmsnative.core.model.OrdineInevasoDTO; import it.integry.integrywmsnative.core.model.secondary.GestioneEnum; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.GetPickingListDTO; import it.integry.integrywmsnative.core.rest.model.OrdineUscitaInevasoDTO; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.SitArtOrdDTO; import it.integry.integrywmsnative.core.utility.UtilityDB; -import it.integry.integrywmsnative.core.utility.UtilityLogger; import it.integry.integrywmsnative.core.utility.UtilityQuery; import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.gest.spedizione.model.PickingObjectDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -49,7 +50,7 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer { OrdiniRESTConsumerService service = RESTBuilder.getService(OrdiniRESTConsumerService.class, 90); service .getSuggestedPickingList(codMdep, sitArtOrdList) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getSuggestedPickingList", pickingObjects -> { @@ -109,8 +110,8 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -126,7 +127,7 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer { OrdiniRESTConsumerService service = RESTBuilder.getService(OrdiniRESTConsumerService.class); service.getOrdiniInevasi(codMdep, gestione.getText()) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getOrdiniInevasi", responseDtoList -> { @@ -139,9 +140,8 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - Logger.e(t, "Errore durante il caricamento degli ordini di lavorazione"); - if (onFailed != null) onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + if (onFailed != null) onFailed.run(e); } }); } @@ -158,7 +158,7 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer { OrdiniRESTConsumerService service = RESTBuilder.getService(OrdiniRESTConsumerService.class, 90); - service.getArticoliFromOrdini(codMdep, getPickingListDTOs).enqueue(new Callback<>() { + service.getArticoliFromOrdini(codMdep, getPickingListDTOs).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "retrieveListaArticoliFromOrdiniUscita", sitArtOrds -> { @@ -173,9 +173,8 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - UtilityLogger.error(new Exception(t)); - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PVOrdiniAcquistoRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PVOrdiniAcquistoRESTConsumer.java index 930353f6..a095df0e 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PVOrdiniAcquistoRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PVOrdiniAcquistoRESTConsumer.java @@ -2,6 +2,8 @@ package it.integry.integrywmsnative.core.rest.consumers; import android.util.Log; +import androidx.annotation.NonNull; + import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; @@ -14,14 +16,13 @@ import it.integry.integrywmsnative.core.data_store.db.entity.Ordine; import it.integry.integrywmsnative.core.data_store.db.view_model.OrdiniAcquistoGrigliaDTO; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.utility.UtilityDate; -import it.integry.integrywmsnative.core.utility.UtilityLogger; import it.integry.integrywmsnative.gest.contab_doc_interni.dto.ArtDTO; import it.integry.integrywmsnative.gest.contab_doc_interni.dto.OrdineDTO; import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -36,7 +37,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer { public void retrieveArticoli(String codAlis, String codMdep, RunnableArgs onSuccess, RunnableArgs onFailed) { PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300); ordiniARestService.retrieveArticoli(codAlis, codMdep, null) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { var startTime = new Date().getTime(); @@ -47,8 +48,8 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -56,7 +57,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer { public void retrieveArticolo(String codAlis, String codMdep, String barcode, RunnableArgs onSuccess, RunnableArgs onFailed) { PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300); ordiniARestService.retrieveArticoli(codAlis, codMdep, barcode) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { var startTime = new Date().getTime(); @@ -67,8 +68,8 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -91,7 +92,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer { PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300); ordiniARestService.save(codMdep, saveDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { var startTime = new Date().getTime(); @@ -113,10 +114,8 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - Log.e("saveOrdine", t.toString()); - UtilityLogger.error(new Exception(t)); - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PosizioniRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PosizioniRESTConsumer.java index 25cf1d01..ceb4d905 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PosizioniRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PosizioniRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; + import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; @@ -12,10 +14,10 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.utility.UtilityDB; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -31,7 +33,7 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer { String codMdep = null; PosizioniRESTConsumerService posizioniRESTConsumerService = RESTBuilder.getService(PosizioniRESTConsumerService.class); - posizioniRESTConsumerService.getAvailablePosizioni(codMdep).enqueue(new Callback<>() { + posizioniRESTConsumerService.getAvailablePosizioni(codMdep).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getAvailablePosizioni", (m) -> { @@ -40,8 +42,8 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumer.java index b7822bf8..9cacc18c 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumer.java @@ -1,6 +1,6 @@ package it.integry.integrywmsnative.core.rest.consumers; -import android.util.Log; +import androidx.annotation.NonNull; import com.annimon.stream.Stream; @@ -10,20 +10,18 @@ import java.util.List; import javax.inject.Singleton; import it.integry.integrywmsnative.BuildConfig; -import it.integry.integrywmsnative.core.exception.NoPrintersFoundException; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.report.ReportType; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.JasperDTO; import it.integry.integrywmsnative.core.rest.model.JasperPairDTO; import it.integry.integrywmsnative.core.rest.model.ReportTypeDTO; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; -import it.integry.integrywmsnative.core.utility.UtilityLogger; import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.gest.spedizione.model.PrintOrderCloseDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -40,7 +38,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { String printerTypeStr = printerType != null ? printerType.toString() : null; PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class); - printerService.getAvailablePrinters(codMdep, printerTypeStr).enqueue(new Callback<>() { + printerService.getAvailablePrinters(codMdep, printerTypeStr).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "GetAvailablePrinters", printerList -> { @@ -50,10 +48,8 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - Log.e("GetAvailablePrinters", t.toString()); - UtilityLogger.error(new Exception(t)); - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -68,7 +64,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class); printerService .printCollo(testataColloToPrint) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "printCollo", data -> { @@ -77,10 +73,8 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - if (t.getMessage().contains("Printer not found")) { - onFailed.run(new NoPrintersFoundException()); - } else onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -101,7 +95,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class); printerService .processPrintReport(printerName, quantity, jasperDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "printReport", data -> { @@ -110,10 +104,8 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - if (t.getMessage().contains("Printer not found")) { - onFailed.run(new NoPrintersFoundException()); - } else onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -131,7 +123,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class); printerService .printReportType(reportTypeDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "printReportType", data -> { @@ -140,10 +132,8 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - if (t.getMessage().contains("Printer not found")) { - onFailed.run(new NoPrintersFoundException()); - } else onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -164,7 +154,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class, 240); Call> callable = printerService.printClosedOrders(codMdep, dto); - callable.enqueue(new Callback<>() { + callable.enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "printCollo", data -> { @@ -173,10 +163,8 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - if (t.getMessage().contains("Printer not found")) { - onFailed.run(new NoPrintersFoundException()); - } else onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumer.java index 0b802557..34905843 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.core.rest.consumers; +import androidx.annotation.NonNull; + import com.annimon.stream.Stream; import com.google.gson.JsonObject; @@ -9,10 +11,10 @@ import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.gest.prod_linee_produzione.dto.ProdLineStatusDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -21,7 +23,7 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer { public void avviaLineaDiProduzione(String codJfas, Integer hrNum, Runnable onComplete, RunnableArgs onFailed) { ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class); Call> callable = restService.avviaLineaDiProduzione(codJfas, hrNum); - callable.enqueue(new Callback<>() { + callable.enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "avviaLineaDiProduzione", data -> { @@ -30,8 +32,8 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -39,7 +41,7 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer { public void arrestaLineaDiProduzione(String codJfas, Runnable onComplete, RunnableArgs onFailed) { ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class); Call> callable = restService.arrestaLineaDiProduzione(codJfas); - callable.enqueue(new Callback<>() { + callable.enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "arrestaLineaDiProduzione", data -> { @@ -48,8 +50,8 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -57,7 +59,7 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer { public void avviaProduzioneArticoloSuLinea(String codJfas, String codMart, String partitaMag, Runnable onComplete, RunnableArgs onFailed) { ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class, 300); Call> callable = restService.avviaProduzioneArticoloSuLinea(codJfas, codMart, partitaMag); - callable.enqueue(new Callback<>() { + callable.enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "avviaProduzioneArticoloSuLinea", data -> { @@ -66,8 +68,8 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -75,15 +77,15 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer { public void getStatoLinee(String codMdep, RunnableArgs> onComplete, RunnableArgs onFailed) { ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class); Call>> callable = restService.getStatoLinee(codMdep); - callable.enqueue(new Callback<>() { + callable.enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getStatoLinee", onComplete::run, onFailed); } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -92,7 +94,7 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer { public void getLineDetails(ProdLineStatusDTO lineaProd, RunnableArgs onComplete, RunnableArgs onFailed) { ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class); Call>> callable = restService.getStatoLinee(lineaProd.getCodMdepLav()); - callable.enqueue(new Callback<>() { + callable.enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getLineDetails", (lines) -> { @@ -102,8 +104,8 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProduzioneRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProduzioneRESTConsumer.java index 0efd676c..ae7f2e55 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProduzioneRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProduzioneRESTConsumer.java @@ -1,15 +1,15 @@ package it.integry.integrywmsnative.core.rest.consumers; -import com.orhanobut.logger.Logger; +import androidx.annotation.NonNull; import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.produzione.CaricoProdFinDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -22,7 +22,7 @@ public class ProduzioneRESTConsumer extends _BaseRESTConsumer{ ProduzioneRESTConsumerService service = RESTBuilder.getService(ProduzioneRESTConsumerService.class); service.caricoProdFin(caricoProdFin) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "caricoProdFin", Void -> onComplete.run(), ex -> { @@ -31,9 +31,8 @@ public class ProduzioneRESTConsumer extends _BaseRESTConsumer{ } @Override - public void onFailure(Call> call, Throwable t) { - Logger.e(t, "caricoProdFin"); - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/SystemRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/SystemRESTConsumer.java index da5fd31c..f0f5db5f 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/SystemRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/SystemRESTConsumer.java @@ -3,24 +3,24 @@ package it.integry.integrywmsnative.core.rest.consumers; import android.text.TextUtils; import android.util.Log; +import androidx.annotation.NonNull; + import com.google.gson.Gson; -import com.orhanobut.logger.Logger; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.lang.reflect.Type; -import java.net.ConnectException; import java.util.List; import javax.inject.Singleton; import it.integry.integrywmsnative.BuildConfig; import it.integry.integrywmsnative.core.CommonConst; -import it.integry.integrywmsnative.core.exception.InvalidConnectionException; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO; import it.integry.integrywmsnative.core.rest.model.MailRequestDTO; import it.integry.integrywmsnative.core.rest.model.NativeSqlRequestDTO; @@ -31,7 +31,6 @@ import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.utility.UtilityGson; import it.integry.integrywmsnative.core.utility.UtilityString; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -41,15 +40,15 @@ public class SystemRESTConsumer extends _BaseRESTConsumer { public void retrieveUpdatesInfo(final RunnableArgs onSuccess, final RunnableArgs onFailed) { SystemRESTConsumerService systemRESTConsumerService = RESTBuilder.getService(SystemRESTConsumerService.class); systemRESTConsumerService.retrieveUpdatesInfo() - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call call, Response response) { analyzeAnswerGeneric(response, "updates", onSuccess, onFailed); } @Override - public void onFailure(Call call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -61,15 +60,15 @@ public class SystemRESTConsumer extends _BaseRESTConsumer { SystemRESTConsumerService systemRESTConsumerService = RESTBuilder.getService(SystemRESTConsumerService.class); systemRESTConsumerService.registerDevice(registerDeviceRequestDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "device/register", Void -> onSuccess.run(), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); @@ -82,7 +81,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer { SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class); service .processSql(nativeSqlDTO) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "ProcessSql", o -> { @@ -100,13 +99,8 @@ public class SystemRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - Logger.e(t, "ProcessSQL"); - - if (t instanceof ConnectException) - onFailed.run(new InvalidConnectionException(RESTBuilder.getDefaultHost(), RESTBuilder.getDefaultPort(), t)); - else - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -114,16 +108,15 @@ public class SystemRESTConsumer extends _BaseRESTConsumer { public void getAvailableCodMdeps(final RunnableArgs> onSuccess, RunnableArgs onFailed) { SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class); - service.getAvailableCodMdeps().enqueue(new Callback<>() { + service.getAvailableCodMdeps().enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "CodMdepsAvailable", onSuccess, onFailed); } @Override - public void onFailure(Call>> call, final Throwable t) { - Log.e("CodMdepsAvailable", t.toString()); - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -161,16 +154,16 @@ public class SystemRESTConsumer extends _BaseRESTConsumer { public void sendMail(MailRequestDTO mailDTO, Runnable onComplete, RunnableArgs onFailed) { SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class); - service.sendMail(mailDTO).enqueue(new Callback<>() { + service.sendMail(mailDTO).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { if (onComplete != null) onComplete.run(); } @Override - public void onFailure(Call> call, Throwable t) { + public void onFailure(Call> call, @NonNull final Exception e) { if (onFailed != null) { - onFailed.run(new Exception(t)); + onFailed.run(e); } } }); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/handler/ManagedErrorCallback.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/handler/ManagedErrorCallback.java new file mode 100644 index 00000000..a2fe946b --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/handler/ManagedErrorCallback.java @@ -0,0 +1,27 @@ +package it.integry.integrywmsnative.core.rest.handler; + +import androidx.annotation.NonNull; + +import java.net.ConnectException; + +import it.integry.integrywmsnative.core.exception.InvalidConnectionException; +import it.integry.integrywmsnative.core.exception.NoPrintersFoundException; +import it.integry.integrywmsnative.core.rest.RESTBuilder; +import retrofit2.Call; +import retrofit2.Callback; + +public abstract class ManagedErrorCallback implements Callback { + + @Override + public void onFailure(Call call, Throwable t) { + if (t instanceof ConnectException connectException) { + t = new InvalidConnectionException(RESTBuilder.getDefaultHost(), RESTBuilder.getDefaultPort(), connectException); + } else if (t.getMessage() != null && t.getMessage().contains("Printer not found")) { + t = new NoPrintersFoundException(); + } + + onFailure(call, (Exception) t); + } + + public abstract void onFailure(Call call, @NonNull final Exception e); +} diff --git a/app/src/main/java/it/integry/integrywmsnative/core/settings/Stash.java b/app/src/main/java/it/integry/integrywmsnative/core/settings/Stash.java index 9b9dd969..7aeb8cd7 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/settings/Stash.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/settings/Stash.java @@ -219,7 +219,7 @@ public class Stash { Type type = new GenericType(tClass); return (ArrayList) gson.fromJson(data, type); } - return new ArrayList(); + return new ArrayList<>(); } //clear single value diff --git a/app/src/main/java/it/integry/integrywmsnative/core/utility/UtilityLiveData.java b/app/src/main/java/it/integry/integrywmsnative/core/utility/UtilityLiveData.java index b84a6faa..3afcd18b 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/utility/UtilityLiveData.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/utility/UtilityLiveData.java @@ -6,7 +6,7 @@ import androidx.lifecycle.Observer; public class UtilityLiveData { public static void observeOnce(final LiveData liveData, final Observer observer) { - liveData.observeForever(new Observer() { + liveData.observeForever(new Observer<>() { @Override public void onChanged(T t) { liveData.removeObserver(this); 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 a273c07f..fdd64cfa 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 @@ -15,7 +15,7 @@ import java.util.regex.Pattern; */ public class UtilityString { - private static final Map DATE_FORMAT_REGEXPS = new HashMap() {{ + private static final Map DATE_FORMAT_REGEXPS = new HashMap<>() {{ //----------------------------------------------------------------------------------------- //giorno-mese-giorno diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_bolla_elenco/rest/BolleAccettazioneRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_bolla_elenco/rest/BolleAccettazioneRESTConsumer.java index 7bae2e9f..b34c61e7 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_bolla_elenco/rest/BolleAccettazioneRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_bolla_elenco/rest/BolleAccettazioneRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest; +import androidx.annotation.NonNull; + import java.util.List; import javax.inject.Singleton; @@ -7,6 +9,7 @@ import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.RetrieveElencoArticoliAccettazioneBollaRequestDTO; import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.RetrieveElencoArticoliAccettazioneBollaResponseDTO; @@ -14,7 +17,6 @@ import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.Retri import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.SitBollaAccettazioneDTO; import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.TestataBollaAccettazioneDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -24,15 +26,15 @@ public class BolleAccettazioneRESTConsumer extends _BaseRESTConsumer { public void retrieveBolleDaAccettare(RunnableArgs> onComplete, RunnableArgs onFailed) { BolleAccettazioneRESTConsumerService service = RESTBuilder.getService(BolleAccettazioneRESTConsumerService.class); service.retrieveElencoBolle() - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "retrieveBolleDaAccettare", data -> onComplete.run(data.getBolleDaAccettare()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -44,15 +46,15 @@ public class BolleAccettazioneRESTConsumer extends _BaseRESTConsumer { .setBolle(bolle); service.retrievePickingListBolle(request) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "retrievePickingListBolle", data -> onComplete.run(data.getSitArticoli()), onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_bolla_picking/rest/AccettazioneBollaPickingRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_bolla_picking/rest/AccettazioneBollaPickingRESTConsumer.java index 709e3d94..a0c9b3d4 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_bolla_picking/rest/AccettazioneBollaPickingRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_bolla_picking/rest/AccettazioneBollaPickingRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.gest.accettazione_bolla_picking.rest; +import androidx.annotation.NonNull; + import java.util.ArrayList; import java.util.List; @@ -7,15 +9,15 @@ import javax.inject.Inject; import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; +import it.integry.integrywmsnative.core.model.dto.AlreadyRegisteredUDCDTO; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.TestataBollaAccettazioneDTO; -import it.integry.integrywmsnative.core.model.dto.AlreadyRegisteredUDCDTO; import it.integry.integrywmsnative.gest.accettazione_bolla_picking.dto.RetrieveAlreadyRegisteredULAccettazioneBollaRequestDTO; import it.integry.integrywmsnative.gest.accettazione_bolla_picking.dto.RetrieveAlreadyRegisteredULAccettazioneBollaResponseDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -33,7 +35,7 @@ public class AccettazioneBollaPickingRESTConsumer extends _BaseRESTConsumer { .setBolle(bolle); service.retrieveAlreadyRegisteredUDC(request) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "retrieveAlreadyRegisteredUDC", @@ -42,8 +44,8 @@ public class AccettazioneBollaPickingRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_ordini_elenco/rest/OrdiniAccettazioneRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_ordini_elenco/rest/OrdiniAccettazioneRESTConsumer.java index 374ad9f5..d2ecec03 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_ordini_elenco/rest/OrdiniAccettazioneRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_ordini_elenco/rest/OrdiniAccettazioneRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.gest.accettazione_ordini_elenco.rest; +import androidx.annotation.NonNull; + import com.annimon.stream.Stream; import java.util.List; @@ -9,13 +11,12 @@ import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; -import it.integry.integrywmsnative.core.utility.UtilityLogger; import it.integry.integrywmsnative.gest.accettazione_ordini_elenco.dto.GetPickingListAccettazioneDTO; import it.integry.integrywmsnative.gest.accettazione_ordini_elenco.dto.OrdineAccettazioneInevasoDTO; import it.integry.integrywmsnative.gest.accettazione_ordini_elenco.dto.SitArtOrdDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -24,15 +25,15 @@ public class OrdiniAccettazioneRESTConsumer extends _BaseRESTConsumer { public void getOrdiniInevasi(String codMdep, RunnableArgs> onComplete, RunnableArgs onFailed) { OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class); - service.listOrdiniInevasi(codMdep, "A").enqueue(new Callback<>() { + service.listOrdiniInevasi(codMdep, "A").enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getOrdiniInevasi", onComplete, onFailed); } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -47,16 +48,15 @@ public class OrdiniAccettazioneRESTConsumer extends _BaseRESTConsumer { .toList(); OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class); - service.getArticoliFromOrdiniAccettazione(getPickingListDTOs).enqueue(new Callback>>() { + service.getArticoliFromOrdiniAccettazione(getPickingListDTOs).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "retrieveListaArticoliFromOrdiniAccettazione", onComplete, onFailed); } @Override - public void onFailure(Call>> call, Throwable t) { - UtilityLogger.error(new Exception(t)); - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_ordini_picking/rest/AccettazioneOrdiniPickingRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_ordini_picking/rest/AccettazioneOrdiniPickingRESTConsumer.java index 1ec0f5ee..5ba8e603 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_ordini_picking/rest/AccettazioneOrdiniPickingRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_ordini_picking/rest/AccettazioneOrdiniPickingRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.gest.accettazione_ordini_picking.rest; +import androidx.annotation.NonNull; + import java.util.ArrayList; import java.util.List; @@ -11,12 +13,12 @@ import it.integry.integrywmsnative.core.model.dto.AlreadyRegisteredUDCDTO; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.gest.accettazione_ordini_elenco.dto.OrdineAccettazioneInevasoDTO; import it.integry.integrywmsnative.gest.accettazione_ordini_picking.dto.RetrieveAlreadyRegisteredULAccettazioneOrdineRequestDTO; import it.integry.integrywmsnative.gest.accettazione_ordini_picking.dto.RetrieveAlreadyRegisteredULAccettazioneOrdineResponseDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -36,7 +38,7 @@ public class AccettazioneOrdiniPickingRESTConsumer extends _BaseRESTConsumer { .setOrdini(ordiniToShow); service.retrieveAlreadyRegisteredUDC(request) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "retrieveAlreadyRegisteredUDC", @@ -45,8 +47,8 @@ public class AccettazioneOrdiniPickingRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/contab_doc_interni/rest/DocInterniRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/contab_doc_interni/rest/DocInterniRESTConsumer.java index d9bb33a5..b550275f 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/contab_doc_interni/rest/DocInterniRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/contab_doc_interni/rest/DocInterniRESTConsumer.java @@ -6,17 +6,16 @@ import java.util.List; import javax.inject.Singleton; -import it.integry.integrywmsnative.core.exception.RestException; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers.MagazzinoRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO; import it.integry.integrywmsnative.gest.contab_doc_interni.dto.RetrieveLottiDTO; import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -30,15 +29,15 @@ public class DocInterniRESTConsumer extends _BaseRESTConsumer { public void getDocInterniSetup(RunnableArgs onComplete, RunnableArgs onFailed) { DocInterniRESTConsumerService service = RESTBuilder.getService(DocInterniRESTConsumerService.class); - service.getSetupDocInterni().enqueue(new Callback<>() { + service.getSetupDocInterni().enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "getSetupDocInterni", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - onFailed.run(new RestException(t.getMessage())); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -46,15 +45,15 @@ public class DocInterniRESTConsumer extends _BaseRESTConsumer { public void retrieveLotti(String codProd, RunnableArgs> onComplete, RunnableArgs onFailed) { DocInterniRESTConsumerService service = RESTBuilder.getService(DocInterniRESTConsumerService.class); service.retrieveLotti(codProd) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(@NonNull Call>> call, @NonNull Response>> response) { analyzeAnswer(response, "retrieveLotti", onComplete, onFailed); } @Override - public void onFailure(@NonNull Call>> call, @NonNull Throwable t) { - onFailed.run(new RestException(t.getMessage())); + public void onFailure(@NonNull Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/login/rest/LoginRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/login/rest/LoginRESTConsumer.java index 67a9070e..043ecf1a 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/login/rest/LoginRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/login/rest/LoginRESTConsumer.java @@ -1,6 +1,6 @@ package it.integry.integrywmsnative.gest.login.rest; -import android.util.Log; +import androidx.annotation.NonNull; import javax.inject.Singleton; @@ -8,12 +8,12 @@ import it.integry.integrywmsnative.core.CommonConst; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.gest.login.dto.LoginAziendaDTO; -import it.integry.integrywmsnative.gest.login.dto.LoginResponseDTO; import it.integry.integrywmsnative.gest.login.dto.LoginRequestDTO; +import it.integry.integrywmsnative.gest.login.dto.LoginResponseDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -27,16 +27,15 @@ public class LoginRESTConsumer extends _BaseRESTConsumer { int port = CommonConst.Login.Azienda.port; LoginRESTConsumerService service = RESTBuilder.getService(LoginRESTConsumerService.class, protocol, host, port, false, true); - service.loginAzienda(codAzienda).enqueue(new Callback<>() { + service.loginAzienda(codAzienda).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "LoginAzienda", onComplete, onFailed); } @Override - public void onFailure(Call> call, Throwable t) { - Log.e("LoginAzienda", t.toString()); - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -49,7 +48,7 @@ public class LoginRESTConsumer extends _BaseRESTConsumer { .setUsername(username) .setPassword(password); - service.login(loginRequestDTO).enqueue(new Callback<>() { + service.login(loginRequestDTO).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { @@ -57,9 +56,8 @@ public class LoginRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, final Throwable t) { - Log.e("Login", t.toString()); - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/ordini_uscita_elenco/rest/OrdiniUscitaElencoRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/ordini_uscita_elenco/rest/OrdiniUscitaElencoRESTConsumer.java index ecd3475f..48330288 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/ordini_uscita_elenco/rest/OrdiniUscitaElencoRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/ordini_uscita_elenco/rest/OrdiniUscitaElencoRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.gest.ordini_uscita_elenco.rest; +import androidx.annotation.NonNull; + import java.util.List; import javax.inject.Singleton; @@ -10,9 +12,9 @@ import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.secondary.GestioneEnum; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -27,7 +29,7 @@ public class OrdiniUscitaElencoRESTConsumer extends _BaseRESTConsumer { testataCollo.getGestione(), GestioneEnum.VENDITA.getText(), codMdep) - .enqueue(new Callback>>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getOrdiniFromCommessaCollo", (m) -> { @@ -36,8 +38,8 @@ public class OrdiniUscitaElencoRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_accettazione_ord_produzione/rest/ProdOrdineProduzioneRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_accettazione_ord_produzione/rest/ProdOrdineProduzioneRESTConsumer.java index eaaf8dec..79c6db62 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/prod_accettazione_ord_produzione/rest/ProdOrdineProduzioneRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_accettazione_ord_produzione/rest/ProdOrdineProduzioneRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione.rest; +import androidx.annotation.NonNull; + import com.annimon.stream.Stream; import java.util.List; @@ -9,14 +11,13 @@ import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; -import it.integry.integrywmsnative.core.utility.UtilityLogger; import it.integry.integrywmsnative.gest.accettazione_ordini_elenco.dto.GetPickingListAccettazioneDTO; import it.integry.integrywmsnative.gest.accettazione_ordini_elenco.dto.OrdineAccettazioneInevasoDTO; import it.integry.integrywmsnative.gest.accettazione_ordini_elenco.dto.SitArtOrdDTO; import it.integry.integrywmsnative.gest.accettazione_ordini_elenco.rest.OrdiniAccettazioneRESTConsumerService; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -24,15 +25,15 @@ public class ProdOrdineProduzioneRESTConsumer extends _BaseRESTConsumer { public void getOrdiniInevasi(String codMdep, RunnableArgs> onComplete, RunnableArgs onFailed) { OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class); - service.listOrdiniInevasi(codMdep, "P").enqueue(new Callback<>() { + service.listOrdiniInevasi(codMdep, "P").enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "getOrdiniInevasi", onComplete, onFailed); } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -47,16 +48,15 @@ public class ProdOrdineProduzioneRESTConsumer extends _BaseRESTConsumer { .toList(); OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class); - service.getArticoliFromOrdiniAccettazione(getPickingListDTOs).enqueue(new Callback<>() { + service.getArticoliFromOrdiniAccettazione(getPickingListDTOs).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { analyzeAnswer(response, "retrieveListaArticoliFromOrdiniProduzione", onComplete, onFailed); } @Override - public void onFailure(Call>> call, Throwable t) { - UtilityLogger.error(new Exception(t)); - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_fabbisogno_linee_prod/rest/ProdFabbisognoLineeProdRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_fabbisogno_linee_prod/rest/ProdFabbisognoLineeProdRESTConsumer.java index 8f54b725..805eb001 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/prod_fabbisogno_linee_prod/rest/ProdFabbisognoLineeProdRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_fabbisogno_linee_prod/rest/ProdFabbisognoLineeProdRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.rest; +import androidx.annotation.NonNull; + import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; @@ -11,15 +13,13 @@ import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.rest.RESTBuilder; -import it.integry.integrywmsnative.core.rest.consumers.MagazzinoBufferRESTConsumerService; import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.utility.UtilityDB; -import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.dto.ProdFabbisognoLineeProdDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -35,7 +35,7 @@ public class ProdFabbisognoLineeProdRESTConsumer extends _BaseRESTConsumer { public void loadFabbisogno(String numOrd, String codMdep, RunnableArgs> onComplete, RunnableArgs onFailed) { ProdFabbisognoLineeProdRESTConsumerService prodFabbisognoLineeProdRESTConsumerService = RESTBuilder.getService(ProdFabbisognoLineeProdRESTConsumerService.class); prodFabbisognoLineeProdRESTConsumerService.loadFabbisogno(numOrd, codMdep) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { @@ -43,8 +43,8 @@ public class ProdFabbisognoLineeProdRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - onFailed.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_rientro_merce/order_detail/ProdRientroMerceOrderDetailFragment.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_rientro_merce/order_detail/ProdRientroMerceOrderDetailFragment.java index e737c161..c990983b 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/prod_rientro_merce/order_detail/ProdRientroMerceOrderDetailFragment.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_rientro_merce/order_detail/ProdRientroMerceOrderDetailFragment.java @@ -360,15 +360,14 @@ public class ProdRientroMerceOrderDetailFragment extends BaseFragment implements public Drawable getOrderStatusIcon() { if (currentOrder.getValue() != null) { - switch (currentOrder.getValue().getStatoEnum()) { - case IN_CORSO: - return ContextCompat.getDrawable(requireActivity(), R.drawable.ic_play_circle_filled_24dp); - case PAUSA: - return ContextCompat.getDrawable(requireActivity(), R.drawable.ic_pause_circle_filled_24dp); - case PROGRAMMATO: - default: - return ContextCompat.getDrawable(requireActivity(), R.drawable.ic_clock_circle_outline_24dp); - } + return switch (currentOrder.getValue().getStatoEnum()) { + case IN_CORSO -> + ContextCompat.getDrawable(requireActivity(), R.drawable.ic_play_circle_filled_24dp); + case PAUSA -> + ContextCompat.getDrawable(requireActivity(), R.drawable.ic_pause_circle_filled_24dp); + default -> + ContextCompat.getDrawable(requireActivity(), R.drawable.ic_clock_circle_outline_24dp); + }; } else return ContextCompat.getDrawable(requireActivity(), R.drawable.ic_clock_circle_outline_24dp); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_rientro_merce/order_detail/rest/ProdRientroMerceOrderDetailRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_rientro_merce/order_detail/rest/ProdRientroMerceOrderDetailRESTConsumer.java index a722b1bc..60e83ad6 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/prod_rientro_merce/order_detail/rest/ProdRientroMerceOrderDetailRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_rientro_merce/order_detail/rest/ProdRientroMerceOrderDetailRESTConsumer.java @@ -1,10 +1,10 @@ package it.integry.integrywmsnative.gest.prod_rientro_merce.order_detail.rest; +import androidx.annotation.NonNull; import androidx.databinding.ObservableArrayList; import com.annimon.stream.Stream; import com.google.gson.reflect.TypeToken; -import com.orhanobut.logger.Logger; import java.lang.reflect.Type; import java.util.ArrayList; @@ -21,13 +21,13 @@ import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.utility.UtilityDB; import it.integry.integrywmsnative.core.utility.UtilityQuery; import it.integry.integrywmsnative.gest.prod_rientro_merce.order_detail.rest.dto.ImportColliDaProduzioneRequestDTO; import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -113,7 +113,7 @@ public class ProdRientroMerceOrderDetailRESTConsumer extends _BaseRESTConsumer { ProdRientroMerceOrderDetailRESTConsumerService service = RESTBuilder.getService(ProdRientroMerceOrderDetailRESTConsumerService.class); service.importColliDaProduzione(Collections.singletonList(importColliDaProduzioneRequestDTO)) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswerList(response, "importColliDaProduzione", mtbColt -> { @@ -124,9 +124,8 @@ public class ProdRientroMerceOrderDetailRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - Logger.e(t, "importColliDaProduzione"); - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } @@ -134,7 +133,7 @@ public class ProdRientroMerceOrderDetailRESTConsumer extends _BaseRESTConsumer { public void deleteColloDaProduzione(MtbColt mtbColtToDelete, Runnable onComplete, RunnableArgs onFailed) { ProdRientroMerceOrderDetailRESTConsumerService service = RESTBuilder.getService(ProdRientroMerceOrderDetailRESTConsumerService.class); - service.deleteColloDaProduzione(mtbColtToDelete).enqueue(new Callback>() { + service.deleteColloDaProduzione(mtbColtToDelete).enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "deleteColloDaProduzione", mtbColt -> { @@ -145,9 +144,8 @@ public class ProdRientroMerceOrderDetailRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call> call, Throwable t) { - Logger.e(t, "deleteColloDaProduzione"); - onFailed.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onFailed.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/rest/RettificaGiacenzeRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/rest/RettificaGiacenzeRESTConsumer.java index 3ed3faa7..98f0ea06 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/rest/RettificaGiacenzeRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/rest/RettificaGiacenzeRESTConsumer.java @@ -1,5 +1,7 @@ package it.integry.integrywmsnative.gest.rettifica_giacenze.rest; +import androidx.annotation.NonNull; + import com.annimon.stream.Stream; import com.google.gson.reflect.TypeToken; @@ -16,6 +18,7 @@ import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; +import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback; import it.integry.integrywmsnative.core.rest.model.SaveDocFromPickingRequestDTO; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO; @@ -24,7 +27,6 @@ import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.SearchArticoloByB import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.SearchArticoloByCodArtFornOrDescrizioneRequestDTO; import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.SearchArticoloByCodArtFornOrDescrizioneResponseDTO; import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; @Singleton @@ -53,7 +55,7 @@ public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer { service.searchByCodArtFornOrDescrizione(new SearchArticoloByCodArtFornOrDescrizioneRequestDTO() .setCodAlis(codAlis) .setCodArtFornOrDescrizione(codArtForOrDescr)) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { @@ -61,8 +63,8 @@ public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - onError.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onError.run(e); } }); @@ -75,7 +77,7 @@ public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer { final RettificaGiacenzeRESTConsumerService service = RESTBuilder.getService(RettificaGiacenzeRESTConsumerService.class); service.searchByCodMartOrBarcode(new SearchArticoloByBarcodeOrCodMartRequestDTO() .setCodMartOrBarcode(codMartOrBarcodeOrDescr)) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call>> call, Response>> response) { @@ -96,8 +98,8 @@ public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer { } @Override - public void onFailure(Call>> call, Throwable t) { - onError.run(new Exception(t)); + public void onFailure(Call>> call, @NonNull final Exception e) { + onError.run(e); } }); } @@ -110,15 +112,15 @@ public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer { final RettificaGiacenzeRESTConsumerService service = RESTBuilder.getService(RettificaGiacenzeRESTConsumerService.class); service.saveDocFromPickingPvm(request) - .enqueue(new Callback<>() { + .enqueue(new ManagedErrorCallback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswerList(response, "saveDocFromPickingPvm", data -> onComplete.run(), onError); } @Override - public void onFailure(Call> call, Throwable t) { - onError.run(new Exception(t)); + public void onFailure(Call> call, @NonNull final Exception e) { + onError.run(e); } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/ui/fastscroll/RecyclerViewScrollListener.java b/app/src/main/java/it/integry/integrywmsnative/ui/fastscroll/RecyclerViewScrollListener.java index 9d70508f..8768be03 100644 --- a/app/src/main/java/it/integry/integrywmsnative/ui/fastscroll/RecyclerViewScrollListener.java +++ b/app/src/main/java/it/integry/integrywmsnative/ui/fastscroll/RecyclerViewScrollListener.java @@ -5,10 +5,6 @@ import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; import java.util.List; -/** - * Created by Michal on 04/08/16. - * Responsible for updating the handle / bubble position when user scrolls the {@link android.support.v7.widget.RecyclerView}. - */ public class RecyclerViewScrollListener extends RecyclerView.OnScrollListener { private final FastScroller scroller; diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/tracciamento_imballi/TracciamentoImballoDTO.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/tracciamento_imballi/TracciamentoImballoDTO.java index 94e39eb8..aca61953 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/tracciamento_imballi/TracciamentoImballoDTO.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/tracciamento_imballi/TracciamentoImballoDTO.java @@ -8,7 +8,7 @@ public class TracciamentoImballoDTO { private final ObservableField codTcol = new ObservableField<>(); private final ObservableField descrizione = new ObservableField<>(); private final ObservableField codMart = new ObservableField<>(); - private final ObservableField qta = new ObservableField(); + private final ObservableField qta = new ObservableField<>(); private final ObservableBoolean editable = new ObservableBoolean(true); diff --git a/app/src/main/res/layout-large/fragment_prod_rientro_merce_order_detail.xml b/app/src/main/res/layout-large/fragment_prod_rientro_merce_order_detail.xml index 5ec6ff88..2b88eeaf 100644 --- a/app/src/main/res/layout-large/fragment_prod_rientro_merce_order_detail.xml +++ b/app/src/main/res/layout-large/fragment_prod_rientro_merce_order_detail.xml @@ -1158,6 +1158,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/add_unit" + android:layout_marginStart="8dp" app:icon="@drawable/ic_add_24dp" app:singleClick="@{() -> view.addSingleUnitButtonClick()}" /> diff --git a/app/src/main/res/layout/bottom_sheet_fragment__lu_content__list_item.xml b/app/src/main/res/layout/bottom_sheet_fragment__lu_content__list_item.xml index 7fa714e0..d60b1534 100644 --- a/app/src/main/res/layout/bottom_sheet_fragment__lu_content__list_item.xml +++ b/app/src/main/res/layout/bottom_sheet_fragment__lu_content__list_item.xml @@ -178,7 +178,7 @@ diff --git a/app/src/main/res/layout/fragment_prod_rientro_merce_order_detail.xml b/app/src/main/res/layout/fragment_prod_rientro_merce_order_detail.xml index 294f002c..8c36d9b7 100644 --- a/app/src/main/res/layout/fragment_prod_rientro_merce_order_detail.xml +++ b/app/src/main/res/layout/fragment_prod_rientro_merce_order_detail.xml @@ -739,6 +739,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/add_unit" + android:layout_marginStart="8dp" app:icon="@drawable/ic_add_24dp" app:singleClick="@{() -> view.addSingleUnitButtonClick()}" /> diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 533a98a7..0b70fac6 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -380,8 +380,8 @@ Griglia: Seleziona / Crea ordine Aggiungi - Aggiungi pedana - Aggiungi unità + Agg. pedana + Agg. unità Chiudi Chiudi ed esporta ordine Chiudi ordine diff --git a/honeywellscannerlibrary/src/main/java/it/integry/honeywellscannerlibrary/HoneyWellBarcodeReader.java b/honeywellscannerlibrary/src/main/java/it/integry/honeywellscannerlibrary/HoneyWellBarcodeReader.java index b79d43fd..8c482b60 100644 --- a/honeywellscannerlibrary/src/main/java/it/integry/honeywellscannerlibrary/HoneyWellBarcodeReader.java +++ b/honeywellscannerlibrary/src/main/java/it/integry/honeywellscannerlibrary/HoneyWellBarcodeReader.java @@ -40,7 +40,7 @@ public class HoneyWellBarcodeReader implements BarcodeReaderInterface { @Override public boolean isRightAdapter() { String model = Build.MODEL; - List compatibleModels = new ArrayList(); + List compatibleModels = new ArrayList<>(); compatibleModels.add("EDA50"); compatibleModels.add("EDA51"); compatibleModels.add("EDA52");