Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ enum class ErrorCode(val value: String) {
INVALID_PARAMS("INVALID_PARAMS"),
LOAD_IMAGE_FAILED("LOAD_IMAGE_FAILED"),
GET_RESOURCE_FAILED("GET_RESOURCE_FAILED"),
PARAMS_REQUIRED("PARAMS_REQUIRED");
PARAMS_REQUIRED("PARAMS_REQUIRED"),
NULL_MAP("NULL_MAP");
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ class MarkTextOptions(options: ReadableMap) : Options(options) {
val waterMarkTextsMap = options.getArray("watermarkTexts")
if (waterMarkTextsMap!!.size() > 0) {
watermarkTexts = arrayOfNulls(waterMarkTextsMap.size())
for (i in 0 until waterMarkTextsMap.size()) {
val textMap = waterMarkTextsMap.getMap(i)
watermarkTexts[i] = TextOptions(textMap)
for (i in 0 until waterMarkTextsMap.size()) {
val textMap = waterMarkTextsMap.getMap(i)
textMap?.let {
watermarkTexts[i] = TextOptions(it)
} ?: run {
throw MarkerError(ErrorCode.NULL_MAP, "watermarkTexts[$i] is null")
}
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions android/src/main/java/com/jimmydaddy/imagemarker/base/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ class Utils {
}

fun handleDynamicToString(d: Dynamic?): String {
return if (d == null) "0"
else
when (d.type) {
ReadableType.String -> d.asString()
ReadableType.Number -> d.asDouble().toString()
else -> {
"0"
return if (d == null) {
"0"
} else {
when (d.type) {
ReadableType.String -> d.asString() ?: "0"
ReadableType.Number -> d.asDouble().toString()
else -> "0"
}
}
}
}
}

Expand Down