android.webkit.WebView#setSaveEnabled ( )源码实例Demo

下面列出了android.webkit.WebView#setSaveEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BigApp_Discuz_Android   文件: WebViewUtils.java
/**
 * webview 显示本地图片,自适应布局大小,图片可缩放
 */
public static void showNetImage(Context mContext, final WebView webview,
                                final String imageLocalUrl, int width, int height) {
    final String fileName = "image.png";

    String data = "<HTML><IMG src=\"" + imageLocalUrl + "\"" + "width=" + width + "height=" + height + "/>";
    webview.loadDataWithBaseURL(imageLocalUrl, data, "text/html", "utf-8", null);

    //webview.loadUrl(imageUrl);//直接显示网上图片
    webview.getSettings().setBuiltInZoomControls(true); //显示放大缩小 controler
    webview.getSettings().setSupportZoom(true); //可以缩放
    webview.setSaveEnabled(true);


}
 
源代码2 项目: Xndroid   文件: LightningView.java
public LightningView(@NonNull Activity activity, @Nullable String url, boolean isIncognito) {
    BrowserApp.getAppComponent().inject(this);
    mActivity = activity;
    mUIController = (UIController) activity;
    mWebView = new WebView(activity);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        mWebView.setId(View.generateViewId());
    }
    mIsIncognitoTab = isIncognito;
    mTitle = new LightningViewTitle(activity);

    sMaxFling = ViewConfiguration.get(activity).getScaledMaximumFlingVelocity();

    mWebView.setDrawingCacheBackgroundColor(Color.WHITE);
    mWebView.setFocusableInTouchMode(true);
    mWebView.setFocusable(true);
    mWebView.setDrawingCacheEnabled(false);
    mWebView.setWillNotCacheDrawing(true);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
        //noinspection deprecation
        mWebView.setAnimationCacheEnabled(false);
        //noinspection deprecation
        mWebView.setAlwaysDrawnWithCacheEnabled(false);
    }
    mWebView.setBackgroundColor(Color.WHITE);

    mWebView.setScrollbarFadingEnabled(true);
    mWebView.setSaveEnabled(true);
    mWebView.setNetworkAvailable(true);
    mWebView.setWebChromeClient(new LightningChromeClient(activity, this));
    mWebView.setWebViewClient(new LightningWebClient(activity, this));
    mWebView.setDownloadListener(new LightningDownloadListener(activity));
    mGestureDetector = new GestureDetector(activity, new CustomGestureListener());
    mWebView.setOnTouchListener(new TouchListener());
    sDefaultUserAgent = mWebView.getSettings().getUserAgentString();
    initializeSettings();
    initializePreferences(activity);

    if (url != null) {
        if (!url.trim().isEmpty()) {
            mWebView.loadUrl(url, mRequestHeaders);
        } else {
            // don't load anything, the user is looking for a blank tab
        }
    } else {
        loadHomepage();
    }
}
 
源代码3 项目: BigApp_Discuz_Android   文件: WebViewUtils.java
/**
     * webview 显示本地图片,自适应布局大小,图片可缩放
     *
     * @param mContext
     * @param webview
     * @param imageLocalUrl
     * @param isAdapterScreenWidth 是否自适应屏幕宽度
     * @param color                0-255
     */
    public static void showLocalImage(Context mContext, final WebView webview,
                                      final String imageLocalUrl, int color, boolean isAdapterScreenWidth, boolean doubleClickEabled) {

        boolean fileExist = FileUtils.isExists(imageLocalUrl);

        if (fileExist) {
            String bgcolor = ColorUtils.toBrowserColor(color);

            ZogUtils.printLog(WebViewUtils.class, "bgcolor:" + bgcolor);

            String adapterScreenWidth = "";
            if (isAdapterScreenWidth) {
                adapterScreenWidth = " width:99.9%;";
            }


            String style =
                    "<style>" +
                            "* { margin:0; padding:0; background-color:" +
                            bgcolor +
                            ";  }" +

                            "img { " + adapterScreenWidth + " margin:0; padding:0; }" +

                            "div{" +
                            adapterScreenWidth +
//                            "     border: thin solid #F00;" +
                            "    margin:0; padding:0;" +
                            " }/*这里的width height 大于图片的宽高*/" +

                            "table{ height:100%; width:100%; text-align:center;}" +

                            " </style>";


            String body = "    <body>" +
                    "        <div>" +
                    "            <table>" +
                    "                <tr>" +
                    "                    <td>" +
                    "                       <img src=\"file://" + imageLocalUrl + "\"" +
//                            "                                width=" + width +
                    "                               margin=" + 0 +
                    "                               padding=" + 0 +
//                    "                               height="+height+
                    "                           />" +
                    "                    </td>" +
                    "                </tr>" +
                    "            </table>" +
                    "        </div>" +
                    "    </body>" +
                    "";

            String data = style + body;

            webview.loadDataWithBaseURL("file://" + imageLocalUrl, data, "text/html", "utf-8", null);

            //webview.loadUrl(imageUrl);//直接显示网上图片

            webview.setVerticalScrollBarEnabled(false); // 取消Vertical ScrollBar显示
            webview.setHorizontalScrollBarEnabled(false); //取消Horizontal ScrollBar显示
            webview.getSettings().setBuiltInZoomControls(true); //显示放大缩小 controler
            webview.getSettings().setSupportZoom(true); //可以缩放
            setZoomControlGone(webview);//去掉zoom按钮

            if (doubleClickEabled) {//双击缩放
                webview.getSettings().setUseWideViewPort(true);
                webview.getSettings().setLoadWithOverviewMode(true);
            }
            webview.setSaveEnabled(true);


        }
    }
 
源代码4 项目: JumpGo   文件: LightningView.java
public LightningView(@NonNull Activity activity, @Nullable String url, boolean isIncognito) {
    BrowserApp.getAppComponent().inject(this);
    mActivity = activity;
    mUIController = (UIController) activity;
    mWebView = new WebView(activity);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        mWebView.setId(View.generateViewId());
    }
    mIsIncognitoTab = isIncognito;
    mTitle = new LightningViewTitle(activity);

    sMaxFling = ViewConfiguration.get(activity).getScaledMaximumFlingVelocity();

    mWebView.setDrawingCacheBackgroundColor(Color.WHITE);
    mWebView.setFocusableInTouchMode(true);
    mWebView.setFocusable(true);
    mWebView.setDrawingCacheEnabled(false);
    mWebView.setWillNotCacheDrawing(true);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
        //noinspection deprecation
        mWebView.setAnimationCacheEnabled(false);
        //noinspection deprecation
        mWebView.setAlwaysDrawnWithCacheEnabled(false);
    }
    mWebView.setBackgroundColor(Color.WHITE);

    mWebView.setScrollbarFadingEnabled(true);
    mWebView.setSaveEnabled(true);
    mWebView.setNetworkAvailable(true);
    mWebView.setWebChromeClient(new LightningChromeClient(activity, this));
    mLightningWebClient = new LightningWebClient(activity, this);
    mWebView.setWebViewClient(mLightningWebClient);
    mWebView.setDownloadListener(new LightningDownloadListener(activity));
    mGestureDetector = new GestureDetector(activity, new CustomGestureListener());
    mWebView.setOnTouchListener(new TouchListener());
    sDefaultUserAgent = mWebView.getSettings().getUserAgentString();
    initializeSettings();
    initializePreferences(activity);

    if (url != null) {
        if (!url.trim().isEmpty()) {
            mWebView.loadUrl(url, mRequestHeaders);
        } else {
            // don't load anything, the user is looking for a blank tab
        }
    } else {
        loadHomepage();
    }
}