Add extra observer hooks for interesting internal processes (#2694)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.maplibre.android.maps;
|
||||
|
||||
import org.maplibre.android.log.Logger;
|
||||
import org.maplibre.android.tile.TileOperation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@@ -35,6 +36,26 @@ class MapChangeReceiver implements NativeMapView.StateCallback {
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final List<MapView.OnCanRemoveUnusedStyleImageListener> onCanRemoveUnusedStyleImageListenerList
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final List<MapView.OnPreCompileShaderListener> onPreCompileShaderList
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final List<MapView.OnPostCompileShaderListener> onPostCompileShaderList
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final List<MapView.OnShaderCompileFailedListener> onShaderCompileFailedList
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final List<MapView.OnGlyphsLoadedListener> onGlyphsLoadedList
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final List<MapView.OnGlyphsErrorListener> onGlyphsErrorList
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final List<MapView.OnGlyphsRequestedListener> onGlyphsRequestedList
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final List<MapView.OnTileActionListener> onTileActionList
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final List<MapView.OnSpriteLoadedListener> onSpriteLoadedList
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final List<MapView.OnSpriteErrorListener> onSpriteErrorList
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final List<MapView.OnSpriteRequestedListener> onSpriteRequestedList
|
||||
= new CopyOnWriteArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onCameraWillChange(boolean animated) {
|
||||
@@ -255,6 +276,146 @@ class MapChangeReceiver implements NativeMapView.StateCallback {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPreCompileShader(int id, int type, String additionalDefines) {
|
||||
try {
|
||||
if (!onPreCompileShaderList.isEmpty()) {
|
||||
for (MapView.OnPreCompileShaderListener listener : onPreCompileShaderList) {
|
||||
listener.onPreCompileShader(id, type, additionalDefines);
|
||||
}
|
||||
}
|
||||
} catch (Throwable err) {
|
||||
Logger.e(TAG, "Exception in onPreCompileShader", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostCompileShader(int id, int type, String additionalDefines) {
|
||||
try {
|
||||
if (!onPostCompileShaderList.isEmpty()) {
|
||||
for (MapView.OnPostCompileShaderListener listener : onPostCompileShaderList) {
|
||||
listener.onPostCompileShader(id, type, additionalDefines);
|
||||
}
|
||||
}
|
||||
} catch (Throwable err) {
|
||||
Logger.e(TAG, "Exception in onPostCompileShader", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShaderCompileFailed(int id, int type, String additionalDefines) {
|
||||
try {
|
||||
if (!onShaderCompileFailedList.isEmpty()) {
|
||||
for (MapView.OnShaderCompileFailedListener listener : onShaderCompileFailedList) {
|
||||
listener.onShaderCompileFailed(id, type, additionalDefines);
|
||||
}
|
||||
}
|
||||
} catch (Throwable err) {
|
||||
Logger.e(TAG, "Exception in onShaderCompileFailed", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGlyphsLoaded(String[] stack, int rangeStart, int rangeEnd) {
|
||||
try {
|
||||
if (!onGlyphsLoadedList.isEmpty()) {
|
||||
for (MapView.OnGlyphsLoadedListener listener : onGlyphsLoadedList) {
|
||||
listener.onGlyphsLoaded(stack, rangeStart, rangeEnd);
|
||||
}
|
||||
}
|
||||
} catch (Throwable err) {
|
||||
Logger.e(TAG, "Exception in onGlyphsLoaded", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGlyphsError(String[] stack, int rangeStart, int rangeEnd) {
|
||||
try {
|
||||
if (!onGlyphsErrorList.isEmpty()) {
|
||||
for (MapView.OnGlyphsErrorListener listener : onGlyphsErrorList) {
|
||||
listener.onGlyphsError(stack, rangeStart, rangeEnd);
|
||||
}
|
||||
}
|
||||
} catch (Throwable err) {
|
||||
Logger.e(TAG, "Exception in onGlyphsError", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGlyphsRequested(String[] stack, int rangeStart, int rangeEnd) {
|
||||
try {
|
||||
if (!onGlyphsRequestedList.isEmpty()) {
|
||||
for (MapView.OnGlyphsRequestedListener listener : onGlyphsRequestedList) {
|
||||
listener.onGlyphsRequested(stack, rangeStart, rangeEnd);
|
||||
}
|
||||
}
|
||||
} catch (Throwable err) {
|
||||
Logger.e(TAG, "Exception in onGlyphsRequested", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTileAction(TileOperation op, int x, int y, int z, int wrap, int overscaledZ, String sourceID) {
|
||||
try {
|
||||
if (!onTileActionList.isEmpty()) {
|
||||
for (MapView.OnTileActionListener listener : onTileActionList) {
|
||||
listener.onTileAction(op, x, y, z, wrap, overscaledZ, sourceID);
|
||||
}
|
||||
}
|
||||
} catch (Throwable err) {
|
||||
Logger.e(TAG, "Exception in onTileAction", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpriteLoaded(String id, String url) {
|
||||
try {
|
||||
if (!onSpriteLoadedList.isEmpty()) {
|
||||
for (MapView.OnSpriteLoadedListener listener : onSpriteLoadedList) {
|
||||
listener.onSpriteLoaded(id, url);
|
||||
}
|
||||
}
|
||||
} catch (Throwable err) {
|
||||
Logger.e(TAG, "Exception in onSpriteLoaded", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpriteError(String id, String url) {
|
||||
try {
|
||||
if (!onSpriteErrorList.isEmpty()) {
|
||||
for (MapView.OnSpriteErrorListener listener : onSpriteErrorList) {
|
||||
listener.onSpriteError(id, url);
|
||||
}
|
||||
}
|
||||
} catch (Throwable err) {
|
||||
Logger.e(TAG, "Exception in onSpriteError", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpriteRequested(String id, String url) {
|
||||
try {
|
||||
if (!onSpriteRequestedList.isEmpty()) {
|
||||
for (MapView.OnSpriteRequestedListener listener : onSpriteRequestedList) {
|
||||
listener.onSpriteRequested(id, url);
|
||||
}
|
||||
}
|
||||
} catch (Throwable err) {
|
||||
Logger.e(TAG, "Exception in onSpriteRequested", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
void addOnCameraWillChangeListener(MapView.OnCameraWillChangeListener listener) {
|
||||
onCameraWillChangeListenerList.add(listener);
|
||||
}
|
||||
@@ -375,6 +536,86 @@ class MapChangeReceiver implements NativeMapView.StateCallback {
|
||||
onCanRemoveUnusedStyleImageListenerList.remove(listener);
|
||||
}
|
||||
|
||||
public void addOnPreCompileShaderListener(MapView.OnPreCompileShaderListener callback) {
|
||||
onPreCompileShaderList.add(callback);
|
||||
}
|
||||
|
||||
public void addOnPostCompileShaderListener(MapView.OnPostCompileShaderListener callback) {
|
||||
onPostCompileShaderList.add(callback);
|
||||
}
|
||||
|
||||
public void addOnShaderCompileFailedListener(MapView.OnShaderCompileFailedListener callback) {
|
||||
onShaderCompileFailedList.add(callback);
|
||||
}
|
||||
|
||||
public void addOnGlyphsLoadedListener(MapView.OnGlyphsLoadedListener callback) {
|
||||
onGlyphsLoadedList.add(callback);
|
||||
}
|
||||
|
||||
public void addOnGlyphsErrorListener(MapView.OnGlyphsErrorListener callback) {
|
||||
onGlyphsErrorList.add(callback);
|
||||
}
|
||||
|
||||
public void addOnGlyphsRequestedListener(MapView.OnGlyphsRequestedListener callback) {
|
||||
onGlyphsRequestedList.add(callback);
|
||||
}
|
||||
|
||||
public void addOnTileActionListener(MapView.OnTileActionListener callback) {
|
||||
onTileActionList.add(callback);
|
||||
}
|
||||
|
||||
public void addOnSpriteLoadedListener(MapView.OnSpriteLoadedListener callback) {
|
||||
onSpriteLoadedList.add(callback);
|
||||
}
|
||||
|
||||
public void addOnSpriteErrorListener(MapView.OnSpriteErrorListener callback) {
|
||||
onSpriteErrorList.add(callback);
|
||||
}
|
||||
|
||||
public void addOnSpriteRequestedListener(MapView.OnSpriteRequestedListener callback) {
|
||||
onSpriteRequestedList.add(callback);
|
||||
}
|
||||
|
||||
public void removeOnPreCompileShaderListener(MapView.OnPreCompileShaderListener callback) {
|
||||
onPreCompileShaderList.remove(callback);
|
||||
}
|
||||
|
||||
public void removeOnPostCompileShaderListener(MapView.OnPostCompileShaderListener callback) {
|
||||
onPostCompileShaderList.remove(callback);
|
||||
}
|
||||
|
||||
public void removeOnShaderCompileFailedListener(MapView.OnShaderCompileFailedListener callback) {
|
||||
onShaderCompileFailedList.remove(callback);
|
||||
}
|
||||
|
||||
public void removeOnGlyphsLoadedListener(MapView.OnGlyphsLoadedListener callback) {
|
||||
onGlyphsLoadedList.remove(callback);
|
||||
}
|
||||
|
||||
public void removeOnGlyphsErrorListener(MapView.OnGlyphsErrorListener callback) {
|
||||
onGlyphsErrorList.remove(callback);
|
||||
}
|
||||
|
||||
public void removeOnGlyphsRequestedListener(MapView.OnGlyphsRequestedListener callback) {
|
||||
onGlyphsRequestedList.remove(callback);
|
||||
}
|
||||
|
||||
public void removeOnTileActionListener(MapView.OnTileActionListener callback) {
|
||||
onTileActionList.remove(callback);
|
||||
}
|
||||
|
||||
public void removeOnSpriteLoadedListener(MapView.OnSpriteLoadedListener callback) {
|
||||
onSpriteLoadedList.remove(callback);
|
||||
}
|
||||
|
||||
public void removeOnSpriteErrorListener(MapView.OnSpriteErrorListener callback) {
|
||||
onSpriteErrorList.remove(callback);
|
||||
}
|
||||
|
||||
public void removeOnSpriteRequestedListener(MapView.OnSpriteRequestedListener callback) {
|
||||
onSpriteRequestedList.remove(callback);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
onCameraWillChangeListenerList.clear();
|
||||
onCameraIsChangingListenerList.clear();
|
||||
@@ -391,5 +632,15 @@ class MapChangeReceiver implements NativeMapView.StateCallback {
|
||||
onSourceChangedListenerList.clear();
|
||||
onStyleImageMissingListenerList.clear();
|
||||
onCanRemoveUnusedStyleImageListenerList.clear();
|
||||
onPreCompileShaderList.clear();
|
||||
onPostCompileShaderList.clear();
|
||||
onShaderCompileFailedList.clear();
|
||||
onGlyphsLoadedList.clear();
|
||||
onGlyphsErrorList.clear();
|
||||
onGlyphsRequestedList.clear();
|
||||
onTileActionList.clear();
|
||||
onSpriteLoadedList.clear();
|
||||
onSpriteErrorList.clear();
|
||||
onSpriteRequestedList.clear();
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import org.maplibre.android.maps.widgets.CompassView;
|
||||
import org.maplibre.android.net.ConnectivityReceiver;
|
||||
import org.maplibre.android.storage.FileSource;
|
||||
import org.maplibre.android.utils.BitmapUtils;
|
||||
import org.maplibre.android.tile.TileOperation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -906,6 +907,186 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
|
||||
mapChangeReceiver.removeOnCanRemoveUnusedStyleImageListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that's invoked before a shader is compiled.
|
||||
*
|
||||
* @param listener The callback that's invoked before a shader is compiled
|
||||
*/
|
||||
public void addOnPreCompileShaderListener(MapView.OnPreCompileShaderListener callback) {
|
||||
mapChangeReceiver.addOnPreCompileShaderListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a callback that's invoked before a shader is compiled.
|
||||
*
|
||||
* @param listener The callback that's invoked before a shader is compiled
|
||||
*/
|
||||
public void removeOnPreCompileShaderListener(MapView.OnPreCompileShaderListener callback) {
|
||||
mapChangeReceiver.removeOnPreCompileShaderListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that's invoked after a shader is compiled.
|
||||
*
|
||||
* @param listener The callback that's invoked after a shader is compiled
|
||||
*/
|
||||
public void addOnPostCompileShaderListener(MapView.OnPostCompileShaderListener callback) {
|
||||
mapChangeReceiver.addOnPostCompileShaderListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a callback that's invoked after a shader is compiled.
|
||||
*
|
||||
* @param listener The callback that's invoked after a shader is compiled
|
||||
*/
|
||||
public void removeOnPostCompileShaderListener(MapView.OnPostCompileShaderListener callback) {
|
||||
mapChangeReceiver.removeOnPostCompileShaderListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that's invoked after a shader failed to compile.
|
||||
*
|
||||
* @param listener The callback that's invoked after a shader failes to compile
|
||||
*/
|
||||
public void addOnShaderCompileFailedListener(MapView.OnShaderCompileFailedListener callback) {
|
||||
mapChangeReceiver.addOnShaderCompileFailedListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a callback that's invoked after a shader failed to compile.
|
||||
*
|
||||
* @param listener The callback that's invoked after a shader failes to compile
|
||||
*/
|
||||
public void removeOnShaderCompileFailedListener(MapView.OnShaderCompileFailedListener callback) {
|
||||
mapChangeReceiver.removeOnShaderCompileFailedListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that's invoked after a range of glyphs are loaded.
|
||||
*
|
||||
* @param listener The callback that's invoked after a range of glyphs are loaded
|
||||
*/
|
||||
public void addOnGlyphsLoadedListener(MapView.OnGlyphsLoadedListener callback) {
|
||||
mapChangeReceiver.addOnGlyphsLoadedListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a callback that's invoked after a range of glyphs are loaded.
|
||||
*
|
||||
* @param listener The callback that's invoked after a range of glyphs are loaded
|
||||
*/
|
||||
public void removeOnGlyphsLoadedListener(MapView.OnGlyphsLoadedListener callback) {
|
||||
mapChangeReceiver.removeOnGlyphsLoadedListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that's invoked after a range of glyphs fail to load.
|
||||
*
|
||||
* @param listener The callback that's invoked after a range of glyphs fail to load
|
||||
*/
|
||||
public void addOnGlyphsErrorListener(MapView.OnGlyphsErrorListener callback) {
|
||||
mapChangeReceiver.addOnGlyphsErrorListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a callback that's invoked after a range of glyphs fail to load.
|
||||
*
|
||||
* @param listener The callback that's invoked after a range of glyphs fail to load
|
||||
*/
|
||||
public void removeOnGlyphsErrorListener(MapView.OnGlyphsErrorListener callback) {
|
||||
mapChangeReceiver.removeOnGlyphsErrorListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that's invoked after a range of glyphs are requested.
|
||||
*
|
||||
* @param listener The callback that's invoked after a range of glyphs are requested
|
||||
*/
|
||||
public void addOnGlyphsRequestedListener(MapView.OnGlyphsRequestedListener callback) {
|
||||
mapChangeReceiver.addOnGlyphsRequestedListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a callback that's invoked after a range of glyphs are requested.
|
||||
*
|
||||
* @param listener The callback that's invoked after a range of glyphs are requested
|
||||
*/
|
||||
public void removeOnGlyphsRequestedListener(MapView.OnGlyphsRequestedListener callback) {
|
||||
mapChangeReceiver.removeOnGlyphsRequestedListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that's invoked after a tile action occurs.
|
||||
*
|
||||
* @param listener The callback that's invoked after a tile action occurs
|
||||
*/
|
||||
public void addOnTileActionListener(MapView.OnTileActionListener callback) {
|
||||
mapChangeReceiver.addOnTileActionListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove's a callback that's invoked after a tile action occurs.
|
||||
*
|
||||
* @param listener The callback that's invoked after a tile action occurs
|
||||
*/
|
||||
public void removeOnTileActionListener(MapView.OnTileActionListener callback) {
|
||||
mapChangeReceiver.removeOnTileActionListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that's invoked after a sprite is loaded.
|
||||
*
|
||||
* @param listener The callback that's invoked after a sprite is loaded
|
||||
*/
|
||||
public void addOnSpriteLoadedListener(MapView.OnSpriteLoadedListener callback) {
|
||||
mapChangeReceiver.addOnSpriteLoadedListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a callback that's invoked after a sprite is loaded.
|
||||
*
|
||||
* @param listener The callback that's invoked after a sprite is loaded
|
||||
*/
|
||||
public void removeOnSpriteLoadedListener(MapView.OnSpriteLoadedListener callback) {
|
||||
mapChangeReceiver.removeOnSpriteLoadedListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that's invoked after a sprite fails to laod.
|
||||
*
|
||||
* @param listener The callback that's invoked after a sprite fails to load
|
||||
*/
|
||||
public void addOnSpriteErrorListener(MapView.OnSpriteErrorListener callback) {
|
||||
mapChangeReceiver.addOnSpriteErrorListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a callback that's invoked after a sprite fails to laod.
|
||||
*
|
||||
* @param listener The callback that's invoked after a sprite fails to load
|
||||
*/
|
||||
public void removeOnSpriteErrorListener(MapView.OnSpriteErrorListener callback) {
|
||||
mapChangeReceiver.removeOnSpriteErrorListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that's invoked after a sprite is requested.
|
||||
*
|
||||
* @param listener The callback that's invoked after a sprite is requested
|
||||
*/
|
||||
public void addOnSpriteRequestedListener(MapView.OnSpriteRequestedListener callback) {
|
||||
mapChangeReceiver.addOnSpriteRequestedListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a callback that's invoked after a sprite is requested.
|
||||
*
|
||||
* @param listener The callback that's invoked after a sprite is requested
|
||||
*/
|
||||
public void removeOnSpriteRequestedListener(MapView.OnSpriteRequestedListener callback) {
|
||||
mapChangeReceiver.removeOnSpriteRequestedListener(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked when the camera will change.
|
||||
* <p>
|
||||
@@ -1123,6 +1304,183 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
|
||||
boolean onCanRemoveUnusedStyleImage(@NonNull String id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked before a shader is compiled.
|
||||
* <p>
|
||||
* {@link MapView#addOnPreCompileShaderListener(OnPreCompileShaderListener)}
|
||||
* </p>
|
||||
*/
|
||||
public interface OnPreCompileShaderListener {
|
||||
/**
|
||||
* Called before a shader is compiled.
|
||||
*
|
||||
* @param id of a shader type enumeration. See `mbgl::shaders::BuiltIn` for a list
|
||||
* of possible values.
|
||||
* @param type of graphics backend the shader is being compiled for. See
|
||||
* `mbgl::gfx::Backend::Type` for a list of possible values.
|
||||
* @param additionalDefines that specify the permutaion of the shader.
|
||||
*/
|
||||
void onPreCompileShader(int id, int type, String additionalDefines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked after a shader is compiled.
|
||||
* <p>
|
||||
* {@link MapView#addOnPostCompileShaderListener(OnPostCompileShaderListener)}
|
||||
* </p>
|
||||
*/
|
||||
public interface OnPostCompileShaderListener {
|
||||
/**
|
||||
* Called after a shader is compiled.
|
||||
*
|
||||
* @param id of a shader type enumeration. See `mbgl::shaders::BuiltIn` for a list
|
||||
* of possible values.
|
||||
* @param type of graphics backend the shader is being compiled for. See
|
||||
* `mbgl::gfx::Backend::Type` for a list of possible values.
|
||||
* @param additionalDefines that specify the permutation of the shader.
|
||||
*/
|
||||
void onPostCompileShader(int id, int type, String additionalDefines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked after a shader failed to compile.
|
||||
* <p>
|
||||
* {@link MapView#addOnShaderCompileFailedListener(OnShaderCompileFailedListener)}
|
||||
* </p>
|
||||
*/
|
||||
public interface OnShaderCompileFailedListener {
|
||||
/**
|
||||
* Called when a shader fails to compile.
|
||||
*
|
||||
* @param id of a shader type enumeration. See `mbgl::shaders::BuiltIn` for a list
|
||||
* of possible values.
|
||||
* @param type of graphics backend the shader is being compiled for. See
|
||||
* `mbgl::gfx::Backend::Type` for a list of possible values.
|
||||
* @param additionalDefines that specify the permutation of the shader.
|
||||
*/
|
||||
void onShaderCompileFailed(int id, int type, String additionalDefines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked after a range of glyphs are loaded.
|
||||
* <p>
|
||||
* {@link MapView#addOnGlyphsLoadedListener(OnGlyphsLoadedListener)}
|
||||
* </p>
|
||||
*/
|
||||
public interface OnGlyphsLoadedListener {
|
||||
/**
|
||||
* Called when a range of glyphs for a font stack are loaded.
|
||||
*
|
||||
* @param stack of font names.
|
||||
* @param rangeStart of glyph indices being loaded.
|
||||
* @param rangeEnd of glyph indices being loaded.
|
||||
*/
|
||||
void onGlyphsLoaded(@NonNull String[] stack, int rangeStart, int rangeEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked after a range of glyphs fail to load.
|
||||
* <p>
|
||||
* {@link MapView#addOnGlyphsErrorListener(OnGlyphsErrorListener)}
|
||||
* </p>
|
||||
*/
|
||||
public interface OnGlyphsErrorListener {
|
||||
/**
|
||||
* Called when a range of glyphs for a font stack failed to load.
|
||||
*
|
||||
* @param stack of font names.
|
||||
* @param rangeStart of glyph indices that failed to load.
|
||||
* @param rangeEnd of glyph indices that failed to load.
|
||||
*/
|
||||
void onGlyphsError(@NonNull String[] stack, int rangeStart, int rangeEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked after a range of glyphs are requested.
|
||||
* <p>
|
||||
* {@link MapView#addOnGlyphsRequestedListener(OnGlyphsRequestedListener)}
|
||||
* </p>
|
||||
*/
|
||||
public interface OnGlyphsRequestedListener {
|
||||
/**
|
||||
* Called when a range of glyphs for a font stack are requested.
|
||||
*
|
||||
* @param stack of font names.
|
||||
* @param rangeStart of glyph indices that are being requested.
|
||||
* @param rangeEnd of glyph indices that are being requested.
|
||||
*/
|
||||
void onGlyphsRequested(@NonNull String[] stack, int rangeStart, int rangeEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked after a tile action occurs.
|
||||
* <p>
|
||||
* {@link MapView#addOnTileActionListener(OnTileActionListener)}
|
||||
* </p>
|
||||
*/
|
||||
public interface OnTileActionListener {
|
||||
/**
|
||||
* Called when a tile action occurs.
|
||||
*
|
||||
* @param op identifying the tile action that occurred.
|
||||
* @param x coordinate of the tile.
|
||||
* @param y coordinate of the tile.
|
||||
* @param z coordinate of the tile.
|
||||
* @param wrap coordinate of the tile.
|
||||
* @param overscaledZ coordinate of the tile.
|
||||
* @param sourceID of the tile.
|
||||
*/
|
||||
void onTileAction(TileOperation op, int x, int y, int z, int wrap, int overscaledZ, String sourceID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked after a sprite is requested.
|
||||
* <p>
|
||||
* {@link MapView#addOnSpriteLoadedListener(OnSpriteLoadedListener)}
|
||||
* </p>
|
||||
*/
|
||||
public interface OnSpriteLoadedListener {
|
||||
/**
|
||||
* Called when a sprite is loaded.
|
||||
*
|
||||
* @param id of the sprite.
|
||||
* @param url of the sprite.
|
||||
*/
|
||||
void onSpriteLoaded(@NonNull String id, @NonNull String url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked after a sprite fails to load.
|
||||
* <p>
|
||||
* {@link MapView#addOnSpriteErrorListener(OnSpriteErrorListener)}
|
||||
* </p>
|
||||
*/
|
||||
public interface OnSpriteErrorListener {
|
||||
/**
|
||||
* Called when a sprite fails to load.
|
||||
*
|
||||
* @param id of the sprite.
|
||||
* @param url of the sprite.
|
||||
*/
|
||||
void onSpriteError(@NonNull String id, @NonNull String url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked after a sprite is requested.
|
||||
* <p>
|
||||
* {@link MapView#addOnSpriteRequestedListener(OnSpriteRequestedListener)}
|
||||
* </p>
|
||||
*/
|
||||
public interface OnSpriteRequestedListener {
|
||||
/**
|
||||
* Called when a sprite is requested.
|
||||
*
|
||||
* @param id of the sprite.
|
||||
* @param url of the sprite.
|
||||
*/
|
||||
void onSpriteRequested(@NonNull String id, @NonNull String url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a callback object which will be triggered when the {@link MapLibreMap} instance is ready to be used.
|
||||
*
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.maplibre.android.style.light.Light;
|
||||
import org.maplibre.android.style.sources.CannotAddSourceException;
|
||||
import org.maplibre.android.style.sources.Source;
|
||||
import org.maplibre.android.utils.BitmapUtils;
|
||||
import org.maplibre.android.tile.TileOperation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -1194,6 +1195,76 @@ final class NativeMapView implements NativeMap {
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
private void onPreCompileShader(int id, int type, String additionalDefines) {
|
||||
if (stateCallback != null) {
|
||||
stateCallback.onPreCompileShader(id, type, additionalDefines);
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
private void onPostCompileShader(int id, int type, String additionalDefines) {
|
||||
if (stateCallback != null) {
|
||||
stateCallback.onPostCompileShader(id, type, additionalDefines);
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
private void onShaderCompileFailed(int id, int type, String additionalDefines) {
|
||||
if (stateCallback != null) {
|
||||
stateCallback.onShaderCompileFailed(id, type, additionalDefines);
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
private void onGlyphsLoaded(String[] stack, int rangeStart, int rangeEnd) {
|
||||
if (stateCallback != null) {
|
||||
stateCallback.onGlyphsLoaded(stack, rangeStart, rangeEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
private void onGlyphsError(String[] stack, int rangeStart, int rangeEnd) {
|
||||
if (stateCallback != null) {
|
||||
stateCallback.onGlyphsError(stack, rangeStart, rangeEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
private void onGlyphsRequested(String[] stack, int rangeStart, int rangeEnd) {
|
||||
if (stateCallback != null) {
|
||||
stateCallback.onGlyphsRequested(stack, rangeStart, rangeEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
private void onTileAction(TileOperation op, int x, int y, int z, int wrap, int overscaledZ, String sourceID) {
|
||||
if (stateCallback != null) {
|
||||
stateCallback.onTileAction(op, x, y, z, wrap, overscaledZ, sourceID);
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
private void onSpriteLoaded(String id, String url) {
|
||||
if (stateCallback != null) {
|
||||
stateCallback.onSpriteLoaded(id, url);
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
private void onSpriteError(String id, String url) {
|
||||
if (stateCallback != null) {
|
||||
stateCallback.onSpriteError(id, url);
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
private void onSpriteRequested(String id, String url) {
|
||||
if (stateCallback != null) {
|
||||
stateCallback.onSpriteRequested(id, url);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// JNI methods
|
||||
//
|
||||
@@ -1621,5 +1692,25 @@ final class NativeMapView implements NativeMap {
|
||||
void onStyleImageMissing(String imageId);
|
||||
|
||||
boolean onCanRemoveUnusedStyleImage(String imageId);
|
||||
|
||||
void onPreCompileShader(int id, int type, String additionalDefines);
|
||||
|
||||
void onPostCompileShader(int id, int type, String additionalDefines);
|
||||
|
||||
void onShaderCompileFailed(int id, int type, String additionalDefines);
|
||||
|
||||
void onGlyphsLoaded(String[] stack, int rangeStart, int rangeEnd);
|
||||
|
||||
void onGlyphsError(String[] stack, int rangeStart, int rangeEnd);
|
||||
|
||||
void onGlyphsRequested(String[] stack, int rangeStart, int rangeEnd);
|
||||
|
||||
void onTileAction(TileOperation op, int x, int y, int z, int wrap, int overscaledZ, String sourceID);
|
||||
|
||||
void onSpriteLoaded(String id, String url);
|
||||
|
||||
void onSpriteError(String id, String url);
|
||||
|
||||
void onSpriteRequested(String id, String url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.maplibre.android.tile;
|
||||
|
||||
public enum TileOperation {
|
||||
RequestedFromCache,
|
||||
RequestedFromNetwork,
|
||||
LoadFromNetwork,
|
||||
LoadFromCache,
|
||||
StartParse,
|
||||
EndParse,
|
||||
Error,
|
||||
Cancelled,
|
||||
NullOp,
|
||||
}
|
||||
Reference in New Issue
Block a user