-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57e433f
commit 5048ba4
Showing
7 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
sample/src/main/java/com/sample/ui/activity/WebActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.sample.ui.activity; | ||
|
||
import android.content.Intent; | ||
import android.net.http.SslError; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.webkit.SslErrorHandler; | ||
import android.webkit.WebChromeClient; | ||
import android.webkit.WebResourceError; | ||
import android.webkit.WebResourceRequest; | ||
import android.webkit.WebResourceResponse; | ||
import android.webkit.WebView; | ||
import android.webkit.WebViewClient; | ||
import android.widget.RelativeLayout; | ||
|
||
import com.just.library.AgentWeb; | ||
import com.sample.R; | ||
import com.siberiadante.lib.util.LogUtil; | ||
|
||
public class WebActivity extends BaseActivity { | ||
|
||
private RelativeLayout mRLLayout; | ||
private String url; | ||
private String title; | ||
private AgentWeb mAgentWeb; | ||
private WebViewClient mWebViewClient = new WebViewClient() { | ||
@Override | ||
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { | ||
super.onReceivedSslError(view, handler, error); | ||
LogUtil.e("----error----" + error); | ||
handler.proceed(); | ||
} | ||
|
||
@Override | ||
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { | ||
super.onReceivedHttpError(view, request, errorResponse); | ||
} | ||
|
||
@Override | ||
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { | ||
super.onReceivedError(view, request, error); | ||
LogUtil.e("----error----" + error); | ||
} | ||
}; | ||
|
||
private WebChromeClient mWebChromeClient=new WebChromeClient(){ | ||
}; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_web); | ||
mRLLayout = (RelativeLayout) findViewById(R.id.activity_web); | ||
initIntent(); | ||
initWebView(); | ||
} | ||
|
||
private void initIntent() { | ||
final Intent intent = getIntent(); | ||
url = intent.getStringExtra("url"); | ||
title = intent.getStringExtra("title"); | ||
} | ||
|
||
private void initWebView() { | ||
mAgentWeb = AgentWeb.with(this)//传入Activity or Fragment | ||
.setAgentWebParent(mRLLayout, new RelativeLayout.LayoutParams(-1, -1))//传入AgentWeb 的父控件 ,如果父控件为 RelativeLayout , 那么第二参数需要传入 RelativeLayout.LayoutParams ,第一个参数和第二个参数应该对应。 | ||
.useDefaultIndicator()// 使用默认进度条 | ||
.defaultProgressBarColor() // 使用默认进度条颜色 | ||
.setWebViewClient(mWebViewClient) | ||
.setSecutityType(AgentWeb.SecurityType.strict) | ||
.createAgentWeb()// | ||
.ready() | ||
.go("http://www.chinichi.cn/activity/index/app_detail.html?id=5"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/activity_web" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="com.sample.ui.activity.WebActivity"> | ||
|
||
</RelativeLayout> |