Proper error checking for setting cards

When shrinking the cards array while invalidates are still
in flight, it's possible to have an invalidate or texture
set land on a nonexistent card, causing an out-of-bounds
exception to be thrown, crashing the app. Frequently these
invalidates come from the user dragging the carousel to
another position, so it's not feasible to prevent
invalidates from being sent when we're about to clear the
cards array; nor is it feasible to empty any pending
invalidates, since Renderscript does not provide any
meaningful inspection of the event queue. Therefore, the
only real way we can address the problem is by detecting
these out-of-turn invalidates and handling the errors
cleanly. In practice, since these events are typically to
invalidate a nonexistent card, it's OK to just drop them,
since each such card is already invalid because it does
not exist.

This fix factors out card-get and card-set logic into
common methods, similar to card-set-or-create logic that's
been present for a long time.

Bug: 3381300
Change-Id: I037801de3b4c3bff514b1586fa16417e32c118df
1 file changed
tree: 8ec635f83bacbf8227bf8e2bfda0c3446fbc8024
  1. carousel/
  2. common/
  3. CleanSpec.mk