Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix crash in Android MapView on slow connection

  • Loading branch information...
commit e2cafd9fe9cf3857beaef6286453f51c053d99b6 1 parent c239636
@dmitrys dmitrys authored
View
6 platform/android/Rhodes/jni/src/mapview.cpp
@@ -748,7 +748,7 @@ RHO_GLOBAL void mapview_close();
-RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_mapview_MapView_click
+RHO_GLOBAL jint JNICALL Java_com_rhomobile_rhodes_mapview_MapView_click
(JNIEnv *env, jobject, jlong nativeDevice, jint x, jint y)
{
RHO_MAP_TRACE("Java_com_rhomobile_rhodes_mapview_MapView_click: start");
@@ -757,9 +757,11 @@ RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_mapview_MapView_click
if (mv->handleClick(x, y) ) {
// close
mapview_close();
- }
+ return 1;
+ }
}
RHO_MAP_TRACE("Java_com_rhomobile_rhodes_mapview_MapView_click: finish");
+ return 0;
}
View
28 platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java
@@ -82,7 +82,7 @@
public native void setZoom(long nativeDevice, int zoom);
public native void move(long nativeDevice, int dx, int dy);
- public native void click(long nativeDevice, int x, int y);
+ public native int click(long nativeDevice, int x, int y);
public native void paint(long nativeDevice, Canvas canvas);
public native void destroy(long nativeDevice);
@@ -101,6 +101,8 @@
private long mNativeDevice;
+ public boolean mIsInExitProcess;
+
private static int ourDensity = Bitmap.DENSITY_NONE;//DisplayMetrics.DENSITY_DEFAULT;
private TouchHandler createTouchHandler() {
@@ -143,6 +145,7 @@ public static void destroy() {
final MapView mv = mc;
mc = null;
if (mv != null) {
+ mv.mIsInExitProcess = true;
Logger.I(TAG, "destroy() mc != null - process destroy");
PerformOnUiThread.exec(new Runnable() {
public void run() {
@@ -156,6 +159,7 @@ public void run() {
@Override
public void onCreate(Bundle savedInstanceState) {
Logger.I(TAG, "onCreate()");
+ mIsInExitProcess = false;
super.onCreate(savedInstanceState);
mc = this;
@@ -251,6 +255,7 @@ public void onVisibilityChanged(boolean visible) {}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
Logger.I(TAG, "onBack button pressed()");
+ mIsInExitProcess = true;
mc = null;
mNativeDevice = 0;
destroy(mNativeDevice);
@@ -382,6 +387,9 @@ public void drawText(Canvas canvas, int x, int y, int width, int height, String
}
public void redraw() {
+ if (mIsInExitProcess) {
+ return;
+ }
if (mc != null) {
PerformOnUiThread.exec(new Runnable() {
public void run() {
@@ -443,15 +451,25 @@ public static void addRefImage(int bm) {
public void destroyDevice() {
mNativeDevice = 0;
+ mIsInExitProcess = true;
}
@Override
public void touchClick(Touch touch) {
- click(mNativeDevice, (int)touch.x, (int)touch.y);
+ if (mIsInExitProcess) {
+ return;
+ }
+ if (0 != click(mNativeDevice, (int)touch.x, (int)touch.y) ) {
+ // block all UI because we in exit process from now !
+ mIsInExitProcess = true;
+ }
}
@Override
public void touchDown(Touch first, Touch second) {
+ if (mIsInExitProcess) {
+ return;
+ }
mTouchFirst = first;
mTouchSecond = second;
if (ENABLE_MULTI_TOUCH) {
@@ -465,6 +483,9 @@ public void touchDown(Touch first, Touch second) {
@Override
public void touchUp(Touch first, Touch second) {
+ if (mIsInExitProcess) {
+ return;
+ }
mTouchFirst = first;
mTouchSecond = second;
if (ENABLE_MULTI_TOUCH) {
@@ -482,6 +503,9 @@ public void touchUp(Touch first, Touch second) {
@Override
public void touchMove(Touch first, Touch second) {
+ if (mIsInExitProcess) {
+ return;
+ }
if (first == null || second == null) {
// Move
Touch t = first == null ? second : first;
Please sign in to comment.
Something went wrong with that request. Please try again.