Bug fix: map.clear() does not work correctly
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.0.0-beta3-20170823-2235" 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-20170824-1832" 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
@@ -100,44 +100,37 @@ public class PluginMarker extends MyPlugin implements MyPluginInterface {
@Override
protected void clear() {
synchronized (semaphoreAsync) {
- semaphoreAsync.put("waitCnt", 2);
- //--------------------------------------
- // Cancel tasks
- //--------------------------------------
cordova.getThreadPool().submit(new Runnable() {
@Override
public void run() {
+ //--------------------------------------
+ // Cancel tasks
+ //--------------------------------------
AsyncTask task;
if (iconLoadingTasks != null && iconLoadingTasks.size() > 0) {
int i, ilen = iconLoadingTasks.size();
for (i = 0; i < ilen; i++) {
- task = iconLoadingTasks.remove(i);
+ task = iconLoadingTasks.get(i);
task.cancel(true);
- task = null;
- }
- }
- iconLoadingTasks = null;
- synchronized (semaphoreAsync) {
- int waitCnt = semaphoreAsync.get("waitCnt");
- waitCnt = waitCnt - 1;
- semaphoreAsync.put("waitCnt", waitCnt);
- if (waitCnt < 1) {
- semaphoreAsync.notify();
}
}
}
});
+
//--------------------------------------
// Recycle bitmaps as much as possible
//--------------------------------------
+ if (iconCacheKeys != null) {
String[] cacheKeys = iconCacheKeys.keySet().toArray(new String[iconCacheKeys.size()]);
for (int i = 0; i < cacheKeys.length; i++) {
AsyncLoadImage.removeBitmapFromMemCahce(cacheKeys[i]);
iconCacheKeys.remove(cacheKeys[i]);
}
cacheKeys = null;
+ }
+ if (icons != null) {
Bitmap[] cachedBitmaps = icons.toArray(new Bitmap[icons.size()]);
Bitmap image;
for (int i = 0; i < cachedBitmaps.length; i++) {
@@ -148,6 +141,7 @@ public class PluginMarker extends MyPlugin implements MyPluginInterface {
image = null;
}
icons.clear();
+ }
//--------------------------------------
// clean up properties as much as possible
@@ -177,19 +171,14 @@ public class PluginMarker extends MyPlugin implements MyPluginInterface {
}
synchronized (semaphoreAsync) {
- int waitCnt = semaphoreAsync.get("waitCnt");
- waitCnt = waitCnt - 1;
- semaphoreAsync.put("waitCnt", waitCnt);
- if (waitCnt < 1) {
semaphoreAsync.notify();
}
- }
}
});
try {
- semaphoreAsync.wait();
+ semaphoreAsync.wait(5);
} catch (InterruptedException e) {
e.printStackTrace();
}

Bug fix: map.clear() does not work correctly (#1639, #1669)