Migliorata gestione errori in versamento merce

This commit is contained in:
Giuseppe Scorrano 2021-11-26 10:31:33 +01:00
parent c012c54805
commit 80842e49e5
3 changed files with 33 additions and 22 deletions

View File

@ -22,8 +22,6 @@ public abstract class BaseFragment extends Fragment {
protected final List<Runnable> mOnPreDestroyList = new ArrayList<>();
public void setScrollToolbar(ElevatedToolbar toolbar) {
mToolbar = toolbar;
}
@ -34,10 +32,6 @@ public abstract class BaseFragment extends Fragment {
}
public void onLoadingStarted() {
new Thread(() -> {
BarcodeManager.disable();
@ -88,6 +82,8 @@ public abstract class BaseFragment extends Fragment {
}
protected void popMe() {
getActivity().runOnUiThread(() -> {
((IPoppableActivity) requireActivity()).pop();
});
}
}

View File

@ -319,6 +319,12 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
this.openLU();
}
@Override
public void onError(Exception ex, boolean requestClose) {
super.onError(ex);
if(requestClose) popMe();
}
@Override
public void onWarning(String warningText, Runnable action) {
this.requireActivity().runOnUiThread(() -> {

View File

@ -77,8 +77,13 @@ public class ProdVersamentoMaterialeViewModel {
mtbDepoPosizione.getPosizione(),
getIdMaterialeFromCollo(mtbColt),
ordini -> {
if(ordini == null || ordini.isEmpty())
this.sendError(new Exception("Nessun ordine compatibile con " + getIdMaterialeFromCollo(mtbColt) + " sulla linea " + mtbDepoPosizione.getPosizione()), true);
else {
setCurrentOrders(ordini, mtbColt.getMtbColr().get(0));
this.sendOnLoadingEnded();
}
},
e -> this.sendWarning(e.getMessage(), this::sendRequestLUOpen));
}
@ -194,7 +199,11 @@ public class ProdVersamentoMaterialeViewModel {
}
private void sendError(Exception ex) {
if (this.mListener != null) mListener.onError(ex);
if (this.mListener != null) mListener.onError(ex, false);
}
private void sendError(Exception ex, boolean requestClose) {
if (this.mListener != null) mListener.onError(ex, requestClose);
}
private void sendOnDataSaved() {
@ -205,7 +214,7 @@ public class ProdVersamentoMaterialeViewModel {
void requestLUOpen();
void onError(Exception ex);
void onError(Exception ex, boolean requestClose);
void onWarning(String warningText, Runnable action);