|
|
|
@ -7,6 +7,7 @@ import android.graphics.Path |
|
|
|
|
import android.util.AttributeSet |
|
|
|
|
import androidx.appcompat.widget.AppCompatImageView |
|
|
|
|
import io.legado.app.R |
|
|
|
|
import kotlin.math.max |
|
|
|
|
|
|
|
|
|
class FilletImageView : AppCompatImageView { |
|
|
|
|
internal var width: Float = 0.toFloat() |
|
|
|
@ -62,11 +63,11 @@ class FilletImageView : AppCompatImageView { |
|
|
|
|
|
|
|
|
|
override fun onDraw(canvas: Canvas) { |
|
|
|
|
//这里做下判断,只有图片的宽高大于设置的圆角距离的时候才进行裁剪 |
|
|
|
|
val maxLeft = Math.max(leftTopRadius, leftBottomRadius) |
|
|
|
|
val maxRight = Math.max(rightTopRadius, rightBottomRadius) |
|
|
|
|
val maxLeft = max(leftTopRadius, leftBottomRadius) |
|
|
|
|
val maxRight = max(rightTopRadius, rightBottomRadius) |
|
|
|
|
val minWidth = maxLeft + maxRight |
|
|
|
|
val maxTop = Math.max(leftTopRadius, rightTopRadius) |
|
|
|
|
val maxBottom = Math.max(leftBottomRadius, rightBottomRadius) |
|
|
|
|
val maxTop = max(leftTopRadius, rightTopRadius) |
|
|
|
|
val maxBottom = max(leftBottomRadius, rightBottomRadius) |
|
|
|
|
val minHeight = maxTop + maxBottom |
|
|
|
|
if (width >= minWidth && height > minHeight) { |
|
|
|
|
@SuppressLint("DrawAllocation") val path = Path() |
|
|
|
|