From f09e9ab6601b9e82cfc4cc30c6d60276e7c64020 Mon Sep 17 00:00:00 2001 From: thirstycoda <43832257+thirstycoda@users.noreply.github.com> Date: Mon, 6 Sep 2021 17:58:17 +0100 Subject: [PATCH] Change NativeMapView to use 0 instead of throwing IllegalArgumentException when resizeView is called with a negative width or height (#151) --- .../java/com/mapbox/mapboxsdk/maps/NativeMapView.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java index 91c6518ea..823dd45b5 100755 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java @@ -150,11 +150,17 @@ final class NativeMapView implements NativeMap { height = (int) Math.ceil(height / pixelRatio); if (width < 0) { - throw new IllegalArgumentException("width cannot be negative."); + Logger.e(TAG, String.format("Device returned a negative width size, " + + "setting value to 0 instead of %s", width) + ); + width = 0; } if (height < 0) { - throw new IllegalArgumentException("height cannot be negative."); + Logger.e(TAG, String.format("Device returned a negative height size, " + + "setting value to 0 instead of %s", height) + ); + height = 0; } if (width > 65535) {