diff options
author | Brad Leege <bleege@gmail.com> | 2015-11-09 16:55:07 -0600 |
---|---|---|
committer | Adam Hunter <adam@mapbox.com> | 2015-11-13 16:52:58 -0800 |
commit | 69a2b06e210bdba41d837d2a74e072cdfbf63020 (patch) | |
tree | ce71b89a4429082b529511792c403e9906ae41d1 /android | |
parent | 1c9d85e0de4df1f931e61e27518c6b05d7c016ef (diff) | |
download | qtlocation-mapboxgl-69a2b06e210bdba41d837d2a74e072cdfbf63020.tar.gz |
[android] #2931 - Creating basic Activity for Manual Zoom
Diffstat (limited to 'android')
2 files changed, 107 insertions, 0 deletions
diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/ManualZoomActivity.java b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/ManualZoomActivity.java new file mode 100644 index 0000000000..841cfa6a69 --- /dev/null +++ b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/ManualZoomActivity.java @@ -0,0 +1,88 @@ +package com.mapbox.mapboxsdk.testapp; + +import android.os.Bundle; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.MenuItem; +import com.mapbox.mapboxsdk.constants.Style; +import com.mapbox.mapboxsdk.utils.ApiAccess; +import com.mapbox.mapboxsdk.views.MapView; + +public class ManualZoomActivity extends AppCompatActivity { + + private MapView mMapView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_manual_zoom); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + } + + mMapView = (MapView) findViewById(R.id.manualZoomMapView); + mMapView.setAccessToken(ApiAccess.getToken(this)); + mMapView.setStyle(Style.MAPBOX_STREETS); + mMapView.onCreate(savedInstanceState); + } + + @Override + protected void onStart() { + super.onStart(); + mMapView.onStart(); + } + + @Override + public void onResume() { + super.onResume(); + mMapView.onResume(); + } + + @Override + public void onPause() { + super.onPause(); + mMapView.onPause(); + } + + @Override + protected void onStop() { + super.onStop(); + mMapView.onStop(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mMapView.onSaveInstanceState(outState); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mMapView.onDestroy(); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mMapView.onLowMemory(); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } +} diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml b/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml new file mode 100644 index 0000000000..70f38875a2 --- /dev/null +++ b/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <android.support.v7.widget.Toolbar + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + android:background="@color/primary" + android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> + + <com.mapbox.mapboxsdk.views.MapView + android:id="@+id/manualZoomMapView" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + +</LinearLayout> |