Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

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
Contributor

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
Contributor

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
Contributor

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants