Fix: git merge error
MODIFY
src/android/plugin/google/maps/CordovaGoogleMaps.java
src/android/plugin/google/maps/CordovaGoogleMaps.java
@@ -170,6 +170,7 @@ public class CordovaGoogleMaps extends CordovaPlugin implements ViewTreeObserver
webView.getView().setOverScrollMode(View.OVER_SCROLL_NEVER);
mPluginLayout = new MyPluginLayout(webView, activity);
mPluginLayout.isSuspended = true;
+ mPluginLayout.stopTimer();
// Check the API key
@@ -221,6 +222,7 @@ public class CordovaGoogleMaps extends CordovaPlugin implements ViewTreeObserver
@Override
public boolean onOverrideUrlLoading(String url) {
mPluginLayout.isSuspended = true;
+ mPluginLayout.stopTimer();
/*
this.activity.runOnUiThread(new Runnable() {
@Override
@@ -305,9 +307,7 @@ public class CordovaGoogleMaps extends CordovaPlugin implements ViewTreeObserver
if (mPluginLayout.isSuspended) {
mPluginLayout.isSuspended = false;
- synchronized (mPluginLayout.timerLock) {
- mPluginLayout.timerLock.notify();
- }
+ mPluginLayout.startTimer();
}
callbackContext.success();
}
@@ -331,6 +331,7 @@ public class CordovaGoogleMaps extends CordovaPlugin implements ViewTreeObserver
return;
}
mPluginLayout.isSuspended = true;
+ mPluginLayout.stopTimer();
callbackContext.success();
}
public void resume(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
@@ -340,9 +341,7 @@ public class CordovaGoogleMaps extends CordovaPlugin implements ViewTreeObserver
}
if (mPluginLayout.isSuspended) {
mPluginLayout.isSuspended = false;
- synchronized (mPluginLayout.timerLock) {
- mPluginLayout.timerLock.notify();
- }
+ mPluginLayout.startTimer();
}
callbackContext.success();
}
@@ -367,9 +366,7 @@ public class CordovaGoogleMaps extends CordovaPlugin implements ViewTreeObserver
mPluginLayout.putHTMLElements(elements);
}
- synchronized (mPluginLayout.timerLock) {
- mPluginLayout.timerLock.notify();
- }
+ mPluginLayout.startTimer();
callbackContext.success();
}

MODIFY
src/android/plugin/google/maps/MyPluginLayout.java
src/android/plugin/google/maps/MyPluginLayout.java
@@ -56,8 +56,8 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
public boolean needUpdatePosition = false;
public boolean isSuspended = false;
private float zoomScale;
- public final Object timerLock = new Object();
public boolean isWaiting = false;
+ private final Object timerLock = new Object();
public Timer redrawTimer;
@@ -78,14 +78,7 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
public void run() {
if (isSuspended) {
//Log.d(TAG, "--->ResizeTask : isSuspended = " +isSuspended);
- synchronized (timerLock) {
- isWaiting = true;
- try {
- timerLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
+ stopTimer();
return;
}
isWaiting = false;
@@ -240,28 +233,31 @@ public class MyPluginLayout extends FrameLayout implements ViewTreeObserver.OnSc
startTimer();
}
- public void stopTimer() {
+ public synchronized void stopTimer() {
+ synchronized (timerLock) {
try {
+ if (redrawTimer != null) {
redrawTimer.cancel();
redrawTimer.purge();
- timerLock.notify();
- } catch (Exception e) {}
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
redrawTimer = null;
}
+ }
- public void startTimer() {
+ public synchronized void startTimer() {
+ synchronized (timerLock) {
if (redrawTimer != null) {
return;
}
- try {
- timerLock.notify();
- } catch (Exception e) {}
-
redrawTimer = new Timer();
redrawTimer.scheduleAtFixedRate(new ResizeTask(), 0, 25);
mActivity.getWindow().getDecorView().requestFocus();
}
+ }

MODIFY
src/android/plugin/google/maps/PluginMap.java
src/android/plugin/google/maps/PluginMap.java
@@ -2297,7 +2297,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
String tmp[] = markerTag.split("_");
tmp = markerTag.split("-");
String markerId = tmp[tmp.length - 1];
- String js = String.format(Locale.ENGLISH, "javascript:plugin.google.maps['%s']({evtName: '%s', callback:'_onMarkerEvent', args:['%s', new plugin.google.maps.LatLng(%f, %f)]});",
+ String js = String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName: '%s', callback:'_onMarkerEvent', args:['%s', new plugin.google.maps.LatLng(%f, %f)]});}",
mapId, eventName, markerId, latLng.latitude, latLng.longitude);
jsCallback(js);
}
@@ -2311,7 +2311,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
String tmp[] = markerTag.split("-");
String clusterId = tmp[0];
String markerId = tmp[1];
- String js = String.format(Locale.ENGLISH, "javascript:plugin.google.maps['%s']({evtName: '%s', callback:'_onClusterEvent', args:['%s', '%s', new plugin.google.maps.LatLng(%f, %f)]});",
+ String js = String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName: '%s', callback:'_onClusterEvent', args:['%s', '%s', new plugin.google.maps.LatLng(%f, %f)]});}",
mapId, eventName, clusterId, markerId, latLng.latitude, latLng.longitude);
jsCallback(js);
}
@@ -2323,13 +2323,13 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
LatLng latLng = activeMarker.getPosition();
Point point = projection.toScreenLocation(latLng);
- String js = String.format(Locale.ENGLISH, "javascript:plugin.google.maps['%s']({evtName: 'syncPosition', callback:'_onSyncInfoWndPosition', args:[{'x': %d, 'y': %d}]});",
+ String js = String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName: 'syncPosition', callback:'_onSyncInfoWndPosition', args:[{'x': %d, 'y': %d}]});}",
mapId, (int)(point.x / density), (int)(point.y / density));
jsCallback(js);
}
public void onOverlayEvent(String eventName, String overlayId, LatLng point) {
- String js = String.format(Locale.ENGLISH, "javascript:plugin.google.maps['%s']({evtName: '%s', callback:'_onOverlayEvent', args:['%s', new plugin.google.maps.LatLng(%f, %f)]});",
+ String js = String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName: '%s', callback:'_onOverlayEvent', args:['%s', new plugin.google.maps.LatLng(%f, %f)]});}",
mapId, eventName, overlayId, point.latitude, point.longitude);
jsCallback(js);
}
@@ -2355,7 +2355,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
* @param eventName
*/
public void onMapEvent(final String eventName) {
- String js = String.format(Locale.ENGLISH, "javascript:plugin.google.maps['%s']({evtName: '%s', callback:'_onMapEvent', args:[]});",
+ String js = String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName: '%s', callback:'_onMapEvent', args:[]});}",
mapId, eventName);
jsCallback(js);
}
@@ -2366,7 +2366,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
* @param point
*/
public void onMapEvent(final String eventName, final LatLng point) {
- String js = String.format(Locale.ENGLISH, "javascript:plugin.google.maps['%s']({evtName: '%s', callback:'_onMapEvent', args:[new plugin.google.maps.LatLng(%f, %f)]});",
+ String js = String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName: '%s', callback:'_onMapEvent', args:[new plugin.google.maps.LatLng(%f, %f)]});}",
mapId, eventName, point.latitude, point.longitude);
jsCallback(js);
}
@@ -2521,7 +2521,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
@Override
public boolean onMyLocationButtonClick() {
- jsCallback(String.format(Locale.ENGLISH, "javascript:plugin.google.maps['%s']({evtName: 'my_location_button_click', callback:'_onMapEvent'});", mapId));
+ jsCallback(String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName: 'my_location_button_click', callback:'_onMapEvent'});}", mapId));
return false;
}
@@ -2530,7 +2530,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
PluginLocationService.setLastLocation(location);
try {
JSONObject result = PluginUtil.location2Json(location);
- jsCallback(String.format(Locale.ENGLISH, "javascript:plugin.google.maps['%s']({evtName: 'my_location_click', callback:'_onMapEvent', args: [%s]});", mapId, result.toString(0)));
+ jsCallback(String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName: 'my_location_click', callback:'_onMapEvent', args: [%s]});}", mapId, result.toString(0)));
} catch (JSONException e) {
e.printStackTrace();
}
@@ -2598,7 +2598,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
jsCallback(
String.format(
Locale.ENGLISH,
- "javascript:plugin.google.maps['%s']({evtName:'%s', callback:'_onCameraEvent', args: [%s]});",
+ "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName:'%s', callback:'_onCameraEvent', args: [%s]});}",
mapId, eventName, jsonStr));
}
});
@@ -2663,7 +2663,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
jsonStr = result.toString();
}
}
- jsCallback(String.format(Locale.ENGLISH, "javascript:plugin.google.maps['%s']({evtName:'indoor_building_focused', callback:'_onMapEvent', args: [%s]});", mapId, jsonStr));
+ jsCallback(String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName:'indoor_building_focused', callback:'_onMapEvent', args: [%s]});}", mapId, jsonStr));
}
@Override
@@ -2675,12 +2675,12 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
jsonStr = result.toString();
}
}
- jsCallback(String.format(Locale.ENGLISH, "javascript:plugin.google.maps['%s']({evtName:'indoor_level_activated', callback:'_onMapEvent', args: [%s]});", mapId, jsonStr));
+ jsCallback(String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName:'indoor_level_activated', callback:'_onMapEvent', args: [%s]});}", mapId, jsonStr));
}
@Override
public void onPoiClick(PointOfInterest pointOfInterest) {
- String js = String.format(Locale.ENGLISH, "javascript:plugin.google.maps['%s']({evtName: '%s', callback:'_onMapEvent', args:['%s', '%s', new plugin.google.maps.LatLng(%f, %f)]});",
+ String js = String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName: '%s', callback:'_onMapEvent', args:['%s', '%s', new plugin.google.maps.LatLng(%f, %f)]});}",
mapId, "poi_click", pointOfInterest.placeId, pointOfInterest.name, pointOfInterest.latLng.latitude, pointOfInterest.latLng.longitude);
jsCallback(js);
}

Fix: git merge error