I am currently developing an app in Android Studio [using Java], and I have the challenge of preventing users from uploading nude pictures into the database. Luckily, I found this library on GitHub called NSFW(Nude Content) Detector Android.
My challenge is that it was written in Kotlin and the usage example given is also in Kotlin. I know Java and Kotlin are interoperable but I just can't figure it out after several tries.
The usage given is:
NSFWDetector.isNSFW(bitmap,confidenceThreshold) { isNSFW, confidence, image ->
if (isNSFW){
Toast.makeText(this, "NSFW with confidence: $confidence", Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(this, "SFW with confidence: $confidence", Toast.LENGTH_SHORT).show()
}
}
I know that bitmap is the image I am testing, and confidenceThreshold is the float number of the level of testing, but I can't figure the rest out. I saw these answers 1, 2, and 3 on Stack Overflow but they don't have these kind of callbacks.
Please, how do I implement this in Java?
Thank you for the help.