Code Cleanup

This commit is contained in:
Prathamesh More 2022-05-17 08:06:25 +05:30
parent 860fa9d8b4
commit 6779eb0e2b
5 changed files with 22 additions and 47 deletions

View file

@ -15,26 +15,18 @@ import java.security.MessageDigest
@Suppress("Deprecation")
class BlurTransformation : BitmapTransformation {
class BlurTransformation private constructor(builder: Builder) : BitmapTransformation() {
private var context: Context? = null
private var blurRadius = 0f
private var sampling = 0
private fun init(builder: Builder) {
init {
this.context = builder.context
this.blurRadius = builder.blurRadius
this.sampling = builder.sampling
}
private constructor(builder: Builder) : super() {
init(builder)
}
private constructor(builder: Builder, bitmapPool: BitmapPool) : super() {
init(builder)
}
class Builder(val context: Context) {
private var bitmapPool: BitmapPool? = null
var blurRadius = DEFAULT_BLUR_RADIUS
@ -69,7 +61,7 @@ class BlurTransformation : BitmapTransformation {
fun build(): BlurTransformation {
return if (bitmapPool != null) {
BlurTransformation(this, bitmapPool!!)
BlurTransformation(this)
} else BlurTransformation(this)
}
}
@ -78,7 +70,7 @@ class BlurTransformation : BitmapTransformation {
pool: BitmapPool,
toTransform: Bitmap,
outWidth: Int,
outHeight: Int
outHeight: Int,
): Bitmap {
val sampling = if (this.sampling == 0) {
ImageUtil.calculateInSampleSize(toTransform.width, toTransform.height, 100)