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,75 @@
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
import android.view.View
Comment on lines +10 to +11

Choose a reason for hiding this comment

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

medium

These imports are not used and should be removed.




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 or handle the exception properly.

Suggested change
val b = a/a
// val b = a/a


if(true){
val k = true
}else{
val k = true
}
Comment on lines +33 to +37

Choose a reason for hiding this comment

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

medium

This conditional statement is redundant as the same value is assigned to k in both branches. Simplify this by removing the if-else block and directly assigning true to k if needed. If k is not used, remove it.

//val k = true


val bsss_ssss= "sjaja"


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

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 because you are trying to cast an Integer to a String. Remove this line or handle the exception properly with a try-catch block. If you need to convert the number to a string, use num.toString().

// val str = num as String
// println(str)


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.

high

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

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