Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored MatrixApiActivity and XML #1187

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

langsmith
Copy link
Contributor

MatrixApiActivity was using a bunch of deprecated Maps SDK classes and methods, such as addMarker(), 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 of addMarker() 🐛 🔨

List<Feature> renderedStationFeatures = mapboxMap.queryRenderedFeatures(
mapboxMap.getProjection().toScreenLocation(point), LAYER_ID);
if (!renderedStationFeatures.isEmpty()) {
Point pointOfSelectedStation = (Point) renderedStationFeatures.get(0).geometry();
Copy link
Member

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();
Copy link
Member

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);
Copy link
Member

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.

@langsmith langsmith force-pushed the ls-matrixapi-refactor branch 2 times, most recently from aea0eba to 4be4ff9 Compare September 4, 2019 22:15
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++) {
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants