Refactor: Update weight input dialog and LU closing logic
- Changed `DialogInputPesoLUView` to use `BindableBigDecimal` for weight fields. - Updated `DialogInputPesoLUView` to invoke onComplete only after user confirmation - Refactored `SpedizioneViewModel` to correctly set values coming from the weight input dialog - Removed commented-out code in `SpedizioneViewModel` - Added handling for null values in weight fields. - `SpedizioneActivity` changed to pass current values to `DialogInputPesoLUView` - Fixed recovery mode UI not collapsing
This commit is contained in:
parent
645045b492
commit
0312f972bc
@ -6,6 +6,7 @@ import android.animation.ObjectAnimator;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -70,6 +71,8 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
|||||||
@Inject
|
@Inject
|
||||||
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer;
|
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Handler handler;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
MenuService menuService;
|
MenuService menuService;
|
||||||
@ -267,7 +270,9 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void endRecoverMode() {
|
private void endRecoverMode() {
|
||||||
|
handler.post(() -> {
|
||||||
mBindings.recoverDataExpandableLayout.collapse(true);
|
mBindings.recoverDataExpandableLayout.collapse(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -865,9 +865,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
@Override
|
@Override
|
||||||
public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete) {
|
public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete) {
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
DialogInputPesoLUView.newInstance(null, new BigDecimal(50), new BigDecimal(55), (newCodTcol, newNetWeight, newGrossWeight) -> {
|
DialogInputPesoLUView.newInstance(codTcol, netWeightKG, grossWeightKG, onComplete)
|
||||||
onComplete.run(newCodTcol, netWeightKG, grossWeightKG);
|
|
||||||
})
|
|
||||||
.show(getSupportFragmentManager(), "tag");
|
.show(getSupportFragmentManager(), "tag");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1682,92 +1682,6 @@ public class SpedizioneViewModel {
|
|||||||
this.sendOnLoadingEnded();
|
this.sendOnLoadingEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void requestCloseLU(boolean shouldPrint) throws Exception {
|
|
||||||
// if (mCurrentMtbColt == null) return;
|
|
||||||
// this.sendOnLoadingStarted();
|
|
||||||
//
|
|
||||||
// var shouldBeDeleted = this.shouldUlBeDeleted();
|
|
||||||
// if (shouldBeDeleted) {
|
|
||||||
// deleteLU();
|
|
||||||
//
|
|
||||||
// this.mCurrentMtbColt = null;
|
|
||||||
//
|
|
||||||
// if (mMtbColtSessionID != null)
|
|
||||||
// this.mColliDataRecoverService.closeSession(mMtbColtSessionID);
|
|
||||||
//
|
|
||||||
// this.mIsNewLU = false;
|
|
||||||
// this.sendLUClosed();
|
|
||||||
// this.sendOnLoadingEnded();
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// var askInfoAggiuntiveFuture = Futures.transformAsync(
|
|
||||||
// askPeso(),
|
|
||||||
// voidResult -> askInfoAggiuntive(),
|
|
||||||
// executorService
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// var closeLuFuture = Futures.transformAsync(
|
|
||||||
// askInfoAggiuntiveFuture,
|
|
||||||
// voidResult -> closeLU(),
|
|
||||||
// executorService
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// var duplicateUlFuture = Futures.transformAsync(
|
|
||||||
// closeLuFuture,
|
|
||||||
// generatedMtbColts -> validateTheUdsToBeDuplicated(generatedMtbColts),
|
|
||||||
// executorService
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// var filledMtbColtFuture = Futures.transformAsync(
|
|
||||||
// duplicateUlFuture,
|
|
||||||
// duplicatedMtbColts -> {
|
|
||||||
// SettableFuture<List<MtbColt>> future = SettableFuture.create();
|
|
||||||
// this.mColliMagazzinoRESTConsumer.fillMtbAartsOfMtbColts(duplicatedMtbColts,
|
|
||||||
// future::set,
|
|
||||||
// future::setException);
|
|
||||||
//
|
|
||||||
// return future;
|
|
||||||
// },
|
|
||||||
// executorService
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// var askPosizioneFuture = Futures.transformAsync(filledMtbColtFuture,
|
|
||||||
// this::askPositionChange,
|
|
||||||
// executorService);
|
|
||||||
//
|
|
||||||
// var askPrintFuture = Futures.transformAsync(askPosizioneFuture,
|
|
||||||
// mtbColts -> askPrint(shouldPrint && SettingsManager.iDB().isFlagPrintEtichetteOnLUClose(), mtbColts),
|
|
||||||
// executorService);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Futures.addCallback(askPrintFuture, new FutureCallback<>() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess(List<MtbColt> result) {
|
|
||||||
// handler.post(() -> {
|
|
||||||
// result.stream()
|
|
||||||
// .filter(x -> !mColliRegistrati.contains(x))
|
|
||||||
// .forEach(x -> mColliRegistrati.add(x));
|
|
||||||
//
|
|
||||||
// postCloseOperations(result);
|
|
||||||
//
|
|
||||||
// mIsNewLU = false;
|
|
||||||
//
|
|
||||||
// resetMatchedRows();
|
|
||||||
// sendLUClosed();
|
|
||||||
// sendOnLoadingEnded();
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onFailure(Throwable throwable) {
|
|
||||||
// sendError(new Exception(throwable));
|
|
||||||
// }
|
|
||||||
// }, executorService);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void requestCloseLU(boolean shouldPrint) throws Exception {
|
public void requestCloseLU(boolean shouldPrint) throws Exception {
|
||||||
if (mCurrentMtbColt == null) return;
|
if (mCurrentMtbColt == null) return;
|
||||||
this.sendOnLoadingStarted();
|
this.sendOnLoadingStarted();
|
||||||
@ -1948,9 +1862,10 @@ public class SpedizioneViewModel {
|
|||||||
this.sendLUPesoRequired(mCurrentMtbColt.getCodTcol(), mCurrentMtbColt.getPesoNettoKg(), mCurrentMtbColt.getPesoKg(),
|
this.sendLUPesoRequired(mCurrentMtbColt.getCodTcol(), mCurrentMtbColt.getPesoNettoKg(), mCurrentMtbColt.getPesoKg(),
|
||||||
(newCodTcol, newNetWeight, newGrossWeight) -> {
|
(newCodTcol, newNetWeight, newGrossWeight) -> {
|
||||||
|
|
||||||
mCurrentMtbColt.setCodTcol(newCodTcol);
|
|
||||||
mCurrentMtbColt.setPesoNettoKg(newNetWeight);
|
if(newCodTcol != null) mCurrentMtbColt.setCodTcol(newCodTcol);
|
||||||
mCurrentMtbColt.setPesoKg(newGrossWeight);
|
if(newNetWeight != null) mCurrentMtbColt.setPesoNettoKg(newNetWeight);
|
||||||
|
if(newGrossWeight != null) mCurrentMtbColt.setPesoKg(newGrossWeight);
|
||||||
|
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
});
|
});
|
||||||
@ -2047,6 +1962,7 @@ public class SpedizioneViewModel {
|
|||||||
|
|
||||||
this.sendLUPrintRequest(shouldPrint -> {
|
this.sendLUPrintRequest(shouldPrint -> {
|
||||||
if (!shouldPrint) {
|
if (!shouldPrint) {
|
||||||
|
latch.countDown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import it.integry.integrywmsnative.MainApplication;
|
import it.integry.integrywmsnative.MainApplication;
|
||||||
import it.integry.integrywmsnative.R;
|
import it.integry.integrywmsnative.R;
|
||||||
|
import it.integry.integrywmsnative.core.di.BindableBigDecimal;
|
||||||
import it.integry.integrywmsnative.core.di.BindableString;
|
import it.integry.integrywmsnative.core.di.BindableString;
|
||||||
import it.integry.integrywmsnative.core.expansion.BaseDialogFragment;
|
import it.integry.integrywmsnative.core.expansion.BaseDialogFragment;
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgsss;
|
import it.integry.integrywmsnative.core.expansion.RunnableArgsss;
|
||||||
@ -27,7 +28,6 @@ import it.integry.integrywmsnative.core.model.MtbTCol;
|
|||||||
import it.integry.integrywmsnative.core.model.observable.ObservableMtbTcol;
|
import it.integry.integrywmsnative.core.model.observable.ObservableMtbTcol;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.ImballiRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.ImballiRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityNumber;
|
|
||||||
import it.integry.integrywmsnative.databinding.DialogInputPesoLuBinding;
|
import it.integry.integrywmsnative.databinding.DialogInputPesoLuBinding;
|
||||||
|
|
||||||
public class DialogInputPesoLUView extends BaseDialogFragment {
|
public class DialogInputPesoLUView extends BaseDialogFragment {
|
||||||
@ -44,8 +44,8 @@ public class DialogInputPesoLUView extends BaseDialogFragment {
|
|||||||
private RunnableArgsss<String, BigDecimal, BigDecimal> onDialogDismiss;
|
private RunnableArgsss<String, BigDecimal, BigDecimal> onDialogDismiss;
|
||||||
|
|
||||||
public BindableString codTcol = new BindableString();
|
public BindableString codTcol = new BindableString();
|
||||||
public BindableString netWeight = new BindableString();
|
public BindableBigDecimal netWeight = new BindableBigDecimal();
|
||||||
public BindableString grossWeight = new BindableString();
|
public BindableBigDecimal grossWeight = new BindableBigDecimal();
|
||||||
|
|
||||||
|
|
||||||
private List<ObservableMtbTcol> codTcolList = null;
|
private List<ObservableMtbTcol> codTcolList = null;
|
||||||
@ -62,8 +62,8 @@ public class DialogInputPesoLUView extends BaseDialogFragment {
|
|||||||
this.onDialogDismiss = onDialogDismiss;
|
this.onDialogDismiss = onDialogDismiss;
|
||||||
|
|
||||||
this.codTcol.set(codTcol);
|
this.codTcol.set(codTcol);
|
||||||
this.netWeight.set(UtilityNumber.decimalToString(netWeight));
|
this.netWeight.set(netWeight);
|
||||||
this.grossWeight.set(UtilityNumber.decimalToString(grossWeight));
|
this.grossWeight.set(grossWeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -88,6 +88,12 @@ public class DialogInputPesoLUView extends BaseDialogFragment {
|
|||||||
var alertDialog = new MaterialAlertDialogBuilder(this.mContext)
|
var alertDialog = new MaterialAlertDialogBuilder(this.mContext)
|
||||||
.setView(mBindings.getRoot())
|
.setView(mBindings.getRoot())
|
||||||
.setCancelable(isCancelable())
|
.setCancelable(isCancelable())
|
||||||
|
.setPositiveButton(R.string.confirm, (dialogInterface, i) -> {
|
||||||
|
onDialogDismiss.run(codTcol.get(), netWeight.get(), grossWeight.get());
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.abort, ((dialogInterface, i) -> {
|
||||||
|
onDialogDismiss.run(null, null, null);
|
||||||
|
}))
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
alertDialog.setCanceledOnTouchOutside(isCancelable());
|
alertDialog.setCanceledOnTouchOutside(isCancelable());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user