Thursday, 28 February 2019

Canvas clipOutRect compatibility in AndroidX

I recently came across the deprecation of clipRect(Rect,Region.Op), which I would like to use with DIFFERENCE. This was replaced with clipOutRect(Rect) and thus I implemented:

@Suppress("DEPRECATION")
fun clipOutRect(canvas: Canvas, rect: Rect) =
    if (SDK_INT >= O) canvas.clipOutRect(rect)
    else canvas.clipRect(rect, DIFFERENCE)

Now this looks like it could be a compatibility method in AndroidX, but for some reason I was not able to figure out, where I could find it exactly.

Is there a class already providing a compatibility method for clipOutRect(Rect)?



from Canvas clipOutRect compatibility in AndroidX

No comments:

Post a Comment