From b190211e5a5686783213412dcda649dac195f83e Mon Sep 17 00:00:00 2001 From: Emux Date: Wed, 8 Mar 2017 13:17:35 +0200 Subject: [PATCH] Android MapView in layout designer, closes #330 --- .../src/org/oscim/android/MapView.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/vtm-android/src/org/oscim/android/MapView.java b/vtm-android/src/org/oscim/android/MapView.java index 23df5df2..c1d174d8 100644 --- a/vtm-android/src/org/oscim/android/MapView.java +++ b/vtm-android/src/org/oscim/android/MapView.java @@ -49,13 +49,13 @@ public class MapView extends GLSurfaceView { static final Logger log = LoggerFactory.getLogger(MapView.class); - static { + private static void init() { System.loadLibrary("vtm-jni"); } - protected final AndroidMap mMap; + protected AndroidMap mMap; protected GestureDetector mGestureDetector; - protected final AndroidMotionEvent mMotionEvent; + protected AndroidMotionEvent mMotionEvent; public MapView(Context context) { this(context, null); @@ -64,13 +64,18 @@ public class MapView extends GLSurfaceView { public MapView(Context context, AttributeSet attributeSet) { super(context, attributeSet); + if (isInEditMode()) + return; + + init(); + /* Not sure if this makes sense */ this.setWillNotDraw(true); this.setClickable(true); this.setFocusable(true); this.setFocusableInTouchMode(true); - /* Setup android backedn */ + /* Setup android backend */ AndroidGraphics.init(); AndroidAssets.init(context); GLAdapter.init(new AndroidGL()); @@ -138,8 +143,10 @@ public class MapView extends GLSurfaceView { super.onSizeChanged(width, height, oldWidth, oldHeight); - if (width > 0 && height > 0) - mMap.viewport().setScreenSize(width, height); + if (!isInEditMode()) { + if (width > 0 && height > 0) + mMap.viewport().setScreenSize(width, height); + } } public Map map() {