@@ -79,17 +79,17 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
79
79
80
80
mAgentWeb = AgentWeb .with (this )//
81
81
.setAgentWebParent ((ViewGroup ) view , new LinearLayout .LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT , ViewGroup .LayoutParams .MATCH_PARENT ))//
82
- .setIndicatorColorWithHeight (-1 , 2 )//
83
- .setAgentWebWebSettings (getSettings ())//
84
- .setWebViewClient (mWebViewClient )
85
- .setWebChromeClient (mWebChromeClient )
86
- .setPermissionInterceptor (mPermissionInterceptor )
87
- .setReceivedTitleCallback (mCallback )
88
- .setSecurityType (AgentWeb .SecurityType .strict )
89
- .addDownLoadResultListener (mDownLoadResultListener )
90
- .createAgentWeb ()//
91
- .ready ()//
92
- .go (getUrl ());
82
+ .setIndicatorColorWithHeight (-1 , 2 )//设置进度条颜色与高度-1为默认值,2单位为dp
83
+ .setAgentWebWebSettings (getSettings ())//设置 AgentWebSettings
84
+ .setWebViewClient (mWebViewClient )//WebViewClient , 与WebView 一样
85
+ .setWebChromeClient (mWebChromeClient ) //WebChromeClient
86
+ .setPermissionInterceptor (mPermissionInterceptor ) //权限拦截
87
+ .setReceivedTitleCallback (mCallback )//标题回调
88
+ .setSecurityType (AgentWeb .SecurityType .strict ) //严格模式
89
+ .addDownLoadResultListener (mDownLoadResultListener ) //下载回调
90
+ .createAgentWeb ()//创建AgentWeb
91
+ .ready ()//设置 WebSettings
92
+ .go (getUrl ()); //跳到该页面
93
93
94
94
95
95
initView (view );
@@ -255,6 +255,10 @@ public void onClick(View v) {
255
255
};
256
256
257
257
258
+ /**
259
+ * 打开浏览器
260
+ * @param targetUrl 外部浏览器打开的地址
261
+ */
258
262
private void openBrowser (String targetUrl ) {
259
263
if (TextUtils .isEmpty (targetUrl ) || targetUrl .startsWith ("file://" )) {
260
264
Toast .makeText (this .getContext (), targetUrl + " 该链接无法使用浏览器打开。" , Toast .LENGTH_SHORT ).show ();
@@ -269,6 +273,10 @@ private void openBrowser(String targetUrl) {
269
273
270
274
}
271
275
276
+ /**
277
+ * 显示更多菜单
278
+ * @param view 菜单依附在该View下面
279
+ */
272
280
private void showPoPup (View view ) {
273
281
if (mPopupMenu == null ) {
274
282
mPopupMenu = new PopupMenu (this .getActivity (), view );
@@ -278,6 +286,7 @@ private void showPoPup(View view) {
278
286
mPopupMenu .show ();
279
287
}
280
288
289
+ //菜单的事件处理
281
290
private PopupMenu .OnMenuItemClickListener mOnMenuItemClickListener = new PopupMenu .OnMenuItemClickListener () {
282
291
@ Override
283
292
public boolean onMenuItemClick (MenuItem item ) {
@@ -307,6 +316,7 @@ public boolean onMenuItemClick(MenuItem item) {
307
316
}
308
317
};
309
318
319
+ //清除 WebView 缓存
310
320
private void toCleanWebCache () {
311
321
312
322
if (this .mAgentWeb != null ) {
@@ -321,6 +331,7 @@ private void toCleanWebCache() {
321
331
}
322
332
323
333
334
+ //复制字符串
324
335
private void toCopy (Context context , String text ) {
325
336
326
337
ClipboardManager mClipboardManager = (ClipboardManager ) context .getSystemService (Context .CLIPBOARD_SERVICE );
0 commit comments