/** * Sets the location of a {@code WebElement} * * @param webElement the {@code TextView} object to set location * @param webView the {@code WebView} the text is shown in * @param x the x location to set * @param y the y location to set * @param width the width to set * @param height the height to set */ private void setLocation(WebElement webElement, WebView webView, int x, int y, int width, int height ){ float scale = webView.getScale(); int[] locationOfWebViewXY = new int[2]; webView.getLocationOnScreen(locationOfWebViewXY); int locationX = (int) (locationOfWebViewXY[0] + (x + (Math.floor(width / 2))) * scale); int locationY = (int) (locationOfWebViewXY[1] + (y + (Math.floor(height / 2))) * scale); webElement.setLocationX(locationX); webElement.setLocationY(locationY); }
/** * Returns true if the view is sufficiently shown * * @param view the view to check * @return true if the view is sufficiently shown */ public final boolean isWebElementSufficientlyShown(WebElement webElement){ final WebView webView = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(WebView.class, true)); final int[] xyWebView = new int[2]; if(webView != null && webElement != null){ webView.getLocationOnScreen(xyWebView); if(xyWebView[1] + webView.getHeight() > webElement.getLocationY()) return true; } return false; }
@Override public void getLocationOnScreen(int[] location) { mWebView.getLocationOnScreen(location); }
/** * Sets the location of a {@code WebElement} * * @param webElement the {@code TextView} object to set location * @param webView the {@code WebView} the text is shown in * @param x the x location to set * @param y the y location to set * @param width the width to set * @param height the height to set */ private void setLocation(WebElement webElement, WebView webView, int x, int y, int width, int height ){ float scale = webView.getScale(); int[] locationOfWebViewXY = new int[2]; webView.getLocationOnScreen(locationOfWebViewXY); int locationX = (int) (locationOfWebViewXY[0] + (x + (Math.floor(width / 2))) * scale); int locationY = (int) (locationOfWebViewXY[1] + (y + (Math.floor(height / 2))) * scale); webElement.setLocationX(locationX); webElement.setLocationY(locationY); }
/** * Returns true if the view is sufficiently shown * * @param view the view to check * @return true if the view is sufficiently shown */ public final boolean isWebElementSufficientlyShown(WebElement webElement){ final WebView webView = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(WebView.class, true)); final int[] xyWebView = new int[2]; if(webView != null && webElement != null){ webView.getLocationOnScreen(xyWebView); if(xyWebView[1] + webView.getHeight() > webElement.getLocationY()) return true; } return false; }