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

The following examples show how to use android.webkit.WebView#getScale() . 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: WebViewCapture.java    From ViewCapture with Apache License 2.0 6 votes vote down vote up
private Bitmap captureWebView3(WebView wv) {
    try {
        float scale = wv.getScale();
        int height = (int) (wv.getContentHeight() * scale + 0.5);
        Bitmap bitmap = Bitmap.createBitmap(wv.getWidth(), height, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        wv.draw(canvas);
        return bitmap;
    } catch (Exception e) {
        try {
            openCache(wv);
            return wv.getDrawingCache();
        } finally {
            closeCache(wv);
        }
    }
}
 
Example 2
Source File: NestedTouchScrollingLayout.java    From NestedTouchScrollingLayout with MIT License 5 votes vote down vote up
/**
 * 规避 contentHeight 异步变化
 * @return
 */
private boolean canWebViewScrollUp(WebView webView) {
    if (mWebViewContentHeight == 0) {
        mWebViewContentHeight = (int) (webView.getContentHeight() * webView.getScale());
    }
    final int offset = webView.getScrollY();
    final int range = mWebViewContentHeight - webView.getHeight();
    if (range == 0) {
        return false;
    }
    return offset > 2;
}
 
Example 3
Source File: NestedTouchScrollingLayout.java    From NestedTouchScrollingLayout with MIT License 5 votes vote down vote up
/**
 * 规避 contentHeight 异步变化
 * @return
 */
private boolean canWebViewScrollDown(WebView webView) {
    if (mWebViewContentHeight == 0) {
        mWebViewContentHeight = (int) (webView.getContentHeight() * webView.getScale());
    }
    final int offset = webView.getScrollY();
    final int range = mWebViewContentHeight - webView.getHeight();
    if (range == 0) {
        return false;
    }
    return offset < range - 2;
}
 
Example 4
Source File: ScreenShotHelper.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void createType2(WebView webView, FileHelper.OnSavedToGalleryListener listener) {
    float scale = webView.getScale();
    int webViewHeight = (int) (webView.getContentHeight() * scale + 0.5);
    Bitmap bitmap = Bitmap.createBitmap(webView.getWidth(), webViewHeight, Config.RGB_565);
    Canvas canvas = new Canvas(bitmap);
    webView.draw(canvas);
    try {
        FileHelper.saveImageToGallery(PalmApp.getContext(), bitmap, true, listener);
        bitmap.recycle();
    } catch (Exception e) {
        LogUtils.e(e.getMessage());
    }
}
 
Example 5
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 6
Source File: MDRootLayout.java    From talk-android with MIT License 5 votes vote down vote up
private void invalidateDividersForWebView(WebView view, final boolean setForTop, boolean setForBottom, boolean hasButtons) {
    if (setForTop) {
        mDrawTopDivider = mTitleBar != null &&
                mTitleBar.getVisibility() != View.GONE &&
                //Not scrolled to the top.
                view.getScrollY() + view.getPaddingTop() > 0;
    }
    if (setForBottom) {
        //noinspection deprecation
        mDrawBottomDivider = hasButtons &&
                view.getScrollY() + view.getMeasuredHeight() - view.getPaddingBottom() < view.getContentHeight() * view.getScale();
    }
}
 
Example 7
Source File: ScrollingUtil.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public static boolean isWebViewToBottom(WebView webview, int mTouchSlop) {
    return webview != null && ((webview.getContentHeight() * webview.getScale() - (webview.getHeight() + webview.getScrollY())) <= 2 * mTouchSlop);
}
 
Example 8
Source File: MDRootLayout.java    From talk-android with MIT License 4 votes vote down vote up
private static boolean canWebViewScroll(WebView view) {
    //noinspection deprecation
    return view.getMeasuredHeight() < view.getContentHeight() * view.getScale();
}
 
Example 9
Source File: ScrollingUtil.java    From TwinklingRefreshLayout with Apache License 2.0 4 votes vote down vote up
public static boolean isWebViewToBottom(WebView webview, int mTouchSlop) {
    return webview != null && ((webview.getContentHeight() * webview.getScale() - (webview.getHeight() + webview.getScrollY())) <= 2 * mTouchSlop);
}
 
Example 10
Source File: BGAScrollingUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isWebViewToBottom(WebView webView) {
    return webView != null && webView.getContentHeight() * webView.getScale() == (webView.getScrollY() + webView.getMeasuredHeight());
}
 
Example 11
Source File: ScrollingUtil.java    From Pas with Apache License 2.0 4 votes vote down vote up
public static boolean isWebViewToBottom(WebView webView) {
    return webView != null && webView.getContentHeight() * webView.getScale() == (webView.getScrollY() + webView.getMeasuredHeight());
}