Bug fix: null pointer error when map.clear() method is executing
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.0.0-beta3-20170803-0000" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="2.0.0-beta3-20170803-1233" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-googlemaps</name>
<js-module name="BaseClass" src="www/BaseClass.js">
<runs />

MODIFY
src/android/plugin/google/maps/PluginMarker.java
src/android/plugin/google/maps/PluginMarker.java
@@ -53,6 +53,7 @@ public class PluginMarker extends MyPlugin implements MyPluginInterface {
protected ArrayList<Bitmap> icons = new ArrayList<Bitmap>();
protected HashMap<String, Integer> iconCacheKeys = new HashMap<String, Integer>();
private static final Paint paint = new Paint();
+ private final HashMap<String, Integer> semaphoreAsync = new HashMap<String, Integer>();
protected interface ICreateMarkerCallback {
void onSuccess(Marker marker);
@@ -97,6 +98,9 @@ public class PluginMarker extends MyPlugin implements MyPluginInterface {
@Override
protected void clear() {
+ synchronized (semaphoreAsync) {
+ semaphoreAsync.put("waitCnt", 2);
+
//--------------------------------------
// Cancel tasks
//--------------------------------------
@@ -111,6 +115,14 @@ public class PluginMarker extends MyPlugin implements MyPluginInterface {
task = null;
}
iconLoadingTasks = null;
+ synchronized (semaphoreAsync) {
+ int waitCnt = semaphoreAsync.get("waitCnt");
+ waitCnt = waitCnt - 1;
+ semaphoreAsync.put("waitCnt", waitCnt);
+ if (waitCnt < 1) {
+ semaphoreAsync.notify();
+ }
+ }
}
});
@@ -163,9 +175,25 @@ public class PluginMarker extends MyPlugin implements MyPluginInterface {
objects.clear();
PluginMarker.super.clear();
+ synchronized (semaphoreAsync) {
+ int waitCnt = semaphoreAsync.get("waitCnt");
+ waitCnt = waitCnt - 1;
+ semaphoreAsync.put("waitCnt", waitCnt);
+ if (waitCnt < 1) {
+ semaphoreAsync.notify();
+ }
+ }
+
}
});
+ try {
+ semaphoreAsync.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
}
/**

Bug fix: null pointer error when map.clear() method is executing