question: private void randomInvalidator ( ViewGroup parent ) { for ( int i = 0 ; i < parent . getChildCount ( ) ; ++ i ) { View child = parent . getChildAt ( i ) ; if ( Math . random ( ) < .5 ) { child . invalidate ( ) ; } if ( child instanceof ViewGroup ) { randomInvalidator ( ( ViewGroup ) child ) ; } } }
target:  Invalidates views based on random chance (50%). This is meant to test invalidating several items in the hierarchy at the same time, which can cause artifacts if our invalidation-propagation logic is not sound.