Commit c7c89643 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Simplifies function.

parent 046b7942
...@@ -3,17 +3,9 @@ package chat.rocket.android.util.extensions ...@@ -3,17 +3,9 @@ package chat.rocket.android.util.extensions
import android.graphics.Bitmap import android.graphics.Bitmap
fun Bitmap.getCompressFormat(mimeType: String): Bitmap.CompressFormat { fun Bitmap.getCompressFormat(mimeType: String): Bitmap.CompressFormat {
var compressFormat = Bitmap.CompressFormat.PNG return when {
when { mimeType.contains("jpeg") -> Bitmap.CompressFormat.JPEG
mimeType.contains("jpeg") -> { mimeType.contains("webp") -> Bitmap.CompressFormat.WEBP
compressFormat = Bitmap.CompressFormat.JPEG else -> Bitmap.CompressFormat.PNG
}
mimeType.contains("png") -> {
compressFormat = Bitmap.CompressFormat.PNG
}
mimeType.contains("webp") -> {
compressFormat = Bitmap.CompressFormat.WEBP
}
} }
return compressFormat
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment