After converting some Java code to Kotlin (to create a ReplacementSpan), an annotation-related error is returned.
from
in the @IntRange(from = 0)
constructor returns an error:
'IntRange' is not an annotation class | Cannot find a parameter with this name: from
import android.graphics.Canvas
import android.graphics.Paint
import sun.swing.SwingUtilities2.drawRect
import android.text.style.ReplacementSpan
class HrSpan : ReplacementSpan() {
override fun getSize(
paint: Paint, text: CharSequence, @IntRange(from = 0) start: Int,
@IntRange(from = 0) end: Int, fm: Paint.FontMetricsInt?
): Int {
return 0
}
override fun draw(
canvas: Canvas, text: CharSequence, @IntRange(from = 0) start: Int,
@IntRange(from = 0) end: Int, x: Float, top: Int, y: Int, bottom: Int,
paint: Paint
) {
canvas.drawRect(x, top.toFloat(), y.toFloat(), (top + 8).toFloat(), paint)
}
}