Skip to content

Commit

Permalink
mapbox#2018 - Adding basic second activity that displays a map
Browse files Browse the repository at this point in the history
  • Loading branch information
bleege committed Sep 15, 2015
1 parent 742e209 commit 0ad05e3
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondMapActivity"/>
<meta-data
android:name="io.fabric.ApiKey"
android:value="9724157045ff7d083492c6d9ae03e60e8609d461" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mapbox.mapboxgl.testapp;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.PointF;
Expand Down Expand Up @@ -281,6 +282,10 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
menuItem.setChecked(mMapView.isCompassEnabled());
return true;

case R.id.action_second_map_activity:
startActivity(new Intent(getApplicationContext(), SecondMapActivity.class));
return true;

/*
case R.id.followNone:
mMapView.setUserLocationTrackingMode(MapView.UserLocationTrackingMode.NONE);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.mapbox.mapboxgl.testapp;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.mapbox.mapboxgl.views.MapView;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class SecondMapActivity extends AppCompatActivity {

private static final String TAG = "SecondMapActivity";

private MapView mMapView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_second);

mMapView = (MapView) findViewById(R.id.secondMapView);
// Load the access token
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.token)));
String line = reader.readLine();
mMapView.setAccessToken(line);
} catch (IOException e) {
Log.e(TAG, "Error loading access token from token.txt: " + e.toString());
}

mMapView.onCreate(savedInstanceState);

mMapView.setStyleUrl(getString(R.string.styleURLMapboxStreets));
}

/**
* Dispatch onStart() to all fragments. Ensure any created loaders are
* now started.
*/
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}

@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}

// Called when our app goes into the background
@Override
public void onPause() {
super.onPause();

mMapView.onPause();
}

// Called when our app comes into the foreground
@Override
public void onResume() {
super.onResume();

mMapView.onResume();
}

@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}

// Called when the system is running low on memory
@Override
public void onLowMemory() {
super.onLowMemory();

mMapView.onLowMemory();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.mapbox.mapboxgl.views.MapView
android:id="@+id/secondMapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@
android:checkable="true"
/>

<!--
<group android:id="@+id/locationFollowModesSeparator"/>
<item android:id="@+id/action_second_map_activity"
android:icon="@drawable/ic_looks_two_white_24dp"
android:title="@string/action_second_map_activity"
android:checkable="true"
/>

<group android:id="@+id/locationFollowModes" android:checkableBehavior="single">
<item android:id="@+id/followNone"
android:title="@string/action_location_none"/>
<item android:id="@+id/followFollow"
android:title="@string/action_location_follow"/>
<item android:id="@+id/followBearing"
android:title="@string/action_location_bearing"/>
</group>
-->
<!--
<group android:id="@+id/locationFollowModesSeparator"/>
<group android:id="@+id/locationFollowModes" android:checkableBehavior="single">
<item android:id="@+id/followNone"
android:title="@string/action_location_none"/>
<item android:id="@+id/followFollow"
android:title="@string/action_location_follow"/>
<item android:id="@+id/followBearing"
android:title="@string/action_location_bearing"/>
</group>
-->

<group android:id="@+id/stylesSeparator"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<string name="action_compass">Toggle compass</string>
<string name="action_debug">Toggle debug mode</string>
<string name="action_point_annotations">Toggle point annotations</string>
<string name="action_second_map_activity">Launch 2nd Map</string>

<string name="label_fps">FPS:</string>

Expand Down

0 comments on commit 0ad05e3

Please sign in to comment.