add error message on MMS compression failed

This commit is contained in:
EveX 2022-01-27 01:44:27 +01:00
parent 0774e0cb0f
commit 2605a61005
3 changed files with 13 additions and 1 deletions

View file

@ -106,7 +106,11 @@ class ImageCompressor(private val context: Context) {
private var iteration: Int = 0
fun isSatisfied(imageFile: File): Boolean {
return imageFile.length() <= maxFileSize || iteration >= maxIteration
// If size requirement is not met and iteration is maxed
if(iteration >= maxIteration && imageFile.length() >= maxFileSize) {
throw Exception("Unable to compress image to targeted size")
}
return imageFile.length() <= maxFileSize
}
fun satisfy(imageFile: File): File {