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