From e68a08da51c57412505298b4d114dc2beadc275d Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sat, 29 Apr 2023 12:50:04 -0300 Subject: [PATCH] feat(android): allow `JSObject::getString` to return null --- .../android/src/main/java/app/tauri/plugin/JSObject.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/tauri/mobile/android/src/main/java/app/tauri/plugin/JSObject.kt b/core/tauri/mobile/android/src/main/java/app/tauri/plugin/JSObject.kt index f09fefd2c..3affc81aa 100644 --- a/core/tauri/mobile/android/src/main/java/app/tauri/plugin/JSObject.kt +++ b/core/tauri/mobile/android/src/main/java/app/tauri/plugin/JSObject.kt @@ -13,14 +13,13 @@ class JSObject : JSONObject { constructor(obj: JSONObject, names: Array) : super(obj, names) override fun getString(key: String): String { - return getString(key, "") + return getString(key, "")!! } - fun getString(key: String, defaultValue: String): String { + fun getString(key: String, defaultValue: String?): String? { try { - val value = super.getString(key) if (!super.isNull(key)) { - return value + return super.getString(key) } } catch (_: JSONException) { }