public final < T extends View > T getFreshestView ( ArrayList < T > views ) { final int [ ] locationOnScreen = new int [ 2 ] ; T viewToReturn = null ; long drawingTime = 0 ; if ( views == null ) { return null ; } for ( T view : views ) { if ( view != null ) { view . getLocationOnScreen ( locationOnScreen ) ; if ( locationOnScreen [ 0 ] < 0 || ! ( view . getHeight ( ) > 0 ) ) { continue ; } if ( view . getDrawingTime ( ) > drawingTime ) { drawingTime = view . getDrawingTime ( ) ; viewToReturn = view ; } else if ( view . getDrawingTime ( ) == drawingTime ) { if ( view . isFocused ( ) ) { viewToReturn = view ; } } } } views = null ; return viewToReturn ; }
Tries to guess which view is the most likely to be interesting . Returns the most recently drawn view which presumably will be the one that the user was most recently interacting with .