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