Esri/arcgis-runtime-samples-android

SketchGeometryChangedListener called multiple times with a valid geometry in FREEHAND_POLYGON creation mode

amansaryal opened this issue · 1 comments

I'm trying to trigger a Feature Query after the user finishes drawing the buffer polygon using FREEHAND_POLYGON creation mode.
I'm using SketchGeometryChangedListener callback to retrieve the buffer geometry.
BUT contrary to what I expected, the callback is called multiple times during the drawing process instead of being called
right at the end.

I can't see any flags in SketchEditor instance to determine if the drawing has finished and I don't want the user to explicitly give me that input using a button or something as that would be bad UX.

Is there anything that I might be missing here?

You can see the console log below.
I've printed a line everytime the listener was invoked in a single drag event to draw a freehand polygon.

2020-07-10 23:40:32.249 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.267 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.337 17139-17139/com.jio.templates I/chatty: uid=10174(com.jio.templates) identical 4 lines
2020-07-10 23:40:32.346 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.370 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.426 17139-17139/com.jio.templates I/chatty: uid=10174(com.jio.templates) identical 2 lines
2020-07-10 23:40:32.465 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.494 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.547 17139-17139/com.jio.templates I/chatty: uid=10174(com.jio.templates) identical 3 lines
2020-07-10 23:40:32.565 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.590 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.641 17139-17139/com.jio.templates I/chatty: uid=10174(com.jio.templates) identical 3 lines
2020-07-10 23:40:32.664 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.680 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.763 17139-17139/com.jio.templates I/chatty: uid=10174(com.jio.templates) identical 5 lines
2020-07-10 23:40:32.780 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.798 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.872 17139-17139/com.jio.templates I/chatty: uid=10174(com.jio.templates) identical 3 lines
2020-07-10 23:40:32.882 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.900 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.964 17139-17139/com.jio.templates I/chatty: uid=10174(com.jio.templates) identical 4 lines
2020-07-10 23:40:32.980 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:32.997 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:33.068 17139-17139/com.jio.templates I/chatty: uid=10174(com.jio.templates) identical 4 lines
2020-07-10 23:40:33.089 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:33.106 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:33.172 17139-17139/com.jio.templates I/chatty: uid=10174(com.jio.templates) identical 4 lines
2020-07-10 23:40:33.189 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:33.214 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:33.235 17139-17139/com.jio.templates I/chatty: uid=10174(com.jio.templates) identical 1 line
2020-07-10 23:40:33.248 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:33.248 17139-17153/com.jio.templates I/m.jio.template: Background concurrent copying GC freed 266221(11MB) AllocSpace objects, 23(388KB) LOS objects, 49% free, 6097KB/11MB, paused 1.760ms total 266.145ms
2020-07-10 23:40:33.271 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:33.285 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:33.306 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:33.380 17139-17139/com.jio.templates I/chatty: uid=10174(com.jio.templates) identical 2 lines
2020-07-10 23:40:33.397 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:33.433 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON
2020-07-10 23:40:33.440 17139-17139/com.jio.templates V/MapViewModelBase: SketchGeometryChangedListener: FREEHAND_POLYGON

We try to use this board for any bugs or issues found in one of the samples specifically. Can I ask you to pose your question and any follow up questions on https://community.esri.com/community/developers/native-app-developers/arcgis-runtime-sdk-for-android?

But a brief response to your question...have you tried using the .stop() command or checking the .isSketchValid() property? Following the patterns in this sample may help https://github.com/Esri/arcgis-runtime-samples-android/tree/master/java/sketch-editor