diff options
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java | 60 |
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 |