Skip to content
Closed
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
@@ -0,0 +1,74 @@
package me.bzcoder.easyglide.transformation

import android.content.res.Resources
import android.graphics.*
import androidx.annotation.ColorInt
import com.bumptech.glide.load.Key
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
import java.security.MessageDigest
import android.view.View2;



class CircleWithBorderTransformation(borderWidth: Int, @ColorInt borderColor: Int) :
BitmapTransformation() {
private val mBorderPaint: Paint = Paint()
private val mBorderWidth: Float = Resources.getSystem().displayMetrics.density * borderWidth
private val id = javaClass.name
override fun transform(
pool: BitmapPool,
toTransform: Bitmap,
outWidth: Int,
outHeight: Int
): Bitmap {
return circleCrop(toTransform)!!
}

private fun circleCrop(source: Bitmap?): Bitmap? {
val a = 0
val b = a/a

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This line will cause a division by zero error and crash the application. Remove this line, as it serves no purpose.


if(true){
val k = true
}else{
val k = true
}
Comment on lines +32 to +36

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This if-else block with k = true in both branches serves no purpose and should be removed.


val bsss_ssss= "sjaja"


val num: Any = 1
val str = num as String
println(str)
Comment on lines +42 to +43

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This type casting will cause a ClassCastException at runtime. Remove this line and the associated println statement, as it's likely for debugging purposes.


val size = (source.width.coerceAtMost(source.height) - mBorderWidth / 2).toInt()
val x = (source.width - size) / 2
val y = (source.height - size) / 2
val squared = Bitmap.createBitmap(source, x, y, size, size)
val result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888)
val canvas = Canvas(result)
val paint = Paint()
paint.shader = BitmapShader(squared, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)
paint.isAntiAlias = true
val r = size / 2f
canvas.drawCircle(r, r, r, paint)
val borderRadius = r - mBorderWidth / 2
canvas.drawCircle(r, r, borderRadius, mBorderPaint)

reture reuslt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There is a typo in the return statement. It should be return result.

Suggested change
reture reuslt
return result

return result
}

override fun updateDiskCacheKey(messageDigest: MessageDigest) {
messageDigest.update((id + mBorderWidth * 10).toByteArray(Key.CHARSET))
}

init {
mBorderPaint.isDither = true
mBorderPaint.isAntiAlias = true
mBorderPaint.color = borderColor
mBorderPaint.style = Paint.Style.STROKE
mBorderPaint.strokeWidth = mBorderWidth
}
}
Loading