Fix vari su Synchronized e MainThread
This commit is contained in:
parent
fb6a74aef8
commit
18937a3315
@ -99,8 +99,8 @@ public class MainApplicationModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer) {
|
||||
return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase, systemRESTConsumer, authenticationRESTConsumer);
|
||||
MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer, ExecutorService executorService, Handler handler) {
|
||||
return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase, systemRESTConsumer, authenticationRESTConsumer, executorService, handler);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package it.integry.integrywmsnative.core.context;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
@ -9,6 +10,7 @@ import android.text.SpannedString;
|
||||
import com.google.firebase.installations.FirebaseInstallations;
|
||||
|
||||
import java.net.ConnectException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@ -18,7 +20,6 @@ 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.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityThread;
|
||||
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
|
||||
|
||||
@Singleton
|
||||
@ -29,15 +30,19 @@ public class MainContext {
|
||||
private final AppDatabase appDatabase;
|
||||
private final SystemRESTConsumer systemRESTConsumer;
|
||||
private final AuthenticationRESTConsumer authenticationRESTConsumer;
|
||||
private final ExecutorService executorService;
|
||||
private final Handler handler;
|
||||
|
||||
private Listener mListener;
|
||||
|
||||
public MainContext(Context applicationContext, MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer) {
|
||||
public MainContext(Context applicationContext, MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer, ExecutorService executorService, Handler handler) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.menuService = menuService;
|
||||
this.appDatabase = appDatabase;
|
||||
this.systemRESTConsumer = systemRESTConsumer;
|
||||
this.authenticationRESTConsumer = authenticationRESTConsumer;
|
||||
this.executorService = executorService;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
@ -105,14 +110,16 @@ public class MainContext {
|
||||
|
||||
public void logout(Runnable onLoggedOut) {
|
||||
menuService.invalidateCache();
|
||||
UtilityThread.executeParallel(() -> {
|
||||
executorService.execute(() -> {
|
||||
SettingsManager.i().setUser(null);
|
||||
SettingsManager.i().setUserSession(null);
|
||||
SettingsManager.update();
|
||||
appDatabase.clearAllTables();
|
||||
|
||||
onLoggedOut.run();
|
||||
}, true);
|
||||
handler.post(() -> {
|
||||
onLoggedOut.run();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void initServerStatusChecker() {
|
||||
|
||||
@ -5,6 +5,7 @@ import android.content.pm.ActivityInfo;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.view.LayoutInflater;
|
||||
@ -77,6 +78,9 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
||||
@Inject
|
||||
DialogInputQuantityV2View mDialogInputQuantityV2View;
|
||||
|
||||
@Inject
|
||||
Handler handler;
|
||||
|
||||
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
|
||||
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(false);
|
||||
|
||||
@ -268,46 +272,49 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
||||
|
||||
@Override
|
||||
public void onFornitoriLoaded(ArrayList<FornitoreDTO> fornitoriList) {
|
||||
AutoCompleteFornitoreAdapter autoCompleteFornitoreAdapter = new AutoCompleteFornitoreAdapter(getActivity(), fornitoriList);
|
||||
mBinding.autoCompleteFornitori.setAdapter(autoCompleteFornitoreAdapter);
|
||||
mBinding.autoCompleteFornitori.setDropDownWidth(getActivity().getResources().getDisplayMetrics().widthPixels);
|
||||
handler.post(() -> {
|
||||
|
||||
mBinding.inputCodArtDescrForn.setOnEditorActionListener((v, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
resetAllError();
|
||||
AutoCompleteFornitoreAdapter autoCompleteFornitoreAdapter = new AutoCompleteFornitoreAdapter(getActivity(), fornitoriList);
|
||||
mBinding.autoCompleteFornitori.setAdapter(autoCompleteFornitoreAdapter);
|
||||
mBinding.autoCompleteFornitori.setDropDownWidth(getActivity().getResources().getDisplayMetrics().widthPixels);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(mBinding.autoCompleteFornitori.getText().toString())) {
|
||||
setError(mBinding.autoCompleteFornitoriLayout, getActivity().getResources().getText(R.string.error).toString());
|
||||
mBinding.inputCodArtDescrForn.setOnEditorActionListener((v, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
resetAllError();
|
||||
|
||||
if (UtilityString.isNullOrEmpty(mBinding.autoCompleteFornitori.getText().toString())) {
|
||||
setError(mBinding.autoCompleteFornitoriLayout, getActivity().getResources().getText(R.string.error).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(mBinding.inputCodArtDescrForn.getText().toString())) {
|
||||
setError(mBinding.layoutCodArtDescrForn, getActivity().getResources().getText(R.string.error).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
mViewModel.searchArtFor(
|
||||
mBinding.autoCompleteFornitori.getText().toString(),
|
||||
mBinding.inputCodArtDescrForn.getText().toString());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (UtilityString.isNullOrEmpty(mBinding.inputCodArtDescrForn.getText().toString())) {
|
||||
setError(mBinding.layoutCodArtDescrForn, getActivity().getResources().getText(R.string.error).toString());
|
||||
|
||||
mBinding.inputCodArtDescrInt.setOnEditorActionListener((v, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
resetAllError();
|
||||
|
||||
if (UtilityString.isNullOrEmpty(mBinding.inputCodArtDescrInt.getText().toString())) {
|
||||
setError(mBinding.layoutCodArtDescrInt, getActivity().getResources().getText(R.string.error).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
mViewModel.searchArtInt(mBinding.inputCodArtDescrInt.getText().toString(), null, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
mViewModel.searchArtFor(
|
||||
mBinding.autoCompleteFornitori.getText().toString(),
|
||||
mBinding.inputCodArtDescrForn.getText().toString());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
mBinding.inputCodArtDescrInt.setOnEditorActionListener((v, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
resetAllError();
|
||||
|
||||
if (UtilityString.isNullOrEmpty(mBinding.inputCodArtDescrInt.getText().toString())) {
|
||||
setError(mBinding.layoutCodArtDescrInt, getActivity().getResources().getText(R.string.error).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
mViewModel.searchArtInt(mBinding.inputCodArtDescrInt.getText().toString(), null, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -339,21 +346,25 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
||||
|
||||
@Override
|
||||
public void onLUOpened(MtbColt mtbColt) {
|
||||
initAdapter();
|
||||
handler.post(() -> {
|
||||
initAdapter();
|
||||
|
||||
this.currentMtbColtObs.set(mtbColt);
|
||||
thereIsAnOpenedUL.set(true);
|
||||
this.currentMtbColtObs.set(mtbColt);
|
||||
thereIsAnOpenedUL.set(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLUClosed() {
|
||||
destroyAdapter();
|
||||
handler.post(() -> {
|
||||
destroyAdapter();
|
||||
|
||||
this.currentMtbColtObs.set(null);
|
||||
thereIsAnOpenedUL.set(false);
|
||||
this.currentMtbColtObs.set(null);
|
||||
thereIsAnOpenedUL.set(false);
|
||||
|
||||
this.mViewModel.requestLU();
|
||||
/*if (getActivity() != null) ((IPoppableActivity) getActivity()).pop();*/
|
||||
this.mViewModel.requestLU();
|
||||
/*if (getActivity() != null) ((IPoppableActivity) getActivity()).pop();*/
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -426,7 +437,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
||||
mDialogInputQuantityV2View
|
||||
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||
.setOnComplete(resultDTO -> {
|
||||
if(resultDTO == null || resultDTO.isAborted()) return;
|
||||
if (resultDTO == null || resultDTO.isAborted()) return;
|
||||
|
||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||
.setNumCnf(resultDTO.getNumCnf())
|
||||
@ -458,7 +469,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
||||
@Override
|
||||
public void onRowSaved() {
|
||||
Snackbar.make(getView(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
||||
.setBackgroundTint(getResources().getColor(R. color. green_500))
|
||||
.setBackgroundTint(getResources().getColor(R.color.green_500))
|
||||
.show();
|
||||
}
|
||||
|
||||
|
||||
@ -1524,8 +1524,9 @@ public class SpedizioneViewModel {
|
||||
|
||||
MtbColr createdMtbColr = null;
|
||||
try {
|
||||
executeDepositChangeIfNeeded(refMtbColt);
|
||||
executeTipoUlChangeIfNeeded(refMtbColt);
|
||||
MtbColt sourceMtbColt = pickingObjectDTO.getTempPickData() != null ? pickingObjectDTO.getTempPickData().getSourceMtbColt() : null;
|
||||
executeDepositChangeIfNeeded(sourceMtbColt);
|
||||
executeTipoUlChangeIfNeeded(sourceMtbColt);
|
||||
|
||||
createdMtbColr = this.mColliScaricoRESTConsumer.insertUDSRowSynchronized(insertUDSRowRequestDto);
|
||||
} catch (Exception ex) {
|
||||
@ -2130,7 +2131,8 @@ public class SpedizioneViewModel {
|
||||
try {
|
||||
printClosedOrders(dto);
|
||||
} catch (Exception e) {
|
||||
this.sendLUPrintError(e, () -> {});
|
||||
this.sendLUPrintError(e, () -> {
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user