Open chiuki opened 10 years ago
Moved the HTC check, the Android version check, the class reflection and the method reflection to static block.
I cannot check if the MotionEvent
is an instance of PenEvent
though, since we are not compiling with the HTC library.
With this isHTCPenEvent()
only does one reflection per MotionEvent
(to invoke the cached method on the cached class), and only when we are running on an HTC device running HONEYCOMB_MR1
or HONEYCOMB_MR2
.
I was looking over this patch again and it occurred to me that I'd really rather not do Java reflection on every MotionEvent—that can be pretty expensive.
Things I'd want this patch to do:
PenEvent
class just once, statically (if this fails we can safely return false fromisHTCPenEvent
)isPenEvent()
— let's keep that method aroundisHTCPenEvent
quicklyMotionEvent
we get is an instanceofPenEvent
, before attempting to callisPenEvent()
on itDoes that all make sense?