Skip to content

Commit b7fef02

Browse files
committed
Fix Android build on React Native 0.77.x
1 parent 3f6dbe1 commit b7fef02

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModuleImpl.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ class ImageEditorModuleImpl(private val reactContext: ReactApplicationContext) {
8787
}
8888
}
8989

90+
/**
91+
* React Native
92+
* - 0.77.x: toHashMap(): HashMap<String, Any?>?
93+
* - 0.76.x: toHashMap(): HashMap<String, Any>?
94+
*/
95+
fun <V> safeConvert(map: HashMap<String, V>?): HashMap<String, Any>? {
96+
return map?.filterValues { it != null } as? HashMap<String, Any>
97+
}
98+
9099
/**
91100
* Crop an image. If all goes well, the promise will be resolved with the file:// URI of the new
92101
* image as the only argument. This is a temporary file - consider using
@@ -102,7 +111,7 @@ class ImageEditorModuleImpl(private val reactContext: ReactApplicationContext) {
102111
fun cropImage(uri: String?, options: ReadableMap, promise: Promise) {
103112
val headers =
104113
if (options.hasKey("headers") && options.getType("headers") == ReadableType.Map)
105-
options.getMap("headers")?.toHashMap()
114+
safeConvert(options.getMap("headers")?.toHashMap())
106115
else null
107116
val format = if (options.hasKey("format")) options.getString("format") else null
108117
val offset = if (options.hasKey("offset")) options.getMap("offset") else null

0 commit comments

Comments
 (0)