Java Code Examples for android.webkit.WebView#getLocationOnScreen()

The following examples show how to use android.webkit.WebView#getLocationOnScreen() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebElementCreator.java    From AndroidRipper with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: WebUtils.java    From AndroidRipper with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}