blob: ee9f4b3b65c1527b852eeeba20efb7de2c5e7fde (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package com.mapbox.mapboxsdk;
import com.mapbox.mapboxsdk.log.Logger;
/**
* Loads the mapbox-gl shared library
* <p>
* By default uses the {@link System#loadLibrary(String)},
* use {@link #setLibraryLoader(LibraryLoader)} to provide an alternative library loading hook.
* </p>
*/
public abstract class LibraryLoader {
private static final String TAG = "Mbgl-LibraryLoader";
private static final LibraryLoader DEFAULT = Mapbox.getModuleProvider()
.createLibraryLoaderProvider()
.getDefaultLibraryLoader();
private static volatile LibraryLoader loader = DEFAULT;
private static boolean loaded;
/**
* Set the library loader that loads the shared library.
*
* @param libraryLoader the library loader
*/
public static void setLibraryLoader(LibraryLoader libraryLoader) {
loader = libraryLoader;
}
/**
* Loads "libmapbox-gl.so" native shared library.
* <p>
* Catches UnsatisfiedLinkErrors and prints a warning to logcat.
* </p>
*/
public static void load() {
try {
if (!loaded) {
loaded = true;
loader.load("mapbox-gl");
}
} catch (UnsatisfiedLinkError error) {
loaded = false;
String message = "Failed to load native shared library.";
Logger.e(TAG, message, error);
MapStrictMode.strictModeViolation(message, error);
}
}
public abstract void load(String name);
}
|