diff options
author | Cameron Mace <cameron@mapbox.com> | 2016-08-31 11:56:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-31 11:56:57 -0400 |
commit | fe28b57fe08bcd1069dad8fd47827da6bd835285 (patch) | |
tree | 514e6af956d56634cd98cb5e44d7d49b7bd0d975 | |
parent | 1e2189266ffd9d831619f2c507f55596029fbec3 (diff) | |
download | qtlocation-mapboxgl-fe28b57fe08bcd1069dad8fd47827da6bd835285.tar.gz |
[android] added video view example (#6198)
* [android] added video view example
* removed map ready callback
5 files changed, 143 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 0c289b84e9..54949c08cd 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -301,6 +301,14 @@ android:value="@string/category_fragment" /> </activity> <activity + android:name=".activity.maplayout.VideoViewActivity" + android:description="@string/description_video_view" + android:label="@string/activity_video_view"> + <meta-data + android:name="@string/category" + android:value="@string/category_maplayout" /> + </activity> + <activity android:name=".activity.style.RuntimeStyleActivity" android:description="@string/description_runtime_style" android:label="@string/activity_runtime_style"> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/VideoViewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/VideoViewActivity.java new file mode 100644 index 0000000000..4496b257d3 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/VideoViewActivity.java @@ -0,0 +1,95 @@ +package com.mapbox.mapboxsdk.testapp.activity.maplayout; + +import android.media.MediaPlayer; +import android.net.Uri; +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 android.widget.VideoView; + +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; +import com.mapbox.mapboxsdk.testapp.R; + +import static android.media.MediaPlayer.*; + +public class VideoViewActivity extends AppCompatActivity { + + private MapView mapView; + private VideoView videoView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_video_view); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + final ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + } + + // Setup the video + videoView = (VideoView) findViewById(R.id.video_view); + videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.sea_waves)); + videoView.start(); + + // Used to repeat the video. + videoView.setOnPreparedListener(new OnPreparedListener() { + @Override + public void onPrepared(MediaPlayer mediaPlayer) { + mediaPlayer.setLooping(true); + } + }); + + mapView = (MapView) findViewById(R.id.map_view); + mapView.onCreate(savedInstanceState); + } + + @Override + public void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + public void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mapView.onLowMemory(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } + + @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/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_video_view.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_video_view.xml new file mode 100644 index 0000000000..25b589260e --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_video_view.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:mapbox="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".activity.maplayout.VideoViewActivity"> + + <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"/> + + <VideoView + android:id="@+id/video_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_margin="16dp"/> + + <com.mapbox.mapboxsdk.maps.MapView + android:id="@+id/map_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_below="@id/toolbar" + mapbox:center_latitude="34.4021" + mapbox:center_longitude="-119.7081" + mapbox:attribution_gravity="top" + mapbox:logo_gravity="top" + mapbox:style_url="mapbox://styles/mapbox/streets-v9" + mapbox:zoom="13"/> + +</RelativeLayout>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/sea_waves.mp4 b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/sea_waves.mp4 Binary files differnew file mode 100644 index 0000000000..ac2bcae016 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/sea_waves.mp4 diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index ed58d9ce8c..b6c19300c2 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -63,6 +63,7 @@ <string name="activity_query_rendered_features_box_highlight">Highlight features in box</string> <string name="activity_circle">Add Circle</string> <string name="activity_navigation_drawer">Android SDK View integration</string> + <string name="activity_video_view">Video View</string> <!-- Description --> <string name="description_user_location_tracking">Tracks the location of the user</string> @@ -110,6 +111,7 @@ <string name="description_query_rendered_features_box_count">Count all rendered features in box</string> <string name="description_query_rendered_features_box_highlight">Hightligh buildings in box</string> <string name="description_car_driving">MyLocationView follow map update example</string> + <string name="description_video_view">Android video view on top of the map view</string> <string name="menuitem_title_concurrent_infowindow">Concurrent Open InfoWindows</string> <string name="menuitem_title_deselect_markers_on_tap">Deselect Markers On Tap</string> |