Giter VIP home page Giter VIP logo

commwebview's Introduction

CommWebView License Download

通用webview

  • 避免API < 17 下的漏洞
  • 加载错误时出现默认页面
  • 点击默认页面可重新加载(刷新)--->两种错误提示页面
  • 方便获取当前在加载页面的url和title
  • 与js交互不变
  • 可设置背景透明

导入

app/gradle中加入依赖

compile 'com.jwkj:commwebview:v1.2.6'

用法

初始化并加载页面

         wv_main = (CommWebView) findViewById(R.id.wv_main);
         wv_main.setCurWebUrl("https://www.baidu.com1")
                .addJavascriptInterface(new JSCallJava(), "NativeObj")
                .startCallback(new WebViewCallback() {
                    @Override
                    public void onStart() {
                        ELog.e("开始调用了");
                        mProgressDialog.show();
                    }

                    @Override
                    public void onProgress(int curProgress) {
                        ELog.e(curProgress);
                        if (curProgress > 80) {//加载完成80%以上就可以隐藏了,防止部分网页不能
                            mProgressDialog.dismiss();
                            tvTitle.setText(wv_main.getWebTitle());
                        }
                    }

                    @Override
                    public void onError(int errorCode, String description, String failingUrl) {
                        super.onError(errorCode, description, failingUrl);
                        ELog.e(errorCode + " \t" + description + "\t" + failingUrl);
                    }
                });

销毁

在avtivity销毁的时候需要将webview销毁

 @Override
    protected void onDestroy() {
        wv_main.onDestroy();
        super.onDestroy();
    }

效果图

中文加载失败页面1(默认)

中文加载失败页面2

英文加载失败页面1(默认)

英文加载失败页面2

版本记录

v1.2.6 ( 2018.03.22 )

  • 【优化】适配Android8.0

v1.2.5 ( 2018.01.25 )

  • 【优化】点击默认加载失败页面的刷新无效问题

v1.2.4 ( 2017.11.23 )

  • 【优化】部分魅族手机崩溃问题

v1.2.3 ( 2017.11.15 )

  • 【优化】删除清单文件中的appname,防止部分依赖时app名字被修改

v1.2.2 ( 2017.11.08 )

  • 【新增】onPageFinished回调

v1.2.1 ( 2017.10.25 )

  • 【新增】视频全屏与退出全屏监听

v1.1.4 ( 2017.09.11 )

  • 【新增】网络错误默认页面,通过方法设置setNetErrorConfig(CommWebView.NetErrorConfig.DEFAULT_BUTTON);,默认是DEFAULT_BODY

v1.1.2 ( 2017.09.08 )

  • 【修复】特殊情况抛出空指针

v1.0.9 ( 2017.09.01 )

  • 【修复】中文环境无网络环境时的标题为英文

v1.0.8 ( 2017.08.21 )

  • 【新增】设置是否背景透明方法setTransparent(默认不透明)

v1.0.7 ( 2017.08.04 )

  • 【新增】evaluateJavascript方法
  • 【新增】获取原生WebView方法

v1.0.6

  • 【修复】部分网页大不开

v1.0.5

  • 【新增】英文版加载失败页面(带刷新功能)

v1.0.4

  • 【新增】中文版加载失败页面(带刷新功能)

v1.0.4 以前版本未记录

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.