diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java index 9c031ad32a..70d5b53428 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java @@ -9,7 +9,6 @@ import android.widget.Toast; import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.services.commons.geojson.Feature; @@ -36,52 +35,44 @@ public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity { // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); - mapView.getMapAsync(new OnMapReadyCallback() { - @SuppressWarnings("ConstantConditions") - @Override - public void onMapReady(final MapboxMap mapboxMap) { - QueryRenderedFeaturesBoxCountActivity.this.mapboxMap = mapboxMap; - selectionBox.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - // Query - int top = selectionBox.getTop() - mapView.getTop(); - int left = selectionBox.getLeft() - mapView.getLeft(); - RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight()); - Timber.i(String.format("Querying box %s", box)); - List<Feature> features = mapboxMap.queryRenderedFeatures(box); - - // Show count - Toast.makeText( - QueryRenderedFeaturesBoxCountActivity.this, - String.format("%s features in box", features.size()), - Toast.LENGTH_SHORT).show(); - - // Debug output - debugOutput(features); - } - }); - } + mapView.getMapAsync(mapboxMap -> { + QueryRenderedFeaturesBoxCountActivity.this.mapboxMap = mapboxMap; + selectionBox.setOnClickListener(view -> { + // Query + int top = selectionBox.getTop() - mapView.getTop(); + int left = selectionBox.getLeft() - mapView.getLeft(); + RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight()); + Timber.i("Querying box %s", box); + List<Feature> features = mapboxMap.queryRenderedFeatures(box); + + // Show count + Toast.makeText( + QueryRenderedFeaturesBoxCountActivity.this, + String.format("%s features in box", features.size()), + Toast.LENGTH_SHORT).show(); + + // Debug output + debugOutput(features); + }); }); } private void debugOutput(List<Feature> features) { - Timber.i(String.format("Got %s features", features.size())); + Timber.i("Got %s features", features.size()); for (Feature feature : features) { if (feature != null) { - Timber.i(String.format("Got feature %s with %s properties and Geometry %s", + Timber.i("Got feature %s with %s properties and Geometry %s", feature.getId(), feature.getProperties() != null ? feature.getProperties().entrySet().size() : "<null>", - feature.getGeometry() != null ? feature.getGeometry().getClass().getSimpleName() : "<null>") + feature.getGeometry() != null ? feature.getGeometry().getClass().getSimpleName() : "<null>" ); if (feature.getProperties() != null) { for (Map.Entry<String, JsonElement> entry : feature.getProperties().entrySet()) { - Timber.i(String.format("Prop %s - %s", entry.getKey(), entry.getValue())); + Timber.i("Prop %s - %s", entry.getKey(), entry.getValue()); } } } else { - // TODO Question: Why not formatting here?? - Timber.i("Got NULL feature %s"); + Timber.i("Got 0 features"); } } } |