From 4645015004d868639bdd225aab3ef3cd2760bc45 Mon Sep 17 00:00:00 2001 From: shuiyu1123 Date: Wed, 24 Jun 2026 14:27:17 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20Rect.contains()=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8F=8C=E5=8F=82=E6=95=B0(x,y)=E5=92=8C=E5=9B=9B=E5=8F=82?= =?UTF-8?q?=E6=95=B0(l,t,r,b)=E9=87=8D=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android_pyapi/android/graphics.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/android_pyapi/android/graphics.py b/android_pyapi/android/graphics.py index 26b866a..9ef733e 100644 --- a/android_pyapi/android/graphics.py +++ b/android_pyapi/android/graphics.py @@ -258,14 +258,17 @@ class Rect(Stub): self.right -= dx self.bottom -= dy - def contains(self, x: int, y: int) -> bool: - return self.left < self.right and self.top < self.bottom \ - and x >= self.left and x < self.right and y >= self.top and y < self.bottom - - def contains(self, left: int, top: int, right: int, bottom: int) -> bool: - return self.left < self.right and self.top < self.bottom \ - and self.left <= left and self.top <= top \ - and self.right >= right and self.bottom >= bottom + def contains(self, *args) -> bool: + if len(args) == 2: + x, y = args + return (self.left < self.right and self.top < self.bottom + and x >= self.left and x < self.right and y >= self.top and y < self.bottom) + elif len(args) == 4: + left, top, right, bottom = args + return (self.left < self.right and self.top < self.bottom + and self.left <= left and self.top <= top + and self.right >= right and self.bottom >= bottom) + return False def intersect(self, left: int, top: int, right: int, bottom: int) -> bool: nL = max(self.left, left)