Esri / mapbook-android

App to replace paper maps for field work
Apache License 2.0
12 stars 13 forks source link

Highlighted feature not being replaced #8

Closed mikewilburn closed 7 years ago

mikewilburn commented 7 years ago

It seems there are occasions on which I can tap the map to identify a new feature, but the previously identified feature’s selection isn’t removed.

Unfortunately, I haven't been able to come up with steps to reproduce this yet. See the example below.

5_6_rightangledbracket_highlighting

mikewilburn commented 7 years ago

This still appears to be occurring. Usually tapping to identify features 10 or so times will reveal it. screenshot_20170505-075210

zinfin commented 7 years ago

@doneill Can you confirm that I'm correctly implementing logic for clearing selected features in the MapFragment?

    final LayerList layers = mMapView.getMap().getOperationalLayers();
    for (final Layer layer : layers){
      if (layer instanceof  FeatureLayer){
        ((FeatureLayer) layer).clearSelection();
      }
    }
zinfin commented 7 years ago

@doneill I think this works:

final LayerList layers = mMapView.getMap().getOperationalLayers();
    for (final Layer layer : layers){
      if (layer instanceof  FeatureLayer){
        final FeatureLayer featureLayer = (FeatureLayer)layer;

        final ListenableFuture<FeatureQueryResult> resultListenableFuture = featureLayer.getSelectedFeaturesAsync();
        resultListenableFuture.addDoneListener(new Runnable() {
          @Override public void run() {
            try {
              FeatureQueryResult result = resultListenableFuture.get();
              Iterator<Feature> iter = result.iterator();
              while (iter.hasNext()){
                featureLayer.unselectFeature(iter.next());

              }
              featureLayer.clearSelection();
            } catch (InterruptedException | ExecutionException e) {
              Log.i(TAG, e.getClass().getSimpleName() + " " + e.getMessage());
            }
          }
        });
        Log.i(TAG, "Clearing layer " + featureLayer.getName());
      }
    }
zinfin commented 7 years ago

@mikewilburn I've posted a fix for this in the latest apk file. Can you retest?

mikewilburn commented 7 years ago

Whereas I would have usually seen this within the first 20 or so seconds of tapping features, two minutes spent doing so with the latest version didn't show this behavior. Confirmed that this no longer occurs with the latest .apk.