Stop Allocating Rects in onTouchEvent: A Practical Caching Pattern for Android Hit-Testing
Allocating a new Rect inside onTouchEvent or onDraw creates needless GC churn. Here's the field-caching pattern, where to invalidate it, and the mutability traps to avoid.