public void clickOnScreen ( View view , boolean longClick , int time ) { if ( view == null ) Assert . fail ( "View is null and can therefore not be clicked!" ) ; float [ ] xyToClick = getClickCoordinates ( view ) ; float x = xyToClick [ 0 ] ; float y = xyToClick [ 1 ] ; if ( x == 0 || y == 0 ) { sleeper . sleepMini ( ) ; try { view = viewFetcher . getIdenticalView ( view ) ; } catch ( Exception ignored ) { } if ( view != null ) { xyToClick = getClickCoordinates ( view ) ; x = xyToClick [ 0 ] ; y = xyToClick [ 1 ] ; } } sleeper . sleep ( 300 ) ; if ( longClick ) clickLongOnScreen ( x , y , time , view ) ; else clickOnScreen ( x , y , view ) ; }
Private method used to click on a given view .