summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2018-03-22 08:00:16 -0400
committerTobrun <tobrun.van.nuland@gmail.com>2018-03-22 08:00:16 -0400
commit9b190e272e39fb34a32af5fbe269d2a9bcae4bd7 (patch)
tree2f23c1bcc18067d989f7571ffd5dd660714b6d99
parenta2250098f5dc39a4486555e35823d634a8d0b786 (diff)
downloadqtlocation-mapboxgl-upstream/tvn-fps-test.tar.gz
[android] - small fps testupstream/tvn-fps-test
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java
index 8f8a5af3cc..b9402fdb95 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java
@@ -1,17 +1,27 @@
package com.mapbox.mapboxsdk.testapp.activity.maplayout;
import android.os.Bundle;
+import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
+import com.mapbox.mapboxsdk.camera.CameraPosition;
+import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
+import com.mapbox.mapboxsdk.geometry.LatLng;
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 timber.log.Timber;
+
/**
* Test activity showcasing a simple MapView without any MapboxMap interaction.
*/
public class SimpleMapActivity extends AppCompatActivity {
private MapView mapView;
+ private double fpsCount;
+ private int fpsEventCount;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -20,6 +30,56 @@ public class SimpleMapActivity extends AppCompatActivity {
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
+
+ mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(final MapboxMap mapboxMap) {
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ runFpsAnimationTest(mapboxMap);
+ }
+ }, 3000);
+ }
+ });
+ }
+
+ private void runFpsAnimationTest(MapboxMap mapboxMap) {
+ mapboxMap.setOnFpsChangedListener(new MapboxMap.OnFpsChangedListener() {
+
+ // ignore first fps value
+ private boolean isFirstEvent = true;
+
+ @Override
+ public void onFpsChanged(double fps) {
+ if (isFirstEvent) {
+ isFirstEvent = false;
+ return;
+ }
+
+ Timber.e("FPS: %s", fps);
+ fpsCount += fps;
+ fpsEventCount++;
+ }
+ });
+
+ mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder()
+ .target(new LatLng(-0.719470, 8.752940))
+ .zoom(16)
+ .build()),
+ 5000, new MapboxMap.CancelableCallback() {
+ @Override
+ public void onCancel() {
+
+ }
+
+ @Override
+ public void onFinish() {
+ double averageFps = fpsCount / fpsEventCount;
+ Timber.e("Average FPS: %s", averageFps);
+ }
+ });
}
@Override