[ESSEGRANDE] Miglioramenti alla sync degli inventari
This commit is contained in:
parent
4317e083a6
commit
10f888b5d5
@ -97,7 +97,7 @@ public class InventarioRoomDTO extends BaseSyncDTO implements EntityModelInterfa
|
|||||||
private String zona;
|
private String zona;
|
||||||
|
|
||||||
@ColumnInfo(name = Columns.IS_NEW)
|
@ColumnInfo(name = Columns.IS_NEW)
|
||||||
private Boolean isNew;
|
private Boolean isNew = Boolean.TRUE;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
private List<InventarioRowRoomDTO> inventarioRowList;
|
private List<InventarioRowRoomDTO> inventarioRowList;
|
||||||
|
|||||||
@ -69,7 +69,8 @@ public class InventarioRepository extends _BaseRepository<MtbInvent, InventarioR
|
|||||||
resolveFetch(remoteData, internalLiveData.getValue(),
|
resolveFetch(remoteData, internalLiveData.getValue(),
|
||||||
(remoteItem, localItem) -> Objects.equals(remoteItem.getIdInventario(), localItem.getIdInventario()),
|
(remoteItem, localItem) -> Objects.equals(remoteItem.getIdInventario(), localItem.getIdInventario()),
|
||||||
(remoteItem, localItem) -> {
|
(remoteItem, localItem) -> {
|
||||||
remoteItem.setNew(true);
|
remoteItem.setRemoteSyncDate(localItem.getRemoteSyncDate());
|
||||||
|
remoteItem.setNew(false);
|
||||||
}, onComplete, onError);
|
}, onComplete, onError);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@ -75,6 +75,7 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
|
|||||||
getMenuInflater().inflate(R.menu.picking_inventario_menu, menu);
|
getMenuInflater().inflate(R.menu.picking_inventario_menu, menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -91,18 +92,19 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
|
|||||||
mViewModel.setListener(this);
|
mViewModel.setListener(this);
|
||||||
mBindings.setViewmodel(mViewModel);
|
mBindings.setViewmodel(mViewModel);
|
||||||
|
|
||||||
|
mViewModel.init(
|
||||||
|
DataCache.retrieveItem(getIntent().getStringExtra(KEY_INVENTARIO)),
|
||||||
|
DataCache.retrieveItem(getIntent().getStringExtra(KEY_INVENTARIO_ARTS)));
|
||||||
|
|
||||||
initToolbar();
|
initToolbar();
|
||||||
initBarcodeReader();
|
initBarcodeReader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
mViewModel.init(
|
|
||||||
DataCache.retrieveItem(getIntent().getStringExtra(KEY_INVENTARIO)),
|
|
||||||
DataCache.retrieveItem(getIntent().getStringExtra(KEY_INVENTARIO_ARTS)));
|
|
||||||
|
|
||||||
initRecyclerView();
|
initRecyclerView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +191,8 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
|
|||||||
|
|
||||||
public void requestExportConfirm() {
|
public void requestExportConfirm() {
|
||||||
DialogYesNoView.newInstance("Esporta", "Vuoi confermare e chiudere l'inventario?", result -> {
|
DialogYesNoView.newInstance("Esporta", "Vuoi confermare e chiudere l'inventario?", result -> {
|
||||||
mViewModel.exportAll(this::onBackPressed);
|
if (result == DialogConsts.Results.YES)
|
||||||
|
mViewModel.exportAll(this::onBackPressed);
|
||||||
})
|
})
|
||||||
.show(getSupportFragmentManager(), "tag");
|
.show(getSupportFragmentManager(), "tag");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,6 +111,11 @@ public class PickingInventarioViewModel extends ViewModel {
|
|||||||
|
|
||||||
|
|
||||||
public void exportAll(Runnable onComplete) {
|
public void exportAll(Runnable onComplete) {
|
||||||
|
if(this.currentInventarioRows.getValue().isEmpty()) {
|
||||||
|
this.sendError(new Exception("Impossibile esportare un inventario senza righe"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.sendOnLoadingStarted();
|
this.sendOnLoadingStarted();
|
||||||
currentInventario.getValue().setInventarioRowList(this.currentInventarioRows.getValue());
|
currentInventario.getValue().setInventarioRowList(this.currentInventarioRows.getValue());
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user