-
Notifications
You must be signed in to change notification settings - Fork 493
Refactored MatrixApiActivity and XML #1187
base: master
Are you sure you want to change the base?
Conversation
List<Feature> renderedStationFeatures = mapboxMap.queryRenderedFeatures( | ||
mapboxMap.getProjection().toScreenLocation(point), LAYER_ID); | ||
if (!renderedStationFeatures.isEmpty()) { | ||
Point pointOfSelectedStation = (Point) renderedStationFeatures.get(0).geometry(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should assign the feature to be reused later, not the geometry.
matrixLocationList.get(x).setDistanceFromOrigin(finalConvertedFormattedDistance); | ||
matrixApiLocationRecyclerViewAdapter.notifyDataSetChanged(); | ||
if (response.body() != null) { | ||
List<Double[]> durationsToAllOfTheLocationsFromTheOrigin = response.body().durations(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are fetching durations, the title of the activity mentions time, but we're converting the data (which I understand is travel time) to distance. I think something's off here.
List<Feature> featureList = featureCollection.features(); | ||
for (int i = 0; i < featureList.size(); i++) { | ||
if (featureList.get(i).getStringProperty(STATION_NAME_PROPERTY).equals(selectedBoltFeatureName)) { | ||
makeMapboxMatrixApiCall(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The request could've been made during initialization and cached to be reused on map click.
aea0eba
to
4be4ff9
Compare
4be4ff9
to
0441d3a
Compare
if (pointOfSelectedStation != null) { | ||
String selectedBoltFeatureName = renderedStationFeatures.get(0).getStringProperty(STATION_NAME_PROPERTY); | ||
List<Feature> featureList = featureCollection.features(); | ||
for (int i = 0; i < featureList.size(); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NULL_DEREFERENCE: object featureList
last assigned on line 137 could be null and is dereferenced at line 138.
MatrixApiActivity
was using a bunch of deprecated Maps SDK classes and methods, such asaddMarker()
,setOnMarkerClickListener()
, etc.This pr brings this example up-to-date with
SymbolLayer
icons,onMapClick()
logic, adding null checks, etc. This pr gets rid of the final usage ofaddMarker()
🐛 🔨