[android] - make all library loader load the native library only once

This commit is contained in:
tobrun
2019-01-17 12:57:53 +01:00
committed by Tobrun
parent 16718b0df7
commit f0392e0471

View File

@@ -16,16 +16,13 @@ public abstract class LibraryLoader {
private static final LibraryLoader DEFAULT = new LibraryLoader() {
@Override
public void load(String name) {
if (!loaded) {
System.loadLibrary(name);
}
loaded = true;
System.loadLibrary(name);
}
};
private static volatile LibraryLoader loader = DEFAULT;
protected static boolean loaded;
private static boolean loaded;
/**
* Set the library loader that loads the shared library.
@@ -44,7 +41,10 @@ public abstract class LibraryLoader {
*/
public static void load() {
try {
loader.load("mapbox-gl");
if (!loaded) {
loader.load("mapbox-gl");
}
loaded = true;
} catch (UnsatisfiedLinkError error) {
String message = "Failed to load native shared library.";
Logger.e(TAG, message, error);