diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index e6d118692..13160878f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -593,6 +593,20 @@ android:value=".activity.FeatureOverviewActivity"/> + + + + + + + + * Alternatively, unregister the callback in {@link Activity#onDestroy()} + */ + private static final class Transform implements FileSource.ResourceTransformCallback { + @Override + public String onURL(@Resource.Kind int kind, String url) { + Timber.i("[%s] Could be rewriting %s", Thread.currentThread().getName(), url); + return url; + } + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_data_driven_style); + + // Initialize map as normal + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + + // Get a handle to the file source and set the resource transform + FileSource.getInstance(UrlTransformActivity.this).setResourceTransform(new Transform()); + + mapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(MapboxMap map) { + Timber.i("Map loaded"); + } + }); + } + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + protected void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + protected void onStop() { + super.onStop(); + mapView.onStop(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + + // Example of how to reset the transform callback + FileSource.getInstance(UrlTransformActivity.this).setResourceTransform(null); + + mapView.onDestroy(); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mapView.onLowMemory(); + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index f15ee20be..ac5c528c3 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -54,6 +54,7 @@ Simple Map Dialog with map Marker views in rectangle + Url transform Tracks the location of the user @@ -107,6 +108,7 @@ Display a map inside a dialog fragment Marker Views within a rectangle Show bus stops and route in Singapore + Transform urls on the fly category @@ -122,6 +124,7 @@ User Location Styling Features + Storage Remove polylines