Background
I'm working on a library that has a lot of canvas drawing instead of multiple views (available here).
The problem
As I work to improve it and make it work for our needs of the app (need some customization), I've noticed there are some lines that are marked as deprecated:
canvas.clipRect(0f, mHeaderHeight + mHeaderRowPadding * 2, mHeaderColumnWidth, height.toFloat(), Region.Op.REPLACE)
Thing is, I don't think there is a good candidate to replace this line of code with the newer APIs
What I've found
Looking at the docs, this is what's written:
This method was deprecated in API level 26. Region.Op values other than INTERSECT and DIFFERENCE have the ability to expand the clip. The canvas clipping APIs are intended to only expand the clip as a result of a restore operation. This enables a view parent to clip a canvas to clearly define the maximal drawing area of its children. The recommended alternative calls are clipRect(RectF) and clipOutRect(RectF);
So I tried using either of those functions, yet both of them caused issues with the drawing of how it used to be.
Looking at the deprecation, it seems that the function itself is marked, but not Region.Op.REPLACE :
So maybe it doesn't really have an alternative...
The questions
- What is the best alternative in this case?
- Why exactly was it deprecated?
- As opposed to some deprecated functions, I assume this one should be safe to still use in case I can't find an alternative, right?