Resa synchronized l'init iniziale dell'app
This commit is contained in:
parent
3ac021d7ef
commit
ce5ab1cfc2
@ -49,6 +49,7 @@ import it.integry.integrywmsnative.core.rest.consumers.ProductionLinesRESTConsum
|
|||||||
import it.integry.integrywmsnative.core.rest.consumers.ProduzioneRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.ProduzioneRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.VettoriRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.VettoriRESTConsumer;
|
||||||
|
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
|
||||||
import it.integry.integrywmsnative.core.services.inventario.InventarioService;
|
import it.integry.integrywmsnative.core.services.inventario.InventarioService;
|
||||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||||
import it.integry.integrywmsnative.core.sound.SoundAlertService;
|
import it.integry.integrywmsnative.core.sound.SoundAlertService;
|
||||||
@ -100,8 +101,14 @@ public class MainApplicationModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer, ExecutorService executorService, Handler handler) {
|
ServerStatusChecker providesServerStatusChecker(Handler handler) {
|
||||||
return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase, systemRESTConsumer, authenticationRESTConsumer, executorService, handler);
|
return new ServerStatusChecker(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase, AuthenticationRESTConsumer authenticationRESTConsumer, ExecutorService executorService, Handler handler, ServerStatusChecker serverStatusChecker) {
|
||||||
|
return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase, authenticationRESTConsumer, executorService, handler, serverStatusChecker);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -37,6 +38,9 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
|
|||||||
@Inject
|
@Inject
|
||||||
MainContext mainContext;
|
MainContext mainContext;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Handler handler;
|
||||||
|
|
||||||
private RunnableArgsss<Integer, String[], List<Integer>> onRequestPermissionResult;
|
private RunnableArgsss<Integer, String[], List<Integer>> onRequestPermissionResult;
|
||||||
|
|
||||||
public static void startActivity(Context context) {
|
public static void startActivity(Context context) {
|
||||||
@ -103,12 +107,12 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDBDataLoading(String item) {
|
public void onDBDataLoading(String item) {
|
||||||
runOnUiThread(() -> mBinding.loadingInfoTextview.setText("Caricamento " + item));
|
handler.post(() -> mBinding.loadingInfoTextview.setText("Caricamento " + item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMenuLoading() {
|
public void onMenuLoading() {
|
||||||
runOnUiThread(() -> mBinding.loadingInfoTextview.setText("Caricamento menù"));
|
handler.post(() -> mBinding.loadingInfoTextview.setText("Caricamento menù"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -151,11 +155,13 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Spanned message) {
|
public void onError(Spanned message) {
|
||||||
|
handler.post(() -> {
|
||||||
|
DialogSimpleMessageView.makeErrorDialog(
|
||||||
|
message, null, this::finish, R.string.logout, () -> {
|
||||||
|
this.mainContext.logout(MainApplication::exit);
|
||||||
|
})
|
||||||
|
.show(this.getSupportFragmentManager(), "tag");
|
||||||
|
|
||||||
DialogSimpleMessageView.makeErrorDialog(
|
});
|
||||||
message, null, this::finish, R.string.logout, () -> {
|
|
||||||
this.mainContext.logout(MainApplication::exit);
|
|
||||||
})
|
|
||||||
.show(this.getSupportFragmentManager(), "tag");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,6 @@ import javax.inject.Singleton;
|
|||||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||||
import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
|
import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
|
||||||
import it.integry.integrywmsnative.core.menu.MenuService;
|
import it.integry.integrywmsnative.core.menu.MenuService;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
|
||||||
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
|
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
|
||||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||||
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
|
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
|
||||||
@ -28,21 +27,21 @@ public class MainContext {
|
|||||||
private final Context applicationContext;
|
private final Context applicationContext;
|
||||||
private final MenuService menuService;
|
private final MenuService menuService;
|
||||||
private final AppDatabase appDatabase;
|
private final AppDatabase appDatabase;
|
||||||
private final SystemRESTConsumer systemRESTConsumer;
|
|
||||||
private final AuthenticationRESTConsumer authenticationRESTConsumer;
|
private final AuthenticationRESTConsumer authenticationRESTConsumer;
|
||||||
private final ExecutorService executorService;
|
private final ExecutorService executorService;
|
||||||
private final Handler handler;
|
private final Handler handler;
|
||||||
|
private final ServerStatusChecker serverStatusChecker;
|
||||||
|
|
||||||
private Listener mListener;
|
private Listener mListener;
|
||||||
|
|
||||||
public MainContext(Context applicationContext, MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer, ExecutorService executorService, Handler handler) {
|
public MainContext(Context applicationContext, MenuService menuService, AppDatabase appDatabase, AuthenticationRESTConsumer authenticationRESTConsumer, ExecutorService executorService, Handler handler, ServerStatusChecker serverStatusChecker) {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
this.menuService = menuService;
|
this.menuService = menuService;
|
||||||
this.appDatabase = appDatabase;
|
this.appDatabase = appDatabase;
|
||||||
this.systemRESTConsumer = systemRESTConsumer;
|
|
||||||
this.authenticationRESTConsumer = authenticationRESTConsumer;
|
this.authenticationRESTConsumer = authenticationRESTConsumer;
|
||||||
this.executorService = executorService;
|
this.executorService = executorService;
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
|
this.serverStatusChecker = serverStatusChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
@ -53,34 +52,31 @@ public class MainContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//this.initAuthSession(() -> {
|
executorService.execute(() -> {
|
||||||
// this.initDeviceId(() -> {
|
|
||||||
this.initDBData(() -> {
|
|
||||||
this.initMenu(() -> {
|
|
||||||
|
|
||||||
if (mListener != null) mListener.onContextInitialized();
|
try {
|
||||||
});
|
this.initDBData();
|
||||||
});
|
this.initMenu();
|
||||||
// });
|
serverStatusChecker.init();
|
||||||
//});
|
|
||||||
|
|
||||||
|
if (mListener != null) mListener.onContextInitialized();
|
||||||
|
|
||||||
this.initServerStatusChecker();
|
} catch (Exception ex) {
|
||||||
|
Spanned message = null;
|
||||||
|
|
||||||
// EventBus.getDefault().register(this);
|
if (ex.getCause() != null && ex.getCause() instanceof ConnectException) {
|
||||||
|
message = Html.fromHtml("Impossibile collegarsi all'host <b>" + SettingsManager.i().getServer().getHost() + ":" + SettingsManager.i().getServer().getPort() + "</b>. Riprovare più tardi.");
|
||||||
|
} else if (ex.getMessage().startsWith("Status 404:")) {
|
||||||
|
message = Html.fromHtml("Errore 404. Non è stato possibile soddisfare la richiesta sull'host <b>" + SettingsManager.i().getServer().getHost() + ":" + SettingsManager.i().getServer().getPort() + "</b>. Riprovare più tardi.");
|
||||||
|
} else {
|
||||||
|
message = new SpannableString(ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mListener != null) mListener.onError(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
|
||||||
// public void onSessionExpired(SessionExpiredEvent event) {
|
|
||||||
// DialogSimpleMessageView.makeErrorDialog(
|
|
||||||
// new SpannedString("La sessione è scaduta. Effettua nuovamente la login"),
|
|
||||||
// null,
|
|
||||||
// () -> {
|
|
||||||
// logout(MainApplication::exit);
|
|
||||||
// })
|
|
||||||
// .show(activity.getSupportFragmentManager(), "expired-session-error");
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
private void initAuthSession(Runnable onComplete) {
|
private void initAuthSession(Runnable onComplete) {
|
||||||
this.authenticationRESTConsumer.me(obj -> {
|
this.authenticationRESTConsumer.me(obj -> {
|
||||||
@ -122,40 +118,16 @@ public class MainContext {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initServerStatusChecker() {
|
private void initDBData() throws Exception {
|
||||||
ServerStatusChecker.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initDBData(Runnable onComplete) {
|
|
||||||
|
|
||||||
|
|
||||||
SettingsManager.loadDBVariables(item -> {
|
SettingsManager.loadDBVariables(item -> {
|
||||||
if (mListener != null) mListener.onDBDataLoading(item);
|
if (mListener != null) mListener.onDBDataLoading(item);
|
||||||
},
|
});
|
||||||
onComplete,
|
|
||||||
ex -> {
|
|
||||||
|
|
||||||
Spanned message = null;
|
|
||||||
|
|
||||||
if (ex.getCause() != null && ex.getCause() instanceof ConnectException) {
|
|
||||||
message = Html.fromHtml("Impossibile collegarsi all'host <b>" + SettingsManager.i().getServer().getHost() + ":" + SettingsManager.i().getServer().getPort() + "</b>. Riprovare più tardi.");
|
|
||||||
} else if (ex.getMessage().startsWith("Status 404:")) {
|
|
||||||
message = Html.fromHtml("Errore 404. Non è stato possibile soddisfare la richiesta sull'host <b>" + SettingsManager.i().getServer().getHost() + ":" + SettingsManager.i().getServer().getPort() + "</b>. Riprovare più tardi.");
|
|
||||||
} else {
|
|
||||||
message = new SpannableString(ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener != null) mListener.onError(message);
|
|
||||||
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMenu(Runnable onComplete) {
|
private void initMenu() throws Exception {
|
||||||
if (mListener != null) mListener.onMenuLoading();
|
if (mListener != null) mListener.onMenuLoading();
|
||||||
this.menuService.init(onComplete, ex -> {
|
this.menuService.init();
|
||||||
if (mListener != null) mListener.onError(new SpannedString(ex.getMessage()));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,10 @@
|
|||||||
package it.integry.integrywmsnative.core.menu;
|
package it.integry.integrywmsnative.core.menu;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|
||||||
import it.integry.integrywmsnative.core.model.StbMenu;
|
import it.integry.integrywmsnative.core.model.StbMenu;
|
||||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
|
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.Response;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class MenuRESTConsumer extends _BaseRESTConsumer {
|
public class MenuRESTConsumer extends _BaseRESTConsumer {
|
||||||
@ -22,19 +15,12 @@ public class MenuRESTConsumer extends _BaseRESTConsumer {
|
|||||||
this.restBuilder = restBuilder;
|
this.restBuilder = restBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retrieveMenu(String rootCodOpz, RunnableArgs<StbMenu> onComplete, RunnableArgs<Exception> onFailed) {
|
public StbMenu retrieveMenuSynchronized(String rootCodOpz) throws Exception {
|
||||||
MenuRESTConsumerService menuRESTConsumerService = restBuilder.getService(MenuRESTConsumerService.class);
|
MenuRESTConsumerService menuRESTConsumerService = restBuilder.getService(MenuRESTConsumerService.class);
|
||||||
menuRESTConsumerService.retrieveMenuConfig(rootCodOpz).enqueue(new ManagedErrorCallback<>() {
|
var response = menuRESTConsumerService.retrieveMenuConfig(rootCodOpz)
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<StbMenu>> call, Response<ServiceRESTResponse<StbMenu>> response) {
|
|
||||||
analyzeAnswer(response, "retrieveMenu", onComplete, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
return analyzeAnswer(response, "retrieveMenu");
|
||||||
public void onFailure(Call<ServiceRESTResponse<StbMenu>> call, @NonNull final Exception e) {
|
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import javax.inject.Singleton;
|
|||||||
|
|
||||||
import it.integry.integrywmsnative.core.class_router.configs.BaseMenuConfiguration;
|
import it.integry.integrywmsnative.core.class_router.configs.BaseMenuConfiguration;
|
||||||
import it.integry.integrywmsnative.core.class_router.configs.MenuConfiguration;
|
import it.integry.integrywmsnative.core.class_router.configs.MenuConfiguration;
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|
||||||
import it.integry.integrywmsnative.core.menu.exception.MenuNotFoundException;
|
import it.integry.integrywmsnative.core.menu.exception.MenuNotFoundException;
|
||||||
import it.integry.integrywmsnative.core.model.StbMenu;
|
import it.integry.integrywmsnative.core.model.StbMenu;
|
||||||
|
|
||||||
@ -29,20 +28,18 @@ public class MenuService {
|
|||||||
this.menuRESTConsumer = menuRESTConsumer;
|
this.menuRESTConsumer = menuRESTConsumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(Runnable onMenuInitialized, RunnableArgs<Exception> onFailed) {
|
public void init() throws Exception {
|
||||||
menuRESTConsumer.retrieveMenu(MENU_COD_OPZ, menu -> {
|
var menu = menuRESTConsumer.retrieveMenuSynchronized(MENU_COD_OPZ);
|
||||||
if(menu != null) {
|
|
||||||
this.mInternalCachedMenu = menu.getStbMenuChildren();
|
|
||||||
this.mInternalCachedFlatMenu = new ArrayList<>();
|
|
||||||
flattenMenu(this.mInternalCachedMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMenuInitialized.run();
|
if (menu != null) {
|
||||||
}, onFailed);
|
this.mInternalCachedMenu = menu.getStbMenuChildren();
|
||||||
|
this.mInternalCachedFlatMenu = new ArrayList<>();
|
||||||
|
flattenMenu(this.mInternalCachedMenu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<StbMenu> getMenu() throws Exception {
|
public List<StbMenu> getMenu() throws Exception {
|
||||||
if(mInternalCachedMenu == null) throw new MenuNotFoundException();
|
if (mInternalCachedMenu == null) throw new MenuNotFoundException();
|
||||||
|
|
||||||
return mInternalCachedMenu;
|
return mInternalCachedMenu;
|
||||||
}
|
}
|
||||||
@ -64,10 +61,10 @@ public class MenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void flattenMenu(List<StbMenu> menu) {
|
private void flattenMenu(List<StbMenu> menu) {
|
||||||
for(StbMenu stbMenu : menu) {
|
for (StbMenu stbMenu : menu) {
|
||||||
this.mInternalCachedFlatMenu.add(stbMenu);
|
this.mInternalCachedFlatMenu.add(stbMenu);
|
||||||
|
|
||||||
if(stbMenu.getStbMenuChildren() != null && !stbMenu.getStbMenuChildren().isEmpty()) {
|
if (stbMenu.getStbMenuChildren() != null && !stbMenu.getStbMenuChildren().isEmpty()) {
|
||||||
flattenMenu(stbMenu.getStbMenuChildren());
|
flattenMenu(stbMenu.getStbMenuChildren());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +1,9 @@
|
|||||||
package it.integry.integrywmsnative.core.rest.consumers;
|
package it.integry.integrywmsnative.core.rest.consumers;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|
||||||
import it.integry.integrywmsnative.core.model.Azienda;
|
import it.integry.integrywmsnative.core.model.Azienda;
|
||||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
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.Response;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AziendaRESTConsumer extends _BaseRESTConsumer {
|
public class AziendaRESTConsumer extends _BaseRESTConsumer {
|
||||||
@ -21,19 +14,12 @@ public class AziendaRESTConsumer extends _BaseRESTConsumer {
|
|||||||
this.restBuilder = restBuilder;
|
this.restBuilder = restBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retrieveAzienda(RunnableArgs<Azienda> onComplete, RunnableArgs<Exception> onFailed) {
|
public Azienda retrieveAziendaSynchronized() throws Exception {
|
||||||
AziendaRESTConsumerService aziendaRESTConsumerService = restBuilder.getService(AziendaRESTConsumerService.class);
|
AziendaRESTConsumerService aziendaRESTConsumerService = restBuilder.getService(AziendaRESTConsumerService.class);
|
||||||
aziendaRESTConsumerService.retrieveDefaultAzienda().enqueue(new ManagedErrorCallback<>() {
|
var response = aziendaRESTConsumerService.retrieveDefaultAzienda()
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<Azienda>> call, Response<ServiceRESTResponse<Azienda>> response) {
|
|
||||||
analyzeAnswer(response, "Retrieve default azienda", onComplete, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
return analyzeAnswer(response, "Retrieve default azienda");
|
||||||
public void onFailure(Call<ServiceRESTResponse<Azienda>> call, @NonNull final Exception e) {
|
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,32 +79,22 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getValues(String codMdep, List<StbGestSetupReader> stbGestSetupList, RunnableArgs<List<StbGestSetupReader>> onComplete, RunnableArgs<Exception> onFailed) {
|
public List<StbGestSetupReader> getValuesSynchronized(String codMdep, List<StbGestSetupReader> stbGestSetupList) throws Exception {
|
||||||
var stbGestSetups = stbGestSetupList.stream().map(x -> (StbGestSetup) x).collect(Collectors.toList());
|
var stbGestSetups = stbGestSetupList.stream().map(x -> (StbGestSetup) x).collect(Collectors.toList());
|
||||||
|
|
||||||
GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
|
GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
|
||||||
service.getGestSetupValues(codMdep, stbGestSetups).enqueue(new ManagedErrorCallback<>() {
|
var response = service.getGestSetupValues(codMdep, stbGestSetups)
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<List<StbGestSetup>>> call, Response<ServiceRESTResponse<List<StbGestSetup>>> response) {
|
var data = analyzeAnswer(response, "GestSetup");
|
||||||
analyzeAnswer(response, "GestSetup", data -> {
|
for (StbGestSetup stbGestSetup : data) {
|
||||||
|
stbGestSetupList.stream().filter(x -> stbGestSetup.getGestName().equalsIgnoreCase(x.getGestName()) &&
|
||||||
|
stbGestSetup.getSection().equalsIgnoreCase(x.getSection()) &&
|
||||||
|
stbGestSetup.getKeySection().equalsIgnoreCase(x.getKeySection()))
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(x -> x.setValue(stbGestSetup.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
for (StbGestSetup stbGestSetup : data) {
|
return stbGestSetupList;
|
||||||
stbGestSetupList.stream().filter(x -> stbGestSetup.getGestName().equalsIgnoreCase(x.getGestName()) &&
|
|
||||||
stbGestSetup.getSection().equalsIgnoreCase(x.getSection()) &&
|
|
||||||
stbGestSetup.getKeySection().equalsIgnoreCase(x.getKeySection()))
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(x -> x.setValue(stbGestSetup.getValue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
onComplete.run(stbGestSetupList);
|
|
||||||
}, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<ServiceRESTResponse<List<StbGestSetup>>> call, @NonNull final Exception e) {
|
|
||||||
if (onFailed != null) onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
package it.integry.integrywmsnative.core.rest.consumers;
|
package it.integry.integrywmsnative.core.rest.consumers;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
@ -15,11 +13,7 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|||||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||||
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
|
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
|
||||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
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.UtilityDB;
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.Response;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class PosizioniRESTConsumer extends _BaseRESTConsumer {
|
public class PosizioniRESTConsumer extends _BaseRESTConsumer {
|
||||||
@ -34,23 +28,15 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer {
|
|||||||
this.executorService = executorService;
|
this.executorService = executorService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAvailablePosizioni(RunnableArgs<List<MtbDepoPosizione>> onComplete, RunnableArgs<Exception> onFailed) {
|
public List<MtbDepoPosizione> getAvailablePosizioniSynchronized() throws Exception {
|
||||||
String codMdep = null;
|
String codMdep = null;
|
||||||
|
|
||||||
PosizioniRESTConsumerService posizioniRESTConsumerService = restBuilder.getService(PosizioniRESTConsumerService.class);
|
PosizioniRESTConsumerService posizioniRESTConsumerService = restBuilder.getService(PosizioniRESTConsumerService.class);
|
||||||
posizioniRESTConsumerService.getAvailablePosizioni(codMdep).enqueue(new ManagedErrorCallback<>() {
|
var response = posizioniRESTConsumerService.getAvailablePosizioni(codMdep)
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, Response<ServiceRESTResponse<List<MtbDepoPosizione>>> response) {
|
|
||||||
analyzeAnswer(response, "getAvailablePosizioni", (m) -> {
|
|
||||||
onComplete.run(response.body().getDto());
|
|
||||||
}, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
var data = analyzeAnswer(response, "getAvailablePosizioni");
|
||||||
public void onFailure(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, @NonNull final Exception e) {
|
return response.body().getDto();
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<MtbColt> getBancaliInPosizioneSynchronized(MtbDepoPosizione mtbDepoPosizione) throws Exception {
|
public ArrayList<MtbColt> getBancaliInPosizioneSynchronized(MtbDepoPosizione mtbDepoPosizione) throws Exception {
|
||||||
|
|||||||
@ -89,6 +89,11 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<AvailableCodMdepsDTO> getAvailableCodMdepsSynchronized() throws Exception {
|
||||||
|
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
|
||||||
|
var response = service.getAvailableCodMdeps().execute();
|
||||||
|
return analyzeAnswer(response, "CodMdepsAvailable");
|
||||||
|
}
|
||||||
|
|
||||||
public void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
|
public void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||||
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
|
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
|
||||||
|
|||||||
@ -12,7 +12,11 @@ import it.integry.integrywmsnative.core.utility.UtilityString;
|
|||||||
|
|
||||||
public class ServerStatusChecker {
|
public class ServerStatusChecker {
|
||||||
|
|
||||||
private static final ServerStatusChecker instance = new ServerStatusChecker();
|
|
||||||
|
private final Handler handler;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final List<RunnableArgs<Boolean>> mCallback = new ArrayList<>();
|
private final List<RunnableArgs<Boolean>> mCallback = new ArrayList<>();
|
||||||
|
|
||||||
@ -26,7 +30,29 @@ public class ServerStatusChecker {
|
|||||||
private final long MILLIS_DELAY = 5 * 1000;
|
private final long MILLIS_DELAY = 5 * 1000;
|
||||||
|
|
||||||
|
|
||||||
private final Handler handler = new Handler();
|
public ServerStatusChecker(Handler handler) {
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCallback(RunnableArgs<Boolean> callback) {
|
||||||
|
this.mCallback.add(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeCallback(RunnableArgs<Boolean> callback) {
|
||||||
|
this.mCallback.remove(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
this.shouldExecute = true;
|
||||||
|
|
||||||
|
this.handler.post(this.runnableCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
this.shouldExecute = false;
|
||||||
|
}
|
||||||
|
|
||||||
private final Runnable runnableCode = new Runnable() {
|
private final Runnable runnableCode = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -42,27 +68,4 @@ public class ServerStatusChecker {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public void addCallback(RunnableArgs<Boolean> callback) {
|
|
||||||
this.mCallback.add(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeCallback(RunnableArgs<Boolean> callback) {
|
|
||||||
this.mCallback.remove(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void init() {
|
|
||||||
instance.shouldExecute = true;
|
|
||||||
|
|
||||||
instance.handler.post(instance.runnableCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void dispose() {
|
|
||||||
instance.shouldExecute = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ServerStatusChecker getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,136 +102,111 @@ public class SettingsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void loadDBVariables(RunnableArgs<String> onProgress, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
public static void loadDBVariables(RunnableArgs<String> onProgress) throws Exception {
|
||||||
dbSettingsModelIstance = new DBSettingsModel();
|
dbSettingsModelIstance = new DBSettingsModel();
|
||||||
|
|
||||||
Trace perfTrace = UtilityFirebase.getNewPerformanceTrace("db_load_vars");
|
Trace perfTrace = UtilityFirebase.getNewPerformanceTrace("db_load_vars");
|
||||||
perfTrace.start();
|
perfTrace.start();
|
||||||
|
|
||||||
Runnable tmpOnComplete = () -> {
|
try {
|
||||||
perfTrace.stop();
|
onProgress.run("depositi");
|
||||||
onComplete.run();
|
loadAvailableCodMdeps();
|
||||||
};
|
|
||||||
|
|
||||||
RunnableArgs<Exception> tmpOnFailed = ex -> {
|
|
||||||
UtilityLogger.error(ex);
|
|
||||||
perfTrace.putAttribute("failed", "true");
|
|
||||||
if (!(ex instanceof SocketTimeoutException)) onFailed.run(ex);
|
|
||||||
else
|
|
||||||
onFailed.run(new Exception("Errore durante il caricamento dei dati. Riavviare l'applicazione!"));
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
onProgress.run("depositi");
|
|
||||||
loadAvailableCodMdeps(() -> {
|
|
||||||
|
|
||||||
onProgress.run("posizioni");
|
onProgress.run("posizioni");
|
||||||
loadAvailablePosizioni(() -> {
|
loadAvailablePosizioni();
|
||||||
|
|
||||||
onProgress.run("impostazioni");
|
|
||||||
loadGestSetupValues(() -> {
|
|
||||||
|
|
||||||
onProgress.run("dati azienda");
|
onProgress.run("impostazioni");
|
||||||
loadDatiAzienda(() -> {
|
loadGestSetupValues();
|
||||||
|
|
||||||
loadTipiCollo(tmpOnComplete, tmpOnFailed);
|
|
||||||
|
|
||||||
}, tmpOnFailed);
|
onProgress.run("dati azienda");
|
||||||
}, tmpOnFailed);
|
loadDatiAzienda();
|
||||||
}, tmpOnFailed);
|
loadTipiCollo();
|
||||||
}, tmpOnFailed);
|
|
||||||
|
perfTrace.stop();
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
UtilityLogger.error(ex);
|
||||||
|
perfTrace.putAttribute("failed", "true");
|
||||||
|
|
||||||
|
if (!(ex instanceof SocketTimeoutException))
|
||||||
|
throw ex;
|
||||||
|
else
|
||||||
|
throw new Exception("Errore durante il caricamento dei dati. Riavviare l'applicazione!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadTipiCollo(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
private static void loadTipiCollo() throws Exception {
|
||||||
mImballiRESTConsumer.retrieveImballi(MtbTCol.FlagUiUlEnum.UL, tipiColloUl -> {
|
var tipiColloUl = mImballiRESTConsumer.retrieveImballiSyncronized(MtbTCol.FlagUiUlEnum.UL);
|
||||||
mImballiRESTConsumer.retrieveImballi(MtbTCol.FlagUiUlEnum.UI, tipiColloUi -> {
|
var tipiColloUi = mImballiRESTConsumer.retrieveImballiSyncronized(MtbTCol.FlagUiUlEnum.UI);
|
||||||
|
|
||||||
var imballiList = new ObservableArrayList<ObservableMtbTcol>();
|
var imballiList = new ObservableArrayList<ObservableMtbTcol>();
|
||||||
imballiList.addAll(tipiColloUi);
|
|
||||||
imballiList.addAll(tipiColloUl);
|
|
||||||
|
|
||||||
SettingsManager.iDB().setInternalImballi(imballiList);
|
imballiList.addAll(tipiColloUi);
|
||||||
onComplete.run();
|
imballiList.addAll(tipiColloUl);
|
||||||
}, onFailed);
|
|
||||||
}, onFailed);
|
|
||||||
|
|
||||||
|
SettingsManager.iDB().setInternalImballi(imballiList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadDatiAzienda(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
private static void loadDatiAzienda() throws Exception {
|
||||||
|
|
||||||
mAziendaRESTConsumer.retrieveAzienda(datiAzienda -> {
|
var datiAzienda = mAziendaRESTConsumer.retrieveAziendaSynchronized();
|
||||||
SettingsManager.iDB().setDatiAzienda(datiAzienda);
|
|
||||||
|
|
||||||
if (!SettingsManager.iDB().isFlagUseCodAnagAziendale()) {
|
SettingsManager.iDB().setDatiAzienda(datiAzienda);
|
||||||
onComplete.run();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String internalCodAnagsQuery = "SELECT ga.cod_anag,\n" +
|
if (!SettingsManager.iDB().isFlagUseCodAnagAziendale()) {
|
||||||
" CAST(CASE WHEN vc.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_cliente,\n" +
|
return;
|
||||||
" CAST(CASE WHEN af.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_fornitore\n" +
|
}
|
||||||
"FROM azienda\n" +
|
|
||||||
"INNER JOIN gtb_anag ga on azienda.part_iva = ga.part_iva\n" +
|
|
||||||
"LEFT OUTER JOIN vtb_clie vc on ga.cod_anag = vc.cod_anag AND vc.flag_stato = 'A'\n" +
|
|
||||||
"LEFT OUTER JOIN atb_forn af on ga.cod_anag = af.cod_anag AND af.flag_stato = 'A'";
|
|
||||||
|
|
||||||
Type type = new TypeToken<List<InternalCodAnagsDTO>>() {
|
String internalCodAnagsQuery = "SELECT ga.cod_anag,\n" +
|
||||||
}.getType();
|
" CAST(CASE WHEN vc.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_cliente,\n" +
|
||||||
mSystemRESTConsumer.<List<InternalCodAnagsDTO>>processSql(internalCodAnagsQuery, type, internalCodAnagsList -> {
|
" CAST(CASE WHEN af.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_fornitore\n" +
|
||||||
SettingsManager.iDB().setInternalCodAnags(internalCodAnagsList);
|
"FROM azienda\n" +
|
||||||
|
"INNER JOIN gtb_anag ga on azienda.part_iva = ga.part_iva\n" +
|
||||||
|
"LEFT OUTER JOIN vtb_clie vc on ga.cod_anag = vc.cod_anag AND vc.flag_stato = 'A'\n" +
|
||||||
|
"LEFT OUTER JOIN atb_forn af on ga.cod_anag = af.cod_anag AND af.flag_stato = 'A'";
|
||||||
|
|
||||||
if (onComplete != null) onComplete.run();
|
Type type = new TypeToken<List<InternalCodAnagsDTO>>() {
|
||||||
}, onFailed);
|
}.getType();
|
||||||
|
var internalCodAnagsList = mSystemRESTConsumer.<List<InternalCodAnagsDTO>>processSqlSynchronized(internalCodAnagsQuery, type);
|
||||||
}, onFailed);
|
SettingsManager.iDB().setInternalCodAnags(internalCodAnagsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadAvailableCodMdeps(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
private static void loadAvailableCodMdeps() throws Exception {
|
||||||
mSystemRESTConsumer.getAvailableCodMdeps(availableCodMdeps -> {
|
var availableCodMdeps = mSystemRESTConsumer.getAvailableCodMdepsSynchronized();
|
||||||
dbSettingsModelIstance.setAvailableCodMdep(availableCodMdeps);
|
|
||||||
|
|
||||||
if (availableCodMdeps == null || availableCodMdeps.isEmpty()) {
|
dbSettingsModelIstance.setAvailableCodMdep(availableCodMdeps);
|
||||||
onFailed.run(new Exception(mContext.getText(R.string.no_codmdep_available).toString()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean codMdepExistsAnymore = false;
|
if (availableCodMdeps == null || availableCodMdeps.isEmpty()) {
|
||||||
|
throw new Exception(mContext.getText(R.string.no_codmdep_available).toString());
|
||||||
|
}
|
||||||
|
|
||||||
if (settingsModelIstance.getUserSession().getDepo() != null) {
|
boolean codMdepExistsAnymore = false;
|
||||||
for (AvailableCodMdepsDTO availableCodMdepDTO : availableCodMdeps) {
|
|
||||||
//Controllo se il codMdep salvato esiste ancora
|
if (settingsModelIstance.getUserSession().getDepo() != null) {
|
||||||
if (availableCodMdepDTO.getCodMdep().equalsIgnoreCase(settingsModelIstance.getUserSession().getDepo().getCodMdep())) {
|
for (AvailableCodMdepsDTO availableCodMdepDTO : availableCodMdeps) {
|
||||||
codMdepExistsAnymore = true;
|
//Controllo se il codMdep salvato esiste ancora
|
||||||
break;
|
if (availableCodMdepDTO.getCodMdep().equalsIgnoreCase(settingsModelIstance.getUserSession().getDepo().getCodMdep())) {
|
||||||
}
|
codMdepExistsAnymore = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!codMdepExistsAnymore) {
|
if (!codMdepExistsAnymore) {
|
||||||
settingsModelIstance.getUserSession().setDepo(availableCodMdeps.get(0));
|
settingsModelIstance.getUserSession().setDepo(availableCodMdeps.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onComplete != null) onComplete.run();
|
|
||||||
}, ex -> {
|
|
||||||
//BOH
|
|
||||||
if (onFailed != null) onFailed.run(ex);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void loadAvailablePosizioni(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
private static void loadAvailablePosizioni() throws Exception {
|
||||||
mPosizioniRESTConsumer.getAvailablePosizioni(availablePosizioni -> {
|
var availablePosizioni = mPosizioniRESTConsumer.getAvailablePosizioniSynchronized();
|
||||||
dbSettingsModelIstance.setAvailablePosizioni(availablePosizioni);
|
dbSettingsModelIstance.setAvailablePosizioni(availablePosizioni);
|
||||||
|
|
||||||
if (onComplete != null) onComplete.run();
|
|
||||||
}, ex -> {
|
|
||||||
if (onFailed != null) onFailed.run(ex);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void loadGestSetupValues(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
private static void loadGestSetupValues() throws Exception {
|
||||||
|
|
||||||
List<StbGestSetupReader> stbGestSetupReaderList = new ArrayList<>();
|
List<StbGestSetupReader> stbGestSetupReaderList = new ArrayList<>();
|
||||||
|
|
||||||
@ -648,34 +623,33 @@ public class SettingsManager {
|
|||||||
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
||||||
|
|
||||||
|
|
||||||
mGestSetupRESTConsumer.getValues(codMdep, stbGestSetupReaderList, list -> {
|
var list = mGestSetupRESTConsumer.getValuesSynchronized(codMdep, stbGestSetupReaderList);
|
||||||
|
|
||||||
for (var stbGestSetupReader : list) {
|
|
||||||
var value = stbGestSetupReader.getValue();
|
|
||||||
var clazz = stbGestSetupReader.getClazz();
|
|
||||||
|
|
||||||
Object finalValue = null;
|
for (var stbGestSetupReader : list) {
|
||||||
if (value != null) {
|
var value = stbGestSetupReader.getValue();
|
||||||
if (clazz == String.class) {
|
var clazz = stbGestSetupReader.getClazz();
|
||||||
finalValue = clazz.cast(value);
|
|
||||||
} else if (clazz == Boolean.class) {
|
|
||||||
finalValue = clazz.cast("S".equalsIgnoreCase(value));
|
|
||||||
} else if (clazz == Integer.class && value != null) {
|
|
||||||
finalValue = clazz.cast(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
} else if (stbGestSetupReader.getDefaultValue() == null) {
|
|
||||||
if (clazz == Boolean.class) {
|
|
||||||
finalValue = clazz.cast(Boolean.FALSE);
|
|
||||||
} else if (clazz == Integer.class) {
|
|
||||||
finalValue = clazz.cast(0);
|
|
||||||
}
|
|
||||||
} else finalValue = stbGestSetupReader.getDefaultValue();
|
|
||||||
|
|
||||||
stbGestSetupReader.getSetter().run(finalValue);
|
Object finalValue = null;
|
||||||
}
|
if (value != null) {
|
||||||
|
if (clazz == String.class) {
|
||||||
|
finalValue = clazz.cast(value);
|
||||||
|
} else if (clazz == Boolean.class) {
|
||||||
|
finalValue = clazz.cast("S".equalsIgnoreCase(value));
|
||||||
|
} else if (clazz == Integer.class && value != null) {
|
||||||
|
finalValue = clazz.cast(Integer.parseInt(value));
|
||||||
|
}
|
||||||
|
} else if (stbGestSetupReader.getDefaultValue() == null) {
|
||||||
|
if (clazz == Boolean.class) {
|
||||||
|
finalValue = clazz.cast(Boolean.FALSE);
|
||||||
|
} else if (clazz == Integer.class) {
|
||||||
|
finalValue = clazz.cast(0);
|
||||||
|
}
|
||||||
|
} else finalValue = stbGestSetupReader.getDefaultValue();
|
||||||
|
|
||||||
|
stbGestSetupReader.getSetter().run(finalValue);
|
||||||
|
}
|
||||||
|
|
||||||
if (onComplete != null) onComplete.run();
|
|
||||||
}, onFailed);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
|||||||
import com.orhanobut.logger.Logger;
|
import com.orhanobut.logger.Logger;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.BuildConfig;
|
import it.integry.integrywmsnative.BuildConfig;
|
||||||
|
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||||
import it.integry.integrywmsnative.core.exception.InvalidConnectionException;
|
import it.integry.integrywmsnative.core.exception.InvalidConnectionException;
|
||||||
import it.integry.integrywmsnative.core.exception.InvalidLUException;
|
import it.integry.integrywmsnative.core.exception.InvalidLUException;
|
||||||
import it.integry.integrywmsnative.core.exception.InvalidLUGestioneException;
|
import it.integry.integrywmsnative.core.exception.InvalidLUGestioneException;
|
||||||
@ -19,11 +20,12 @@ import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
|||||||
|
|
||||||
public class UtilityExceptions {
|
public class UtilityExceptions {
|
||||||
|
|
||||||
private static final Class<?>[] FIREBASE_IGNORED_EXCEPTIONS = new Class[] {
|
private static final Class<?>[] FIREBASE_IGNORED_EXCEPTIONS = new Class[]{
|
||||||
InvalidConnectionException.class,
|
InvalidConnectionException.class,
|
||||||
InvalidLUGestioneException.class,
|
InvalidLUGestioneException.class,
|
||||||
InvalidLUException.class
|
InvalidLUException.class
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void defaultException(Context context, Exception ex) {
|
public static void defaultException(Context context, Exception ex) {
|
||||||
defaultException(context, ex, false);
|
defaultException(context, ex, false);
|
||||||
}
|
}
|
||||||
@ -47,7 +49,11 @@ public class UtilityExceptions {
|
|||||||
FragmentManager fm = ContextHelper.getFragmentManagerFromContext(context);
|
FragmentManager fm = ContextHelper.getFragmentManagerFromContext(context);
|
||||||
|
|
||||||
if (fm != null) {
|
if (fm != null) {
|
||||||
DialogSimpleMessageView.makeErrorDialog(Html.fromHtml(errorMessage), null, null)
|
boolean isBarcodeEnabled = BarcodeManager.isLastCallbackEnabled();
|
||||||
|
if (isBarcodeEnabled) BarcodeManager.disableLastCallback();
|
||||||
|
DialogSimpleMessageView.makeErrorDialog(Html.fromHtml(errorMessage), null, () -> {
|
||||||
|
if (isBarcodeEnabled) BarcodeManager.enableLastCallback();
|
||||||
|
})
|
||||||
.show(fm, "tag");
|
.show(fm, "tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,6 +77,9 @@ public class MainActivity extends BaseActivity
|
|||||||
@Inject
|
@Inject
|
||||||
DialogProgressView mDialogProgressView;
|
DialogProgressView mDialogProgressView;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ServerStatusChecker serverStatusChecker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -194,7 +197,7 @@ public class MainActivity extends BaseActivity
|
|||||||
fragment = new MainSettingsFragment();
|
fragment = new MainSettingsFragment();
|
||||||
this.adaptViewToFragment(fragment);
|
this.adaptViewToFragment(fragment);
|
||||||
} else if (id == R.id.nav_logout) {
|
} else if (id == R.id.nav_logout) {
|
||||||
ServerStatusChecker.dispose();
|
serverStatusChecker.dispose();
|
||||||
this.mainContext.logout(() -> {
|
this.mainContext.logout(() -> {
|
||||||
startLoginActivity();
|
startLoginActivity();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -80,6 +80,9 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
|||||||
@Inject
|
@Inject
|
||||||
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer;
|
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ServerStatusChecker serverStatusChecker;
|
||||||
|
|
||||||
private FragmentMainBinding mBindings;
|
private FragmentMainBinding mBindings;
|
||||||
|
|
||||||
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||||
@ -144,7 +147,7 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
|||||||
|
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
ServerStatusChecker.getInstance().addCallback(value -> {
|
serverStatusChecker.addCallback(value -> {
|
||||||
if (value && mBindings.noConnectionTopLayout.isExpanded()) {
|
if (value && mBindings.noConnectionTopLayout.isExpanded()) {
|
||||||
collapseNoConnectionLayout();
|
collapseNoConnectionLayout();
|
||||||
} else if (!value && !mBindings.noConnectionTopLayout.isExpanded()) {
|
} else if (!value && !mBindings.noConnectionTopLayout.isExpanded()) {
|
||||||
|
|||||||
@ -107,12 +107,13 @@ public class DialogSimpleMessageView extends BaseDialogFragment {
|
|||||||
|
|
||||||
mBindings.setView(this);
|
mBindings.setView(this);
|
||||||
mBindings.setLifecycleOwner(this);
|
mBindings.setLifecycleOwner(this);
|
||||||
|
setCancelable(false);
|
||||||
|
|
||||||
this.initContent();
|
this.initContent();
|
||||||
|
|
||||||
var alertDialogBuilder = new MaterialAlertDialogBuilder(requireContext())
|
var alertDialogBuilder = new MaterialAlertDialogBuilder(requireContext())
|
||||||
.setView(mBindings.getRoot())
|
.setView(mBindings.getRoot())
|
||||||
.setCancelable(false);
|
.setCancelable(isCancelable());
|
||||||
|
|
||||||
if (isPositiveVisible())
|
if (isPositiveVisible())
|
||||||
alertDialogBuilder.setPositiveButton(getPositiveButtonText(), (dialog, which) -> {
|
alertDialogBuilder.setPositiveButton(getPositiveButtonText(), (dialog, which) -> {
|
||||||
@ -130,7 +131,7 @@ public class DialogSimpleMessageView extends BaseDialogFragment {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var alertDialog = alertDialogBuilder.create();
|
var alertDialog = alertDialogBuilder.create();
|
||||||
alertDialog.setCanceledOnTouchOutside(false);
|
alertDialog.setCanceledOnTouchOutside(isCancelable());
|
||||||
return alertDialog;
|
return alertDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,6 +189,8 @@ public class DialogSimpleMessageView extends BaseDialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isPositiveVisible() {
|
public boolean isPositiveVisible() {
|
||||||
return mOnPositiveClick != null || (!isNeutralVisible() && !isNegativeVisible());
|
return mOnPositiveClick != null || (!isNeutralVisible() && !isNegativeVisible());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package it.integry.integrywmsnative.view.dialogs.input_quantity_v2;
|
package it.integry.integrywmsnative.view.dialogs.input_quantity_v2;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
||||||
@ -9,8 +11,8 @@ import it.integry.integrywmsnative.core.rest.consumers.MagazzinoRESTConsumer;
|
|||||||
public class DialogInputQuantityV2Module {
|
public class DialogInputQuantityV2Module {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
DialogInputQuantityV2ViewModel providesDialogInputQuantityV2ViewModel(BarcodeRESTConsumer barcodeRESTConsumer, MagazzinoRESTConsumer magazzinoRESTConsumer) {
|
DialogInputQuantityV2ViewModel providesDialogInputQuantityV2ViewModel(ExecutorService executorService, BarcodeRESTConsumer barcodeRESTConsumer, MagazzinoRESTConsumer magazzinoRESTConsumer) {
|
||||||
return new DialogInputQuantityV2ViewModel(barcodeRESTConsumer, magazzinoRESTConsumer);
|
return new DialogInputQuantityV2ViewModel(executorService, barcodeRESTConsumer, magazzinoRESTConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import android.app.Dialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
@ -56,6 +57,9 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
|
|||||||
@Inject
|
@Inject
|
||||||
DialogInputQuantityV2ViewModel mViewModel;
|
DialogInputQuantityV2ViewModel mViewModel;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Handler handler;
|
||||||
|
|
||||||
private DialogInputQuantityV2DTO mDialogInputQuantityV2DTO;
|
private DialogInputQuantityV2DTO mDialogInputQuantityV2DTO;
|
||||||
//1: Result / 2: ShouldCloseLu / 3: Aborted
|
//1: Result / 2: ShouldCloseLu / 3: Aborted
|
||||||
private RunnableArgs<DialogInputQuantityV2ResultDTO> mOnComplete;
|
private RunnableArgs<DialogInputQuantityV2ResultDTO> mOnComplete;
|
||||||
@ -267,13 +271,13 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
|
|||||||
|
|
||||||
this.mViewModel.validate(validated -> {
|
this.mViewModel.validate(validated -> {
|
||||||
|
|
||||||
requireActivity().runOnUiThread(() -> {
|
handler.post(() -> {
|
||||||
this.onLoadingEnded();
|
this.onLoadingEnded();
|
||||||
|
|
||||||
if (validated) {
|
if (validated) {
|
||||||
var result = this.mViewModel.getResult()
|
var result = this.mViewModel.getResult()
|
||||||
.setAborted(false)
|
.setAborted(false)
|
||||||
.setShouldCloseLu(false);
|
.setShouldCloseLu(false);
|
||||||
dismiss(result);
|
dismiss(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -301,7 +305,7 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
|
|||||||
super.dismiss();
|
super.dismiss();
|
||||||
|
|
||||||
if (this.mOnComplete != null) {
|
if (this.mOnComplete != null) {
|
||||||
if(result == null) {
|
if (result == null) {
|
||||||
result = new DialogInputQuantityV2ResultDTO()
|
result = new DialogInputQuantityV2ResultDTO()
|
||||||
.setAborted(true);
|
.setAborted(true);
|
||||||
}
|
}
|
||||||
@ -562,11 +566,14 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWarning(String text, RunnableArgs<Boolean> result) {
|
public void onWarning(String text, RunnableArgs<Boolean> result) {
|
||||||
DialogSimpleMessageView.makeWarningDialog(new SpannableString(Html.fromHtml(text)),
|
handler.post(() -> {
|
||||||
null,
|
|
||||||
() -> result.run(true),
|
DialogSimpleMessageView.makeWarningDialog(new SpannableString(Html.fromHtml(text)),
|
||||||
() -> result.run(false)
|
null,
|
||||||
).show(requireActivity().getSupportFragmentManager(), "tag");
|
() -> result.run(true),
|
||||||
|
() -> result.run(false)
|
||||||
|
).show(requireActivity().getSupportFragmentManager(), "tag");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import java.math.BigDecimal;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@ -98,6 +99,7 @@ public class DialogInputQuantityV2ViewModel {
|
|||||||
|
|
||||||
private Listener mListener;
|
private Listener mListener;
|
||||||
|
|
||||||
|
private final ExecutorService executorService;
|
||||||
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
|
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
|
||||||
private final MagazzinoRESTConsumer mMagazzinoRESTConsumer;
|
private final MagazzinoRESTConsumer mMagazzinoRESTConsumer;
|
||||||
|
|
||||||
@ -106,7 +108,8 @@ public class DialogInputQuantityV2ViewModel {
|
|||||||
private List<MtbPartitaMag> mPartitaMagList;
|
private List<MtbPartitaMag> mPartitaMagList;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DialogInputQuantityV2ViewModel(BarcodeRESTConsumer barcodeRESTConsumer, MagazzinoRESTConsumer magazzinoRESTConsumer) {
|
public DialogInputQuantityV2ViewModel(ExecutorService executorService, BarcodeRESTConsumer barcodeRESTConsumer, MagazzinoRESTConsumer magazzinoRESTConsumer) {
|
||||||
|
this.executorService = executorService;
|
||||||
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
|
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
|
||||||
this.mMagazzinoRESTConsumer = magazzinoRESTConsumer;
|
this.mMagazzinoRESTConsumer = magazzinoRESTConsumer;
|
||||||
}
|
}
|
||||||
@ -515,142 +518,147 @@ public class DialogInputQuantityV2ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void validate(RunnableArgs<Boolean> onValidated) {
|
public void validate(RunnableArgs<Boolean> onValidated) {
|
||||||
if (this.internalQtaCnf == null || UtilityBigDecimal.equalsTo(this.internalQtaCnf, BigDecimal.ZERO)) {
|
executorService.execute(() -> {
|
||||||
|
|
||||||
this.sendError(new InvalidQtaCnfQuantityException());
|
|
||||||
onValidated.run(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!disableTracciabilitaCheck && mtbAart.get().isFlagTracciabilitaBoolean()) {
|
if (this.internalQtaCnf == null || UtilityBigDecimal.equalsTo(this.internalQtaCnf, BigDecimal.ZERO)) {
|
||||||
if (UtilityString.isNullOrEmpty(internalPartitaMag)) {
|
|
||||||
if (suggestPartitaMagRunnable != null) {
|
this.sendError(new InvalidQtaCnfQuantityException());
|
||||||
internalPartitaMag = suggestPartitaMagRunnable.run(this);
|
onValidated.run(false);
|
||||||
if (internalPartitaMag == null) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!disableTracciabilitaCheck && mtbAart.get().isFlagTracciabilitaBoolean()) {
|
||||||
|
if (UtilityString.isNullOrEmpty(internalPartitaMag)) {
|
||||||
|
if (suggestPartitaMagRunnable != null) {
|
||||||
|
internalPartitaMag = suggestPartitaMagRunnable.run(this);
|
||||||
|
if (internalPartitaMag == null) {
|
||||||
|
this.sendError(new InvalidBatchLotException());
|
||||||
|
onValidated.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
this.sendError(new InvalidBatchLotException());
|
this.sendError(new InvalidBatchLotException());
|
||||||
onValidated.run(false);
|
onValidated.run(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.sendError(new InvalidBatchLotException());
|
if (SettingsManager.iDB().isFlagWarningNewPartitaMag()) {
|
||||||
onValidated.run(false);
|
MtbPartitaMag mtbPartitaMag = null;
|
||||||
return;
|
try {
|
||||||
}
|
mtbPartitaMag = retrievePartitaMag(internalPartitaMag, this.getMtbAart().getCodMart());
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
if (SettingsManager.iDB().isFlagWarningNewPartitaMag()) {
|
this.sendError(e);
|
||||||
MtbPartitaMag mtbPartitaMag = null;
|
|
||||||
try {
|
|
||||||
mtbPartitaMag = retrievePartitaMag(internalPartitaMag, this.getMtbAart().getCodMart());
|
|
||||||
} catch (Exception e) {
|
|
||||||
this.sendError(e);
|
|
||||||
onValidated.run(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mtbPartitaMag == null) {
|
|
||||||
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.batch_lot_inexistent_error_message));
|
|
||||||
if (!result) {
|
|
||||||
onValidated.run(false);
|
onValidated.run(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mtbPartitaMag == null) {
|
||||||
|
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.batch_lot_inexistent_error_message));
|
||||||
|
if (!result) {
|
||||||
|
onValidated.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.statoArt == StatoPartitaMag.DISATTIVO) {
|
if (this.statoArt == StatoPartitaMag.DISATTIVO) {
|
||||||
boolean result = runWarningDialogSyncronized(String.format(UtilityResources.getString(R.string.batch_lot_not_enabled), internalPartitaMag));
|
boolean result = runWarningDialogSyncronized(String.format(UtilityResources.getString(R.string.batch_lot_not_enabled), internalPartitaMag));
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
onValidated.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.shouldAskDataScad && UtilityString.isNullOrEmpty(internalPartitaMag)) {
|
||||||
|
|
||||||
|
this.sendError(new InvalidBatchLotException());
|
||||||
onValidated.run(false);
|
onValidated.run(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shouldAskDataScad && UtilityString.isNullOrEmpty(internalPartitaMag)) {
|
if (this.shouldAskDataScad && this.internalDataScad == null) {
|
||||||
|
|
||||||
this.sendError(new InvalidBatchLotException());
|
this.sendError(new InvalidExpireDateException());
|
||||||
onValidated.run(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.shouldAskDataScad && this.internalDataScad == null) {
|
|
||||||
|
|
||||||
this.sendError(new InvalidExpireDateException());
|
|
||||||
onValidated.run(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.canOverflowOrderQuantity && UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaOrd) &&
|
|
||||||
this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
|
||||||
|
|
||||||
this.sendError(new OverflowQtaTotOrderedQuantityException());
|
|
||||||
onValidated.run(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.canOverflowOrderQuantity && UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfOrd) &&
|
|
||||||
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
|
||||||
|
|
||||||
this.sendError(new OverflowNumCnfOrderedQuantityException());
|
|
||||||
onValidated.run(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaAvailable)) {
|
|
||||||
|
|
||||||
this.sendError(new OverflowQtaTotAvailableQuantityException());
|
|
||||||
onValidated.run(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfAvailable) &&
|
|
||||||
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
|
||||||
|
|
||||||
this.sendError(new OverflowNumCnfAvailableQuantityException());
|
|
||||||
onValidated.run(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.canInputZeroQuantity && (this.internalNumCnf == null || this.internalQtaCnf == null || this.internalQtaTot == null ||
|
|
||||||
UtilityBigDecimal.equalsOrLowerThan(this.internalNumCnf, BigDecimal.ZERO) ||
|
|
||||||
UtilityBigDecimal.equalsOrLowerThan(this.internalQtaCnf, BigDecimal.ZERO) ||
|
|
||||||
UtilityBigDecimal.equalsOrLowerThan(this.internalQtaTot, BigDecimal.ZERO))) {
|
|
||||||
|
|
||||||
this.sendError(new InvalidQuantityException());
|
|
||||||
onValidated.run(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isNoteMandatory() && (this.internalNote == null || this.internalNote.length() <= 0)) {
|
|
||||||
this.sendError(new InvalidNotesException());
|
|
||||||
onValidated.run(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!UtilityString.isNullOrEmpty(this.internalPartitaMag))
|
|
||||||
this.internalPartitaMag = this.internalPartitaMag.toUpperCase();
|
|
||||||
|
|
||||||
if (this.warnOnQuantityOverflow && UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaOrd) &&
|
|
||||||
this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
|
||||||
|
|
||||||
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.confirm_ordered_quantity_overflow_error_message));
|
|
||||||
if (!result) {
|
|
||||||
onValidated.run(false);
|
onValidated.run(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.warnOnQuantityOverflow && UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfOrd) &&
|
if (!this.canOverflowOrderQuantity && UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaOrd) &&
|
||||||
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
||||||
|
|
||||||
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.confirm_ordered_num_cnf_overflow_error_message));
|
this.sendError(new OverflowQtaTotOrderedQuantityException());
|
||||||
if (!result) {
|
|
||||||
onValidated.run(false);
|
onValidated.run(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
onValidated.run(true);
|
if (!this.canOverflowOrderQuantity && UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfOrd) &&
|
||||||
|
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
||||||
|
|
||||||
|
this.sendError(new OverflowNumCnfOrderedQuantityException());
|
||||||
|
onValidated.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaAvailable)) {
|
||||||
|
|
||||||
|
this.sendError(new OverflowQtaTotAvailableQuantityException());
|
||||||
|
onValidated.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfAvailable) &&
|
||||||
|
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
||||||
|
|
||||||
|
this.sendError(new OverflowNumCnfAvailableQuantityException());
|
||||||
|
onValidated.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.canInputZeroQuantity && (this.internalNumCnf == null || this.internalQtaCnf == null || this.internalQtaTot == null ||
|
||||||
|
UtilityBigDecimal.equalsOrLowerThan(this.internalNumCnf, BigDecimal.ZERO) ||
|
||||||
|
UtilityBigDecimal.equalsOrLowerThan(this.internalQtaCnf, BigDecimal.ZERO) ||
|
||||||
|
UtilityBigDecimal.equalsOrLowerThan(this.internalQtaTot, BigDecimal.ZERO))) {
|
||||||
|
|
||||||
|
this.sendError(new InvalidQuantityException());
|
||||||
|
onValidated.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isNoteMandatory() && (this.internalNote == null || this.internalNote.length() <= 0)) {
|
||||||
|
this.sendError(new InvalidNotesException());
|
||||||
|
onValidated.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!UtilityString.isNullOrEmpty(this.internalPartitaMag))
|
||||||
|
this.internalPartitaMag = this.internalPartitaMag.toUpperCase();
|
||||||
|
|
||||||
|
if (this.warnOnQuantityOverflow && UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaOrd) &&
|
||||||
|
this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
||||||
|
|
||||||
|
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.confirm_ordered_quantity_overflow_error_message));
|
||||||
|
if (!result) {
|
||||||
|
onValidated.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.warnOnQuantityOverflow && UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfOrd) &&
|
||||||
|
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
|
||||||
|
|
||||||
|
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.confirm_ordered_num_cnf_overflow_error_message));
|
||||||
|
if (!result) {
|
||||||
|
onValidated.run(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onValidated.run(true);
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean runWarningDialogSyncronized(String text) {
|
private boolean runWarningDialogSyncronized(String text) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user