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
75 changes: 75 additions & 0 deletions app/src/main/java/me/bzcoder/webview/utils/test.kt
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



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 DivisionByZeroError and crash the application. You should remove this line, or ensure that a is never zero before performing the division.

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 unnecessary because the condition is always true. Remove the else block, or better yet, remove the entire if statement.

Suggested change
if(true){
val k = true
}else{
val k = true
}
//if(true){
// val k = true
//}else{
// 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.

high

This code will throw a ClassCastException because you are trying to cast an Int to a String without any conversion. If you want to convert the number to a string, use num.toString().

Suggested change
val str = num as String
println(str)
val str = num.toString()
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.

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