BoundaryLayer extends KujakuLayer { @Override public void updateFeatures(@NonNull FeatureCollection featureCollection) { this.builder.featureCollection = featureCollection; if (boundaryLabelLayer != null) { GenericAsyncTask genericAsyncTask = new GenericAsyncTask(new AsyncTaskCallable() { @Override public Object[] call() throws Exception { return new Object[]{calculateCenterPoints(builder.featureCollection)}; } }); genericAsyncTask.setOnFinishedListener(new OnFinishedListener() { @Override public void onSuccess(Object[] objects) { FeatureCollection boundaryCenterFeatures = (FeatureCollection) objects[0]; boundaryLabelsSource.setGeoJson(boundaryCenterFeatures); boundarySource.setGeoJson(featureCollection); } @Override public void onError(Exception e) { Log.e(TAG, Log.getStackTraceString(e)); } }); genericAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } BoundaryLayer(@NonNull KujakuLayer.Builder builder); void updateLineLayerProperties(@NonNull PropertyValue<?>... properties); @Override void addLayerToMap(@NonNull MapboxMap mapboxMap); @Override void enableLayerOnMap(@NonNull MapboxMap mapboxMap); @Override void disableLayerOnMap(@NonNull MapboxMap mapboxMap); @Override @NonNull String[] getLayerIds(); @Override boolean removeLayerOnMap(@NonNull MapboxMap mapboxMap); @Override void updateFeatures(@NonNull FeatureCollection featureCollection); @Override FeatureCollection getFeatureCollection();  }
@Test public void updateFeaturesShouldUpdateFeatureCollection() { float textSize = 20f; float boundaryWidth = 6f; int colorInt = Color.GREEN; String labelProperty = "district-name"; FeatureCollection featureCollection = FeatureCollection.fromFeatures(new ArrayList<Feature>()); BoundaryLayer.Builder builder = new BoundaryLayer.Builder(featureCollection) .setLabelProperty(labelProperty) .setLabelTextSize(textSize) .setLabelColorInt(colorInt) .setBoundaryColor(colorInt) .setBoundaryWidth(boundaryWidth); BoundaryLayer boundaryLayer = builder.build(); FeatureCollection updatedFeatureCollection = FeatureCollection.fromFeatures(new ArrayList<Feature>()); boundaryLayer.updateFeatures(updatedFeatureCollection); assertEquals(updatedFeatureCollection, ReflectionHelpers.getField( ReflectionHelpers.getField(boundaryLayer, "builder"), "featureCollection") ); }