From 834ff765c0dd393bcdc3609e392adf9a88d18cff Mon Sep 17 00:00:00 2001 From: Tobrun Date: Fri, 12 Aug 2016 12:22:20 -0400 Subject: [android] #5968 - add support for a layout editor preview, show a drawable and some overlain items --- .../java/com/mapbox/mapboxsdk/maps/MapView.java | 20 +++++----- .../main/res/drawable-xxhdpi/mapview_preview.png | Bin 0 -> 1071179 bytes .../src/main/res/layout/mapview_preview.xml | 41 +++++++++++++++++++++ 3 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapview_preview.png create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_preview.xml (limited to 'platform') diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index b17350f4f4..1c2f8e59c5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -185,25 +185,23 @@ public class MapView extends FrameLayout { } private void initialize(@NonNull Context context, @NonNull MapboxMapOptions options) { + if (isInEditMode()) { + // if we are in an editor mode we show an image of a map + LayoutInflater.from(context).inflate(R.layout.mapview_preview, this); + return; + } + mInitialLoad = true; mOnMapReadyCallbackList = new ArrayList<>(); mOnMapChangedListener = new CopyOnWriteArrayList<>(); mMapboxMap = new MapboxMap(this); mIcons = new ArrayList<>(); View view = LayoutInflater.from(context).inflate(R.layout.mapview_internal, this); - - if (!isInEditMode()) { - setWillNotDraw(false); - } + setWillNotDraw(false); // Reference the TextureView SurfaceView surfaceView = (SurfaceView) view.findViewById(R.id.surfaceView); - // Check if we are in Android Studio UI editor to avoid error in layout preview - if (isInEditMode()) { - return; - } - mNativeMapView = new NativeMapView(this); // Ensure this view is interactable @@ -1506,6 +1504,10 @@ public class MapView extends FrameLayout { // Called when view is hidden and shown @Override protected void onVisibilityChanged(@NonNull View changedView, int visibility) { + if (isInEditMode()) { + return; + } + // Required by ZoomButtonController (from Android SDK documentation) if (mMapboxMap.getUiSettings().isZoomControlsEnabled() && (visibility != View.VISIBLE)) { mZoomButtonsController.setVisible(false); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapview_preview.png b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapview_preview.png new file mode 100644 index 0000000000..27763f4c86 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapview_preview.png differ diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_preview.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_preview.xml new file mode 100644 index 0000000000..d8f2193fd5 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_preview.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.1