Skip to content

Conversation

@chiuki
Copy link

@chiuki chiuki commented Jan 31, 2014

No description provided.

@dsandler
Copy link
Owner

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:

  • attempt to load the PenEvent class just once, statically (if this fails we can safely return false from isHTCPenEvent)
  • same with isPenEvent() — let's keep that method around
  • we can also cache the test for "HTC", another way to bail out of isHTCPenEvent quickly
  • it would probably be faster to first find out if the MotionEvent we get is an instanceof PenEvent, before attempting to call isPenEvent() on it

Does that all make sense?

@chiuki
Copy link
Author

chiuki commented Mar 17, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants