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);
    }
  }
}

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 ) ; } } }
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 .
