@@ -26,6 +26,7 @@ class ClippedView @JvmOverloads constructor(
26
26
private val textSize = resources.getDimension(R .dimen.textSize)
27
27
private val columnOne = rectInset
28
28
private val columnTwo = columnOne + rectInset + clipRectRight
29
+ private val columnThree = columnTwo + rectInset + clipRectRight
29
30
private val rowOne = rectInset
30
31
private val rowTwo = rowOne + rectInset + clipRectBottom
31
32
private val rowThree = rowTwo + rectInset + clipRectBottom
@@ -49,7 +50,7 @@ class ClippedView @JvmOverloads constructor(
49
50
drawOutsideClippingExample(canvas)
50
51
drawSkewedTextExample(canvas)
51
52
drawTranslatedTextExample(canvas)
52
- // drawQuickRejectExample(canvas)
53
+ drawQuickRejectExample(canvas)
53
54
}
54
55
55
56
private fun drawClippedRectangle (canvas : Canvas ){
@@ -230,5 +231,34 @@ class ClippedView @JvmOverloads constructor(
230
231
}
231
232
232
233
private fun drawQuickRejectExample (canvas : Canvas ){
234
+ val inClipRectangle = RectF (clipRectRight / 2 ,
235
+ clipRectBottom / 2 ,
236
+ clipRectRight * 2 ,
237
+ clipRectBottom * 2
238
+ )
239
+ val notInClipRectangle = RectF (RectF (clipRectRight+ 1 ,
240
+ clipRectBottom+ 1 ,
241
+ clipRectRight * 2 ,
242
+ clipRectBottom * 2 ))
243
+ canvas.save()
244
+ canvas.translate(columnThree, rowOne)
245
+ canvas.clipRect(
246
+ clipRectLeft,clipRectTop,
247
+ clipRectRight,clipRectBottom
248
+ )
249
+ if (
250
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .R ) {
251
+ canvas.quickReject(inClipRectangle)
252
+ } else {
253
+ @Suppress(" DEPRECATION" )
254
+ canvas.quickReject(inClipRectangle, Canvas .EdgeType .AA )
255
+ }
256
+ ) {
257
+ canvas.drawColor(Color .WHITE )
258
+ } else {
259
+ canvas.drawColor(Color .BLACK )
260
+ canvas.drawRect(inClipRectangle, paint)
261
+ }
262
+ canvas.restore()
233
263
}
234
264
}
0 commit comments