Hello everyone, I have the following problem, I read from a data array and what I want to do is go through the at create the geometry and send it through a feature service.
Everything works for me ok, except that my shipments are duplicated.
I am attaching my code to see if someone can help me.
private void sendData(){
ServiceFeatureTable featureTable;
featureTable = mServiceFeatureTable;
for (RepartoClass rep : arrayData){
Integer myId = rep.getId();
Map<String, Object> attributes = new HashMap<>();
attributes.put( "nis", rep.getNis() );
attributes.put( "valor_captura", rep.getCodigo() );
attributes.put( "empresa", empresa );
attributes.put( "modulo", rep.getTipo() );
attributes.put( "fecha", rep.getFecha() );
String oTipo;
oTipo = rep.getTipo();
Point oUbicacion = new Point( rep.getX(), rep.getY(), SpatialReference.create( 32719 ) );
featureTable.addDoneLoadingListener( () -> {
Feature feature = featureTable.createFeature( attributes, oUbicacion );
if (featureTable.canAdd()) {
myDeletes.add( myId );
//featureTable.addFeatureAsync( feature ).addDoneListener( () -> applyEdits( featureTable ) );
featureTable.addFeatureAsync( feature );
}
} );
}
featureTable.loadAsync();
final ListenableFuture<List<FeatureEditResult>> editResult = featureTable.applyEditsAsync();
editResult.addDoneListener( () -> {
try {
List<FeatureEditResult> editResults = editResult.get();
//Check if the server edit succeful
if (editResults != null && !editResults.isEmpty()) {
if (!editResults.get( 0 ).hasCompletedWithErrors()) {
} else {
throw editResults.get( 0 ).getError();
}
}
} catch (InterruptedException | ExecutionException e) {
runOnUiThread( () -> logToUser( true, "ErrorApply:" + e.getCause().getMessage() ) );
}
} );
}