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

Added traffic plugin example #385

Merged
merged 9 commits into from
Jun 28, 2017
Merged

Added traffic plugin example #385

merged 9 commits into from
Jun 28, 2017

Conversation

langsmith
Copy link
Contributor

Fixes #223

Added this example and put it in a new Plugins section

ezgif com-resize

@langsmith langsmith requested a review from cammace June 27, 2017 20:56
@@ -125,6 +125,13 @@
android:value="com.mapbox.mapboxandroiddemo.MainActivity"/>
</activity>
<activity
android:name=".examples.plugins.TrafficPluginActivity"
android:label="@string/activity_mas_traffic_plugin_title">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets change this title activity_mas_traffic_plugin_title to activity_plugin_traffic_title

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

case R.id.nav_plugins:
exampleItemModel.add(new ExampleItemModel(
R.string.activity_mas_traffic_plugin_title,
R.string.activity_mas_traffic_plugin_description,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activity_plugin_traffic_description

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -343,6 +344,16 @@ private void listItems(int id) {
currentCategory = R.id.nav_extrusions;
break;

case R.id.nav_plugins:
exampleItemModel.add(new ExampleItemModel(
R.string.activity_mas_traffic_plugin_title,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activity_plugin_traffic_title

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

R.string.activity_mas_traffic_plugin_title,
R.string.activity_mas_traffic_plugin_description,
new Intent(MainActivity.this, TrafficPluginActivity.class),
R.string.activity_mas_traffic_plugin_url
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activity_plugin_traffic_url

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
TrafficPluginActivity.this.map = mapboxMap;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to clarify the variable location since it's a different name then the local mapboxMap, TrafficPluginActivity.this.map should just be map = mapboxMap;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@Override
public void onMapReady(MapboxMap mapboxMap) {
TrafficPluginActivity.this.map = mapboxMap;
TrafficPluginActivity.this.trafficPlugin = new TrafficPlugin(mapView, mapboxMap);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes for this traffic plugin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
});

FloatingActionButton trafficToggleButton = (FloatingActionButton) findViewById(R.id.traffic_toggle_fab);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you only need to fab id to set the listener, you can make this shorter by directly getting the fab and setting the click listener: findViewById(R.id.traffic_toggle_fab).setOnClickListener(...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get hit with the error below:

screen shot 2017-06-27 at 9 36 28 pm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't assign it to a variable. You are trying to cast a click listener floating action button. remove everything in front of findViewById

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seperate <android.support.constraint.ConstraintLayout and xmlns:android="http://schemas.android.com/apk/res/android" onto different lines so the indentions proper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

mapbox:mapbox_cameraZoom="9.579712"
mapbox:mapbox_styleUrl="@string/mapbox_style_dark"/>

<android.support.design.widget.FloatingActionButton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the vector icons black, lets tint it to white instead so it matches the UI a bit more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

build.gradle Outdated
@@ -11,6 +11,7 @@ buildscript {
allprojects {
repositories {
jcenter()
mavenCentral()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for including the new repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it because that's what the plugin instructions seemed to say. Maybe I misread/misunderstood though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JCenter is a superset of Maven Central, therefore, if JCenter is in your repository, you most likely won't need to also include mavenCentral.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@langsmith langsmith merged commit 9de34e7 into master Jun 28, 2017
@langsmith langsmith deleted the ls-traffic-plugin-example branch June 28, 2017 21:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants