ensure that MapboxAccountManager class is always created from the main thread; fixes crash from Android SDK 4.2.0-beta.4 and up (#517)

This commit is contained in:
Eric Samelson
2017-03-13 17:49:55 -07:00
committed by Bobby Sudekum
parent 4453983022
commit c0ebef23fb
@@ -138,7 +138,7 @@ public class ReactNativeMapboxGLModule extends ReactContextBaseJavaModule {
// Access Token
@ReactMethod
public void setAccessToken(String accessToken) {
public void setAccessToken(final String accessToken) {
if (accessToken == null || accessToken.length() == 0 || accessToken.equals("your-mapbox.com-access-token")) {
throw new JSApplicationIllegalArgumentException("Invalid access token. Register to mapbox.com and request an access token, then pass it to setAccessToken()");
}
@@ -150,7 +150,12 @@ public class ReactNativeMapboxGLModule extends ReactContextBaseJavaModule {
return;
}
initialized = true;
MapboxAccountManager.start(context.getApplicationContext(), accessToken);
mainHandler.post(new Runnable() {
@Override
public void run() {
MapboxAccountManager.start(context.getApplicationContext(), accessToken);
}
});
initializeOfflinePacks();
}