diff --git a/README.md b/README.md
index c518ecc..ac37448 100644
--- a/README.md
+++ b/README.md
@@ -109,9 +109,7 @@
# 导入指南
``` groovy
-// 测试版
-
-def quicklib = "4.0.4"
+def quicklib = "4.0.5"
// quicklib(Base)
implementation "com.sdwfqin.quicklib:quicklib:$quicklib"
@@ -123,22 +121,6 @@ implementation "com.sdwfqin.quicklib:paylib:$quicklib"
implementation "com.sdwfqin.quicklib:imageloader:$quicklib"
// Android 自定义View组件
implementation "com.sdwfqin.quicklib:widget:$quicklib"
-
-// =================================================
-
-// 稳定版
-
-// quicklib(Base)
-implementation 'com.sdwfqin.quicklib:quicklib:3.3.0'
-
-// 支付模块
-implementation 'com.sdwfqin.quicklib:paylib:3.1.0'
-
-// Android 图片加载库(Glide封装)
-implementation 'com.sdwfqin.quick:imageloader:3.2.0'
-
-// Android 自定义View组件
-implementation 'com.sdwfqin.quick:widget:3.2.0'
```
# 相关文档
diff --git a/app/release/app-release.apk b/app/release/app-release.apk
index 20765d7..b715197 100644
Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2b5d3a0..2c6026c 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -33,6 +33,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
+
-
-
-
-
+
+
+
+
+
+ *
+ * @author 张钦
+ * @date 2020/5/27
+ */
+@Route(path = ArouterConstants.COMPONENTS_WEBVIEW)
+public class WebViewMainActivity extends BaseActivity {
+
+ private String[] mTitle = new String[]{
+ "默认",
+ "自定义",
+ "加载本地html"
+ };
+
+ @Override
+ protected ActivitySampleListBinding getViewBinding() {
+ return ActivitySampleListBinding.inflate(getLayoutInflater());
+ }
+
+ @Override
+ protected void initEventAndData() {
+ mTopBar.setTitle("WebView Demo");
+ mTopBar.addLeftBackImageButton().setOnClickListener(v -> finish());
+
+ mBinding.list.setAdapter(new ArrayAdapter<>(mContext, R.layout.item_list, R.id.tv_items, mTitle));
+ }
+
+ @Override
+ protected void initClickListener() {
+ mBinding.list.setOnItemClickListener((adapterView, view, i, l) -> {
+ switch (i) {
+ case 0:
+ QuickWebViewActivity.launch("https://www.baidu.com");
+ break;
+ case 1:
+ ARouter.getInstance().build(ArouterConstants.COMPONENTS_CUSTOMWEBVIEW).navigation();
+ break;
+ case 2:
+ QuickWebViewLoadDataActivity.launch(null, "测试标题", QuickConstants.HEAD + "哈哈哈哈" + QuickConstants.END, false);
+ break;
+ default:
+ }
+ });
+ }
+}
diff --git a/app/src/main/java/com/sdwfqin/quickseed/ui/main/MainFragment.java b/app/src/main/java/com/sdwfqin/quickseed/ui/main/MainFragment.java
index 016a276..b047695 100644
--- a/app/src/main/java/com/sdwfqin/quickseed/ui/main/MainFragment.java
+++ b/app/src/main/java/com/sdwfqin/quickseed/ui/main/MainFragment.java
@@ -13,7 +13,6 @@
import com.sdwfqin.quicklib.base.BaseFragment;
import com.sdwfqin.quicklib.dialog.HintDialog;
import com.sdwfqin.quicklib.imagepreview.ImagePreviewActivity;
-import com.sdwfqin.quicklib.webview.QuickWebViewActivity;
import com.sdwfqin.quickseed.R;
import com.sdwfqin.quickseed.base.ArouterConstants;
import com.sdwfqin.quickseed.databinding.FragmentMainBinding;
@@ -37,10 +36,9 @@ public class MainFragment extends BaseFragment {
"Camerax(支持二维码识别)",
"VLayoutDemo",
"展示SVG图片",
- "跳转网页",
- "自定义Webview",
+ "WebView",
"悬浮窗与截图",
- "弹窗",
+ "支持换肤的弹窗",
"Mvvm Demo",
"Mvp Demo",
"圆(方)形加载进度条",
@@ -88,15 +86,12 @@ protected void initClickListener() {
ARouter.getInstance().build(ArouterConstants.COMPONENTS_SHOWSVG).navigation();
break;
case 7:
- QuickWebViewActivity.launch("https://www.baidu.com");
+ ARouter.getInstance().build(ArouterConstants.COMPONENTS_WEBVIEW).navigation();
break;
case 8:
- ARouter.getInstance().build(ArouterConstants.COMPONENTS_CUSTOMWEBVIEW).navigation();
- break;
- case 9:
ARouter.getInstance().build(ArouterConstants.COMPONENTS_WINDOWFLOATANDSCREENSHOT).navigation();
break;
- case 10:
+ case 9:
HintDialog hintDialog = new HintDialog(mContext);
hintDialog.setFollowSkin(true);
hintDialog.show();
@@ -115,13 +110,13 @@ public void right() {
}
});
break;
- case 11:
+ case 10:
ARouter.getInstance().build(ArouterConstants.COMPONENTS_MVVM).navigation();
break;
- case 12:
+ case 11:
ARouter.getInstance().build(ArouterConstants.COMPONENTS_MVP).navigation();
break;
- case 13:
+ case 12:
ARouter.getInstance().build(ArouterConstants.COMPONENTS_CIRCLEPROGRESSDEMO).navigation();
break;
default:
diff --git a/app/src/main/res/layout/activity_sample_list.xml b/app/src/main/res/layout/activity_sample_list.xml
new file mode 100644
index 0000000..3ffe662
--- /dev/null
+++ b/app/src/main/res/layout/activity_sample_list.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/config.gradle b/config.gradle
index bb1a322..eddf1cf 100644
--- a/config.gradle
+++ b/config.gradle
@@ -1,7 +1,7 @@
ext {
- versionCode = 40094
- versionName = "4.0.4"
+ versionCode = 40095
+ versionName = "4.0.5"
qmui = "2.0.0-alpha09"
okhttp = "4.6.0"
diff --git a/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickBaseWebViewActivity.java b/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickBaseWebViewActivity.java
index 8c88143..57779cb 100644
--- a/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickBaseWebViewActivity.java
+++ b/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickBaseWebViewActivity.java
@@ -4,14 +4,13 @@
import android.webkit.WebView;
import android.widget.LinearLayout;
-import com.blankj.utilcode.util.StringUtils;
import com.just.agentweb.AgentWeb;
import com.just.agentweb.WebChromeClient;
import com.sdwfqin.quicklib.base.BaseActivity;
import com.sdwfqin.quicklib.databinding.QuickActivityWebViewBinding;
/**
- * 描述:
+ * 描述:WebViewActivity基类
*
* @author zhangqin
* @date 2018/6/19
@@ -28,14 +27,6 @@ protected QuickActivityWebViewBinding getViewBinding() {
@Override
protected void initEventAndData() {
-
- if (!StringUtils.isEmpty(getUrl())) {
- mUrl = getUrl();
- } else {
- showMsg("未获取到url地址");
- finish();
- }
-
mTopBar.setTitle(getActivityTitle());
mTopBar.addLeftBackImageButton().setOnClickListener(v -> {
@@ -48,13 +39,8 @@ protected void initEventAndData() {
initWebView();
}
- @Override
- protected void initClickListener() {
-
- }
-
- private void initWebView() {
- mAgentWeb = AgentWeb.with(mContext)
+ protected AgentWeb.CommonBuilder getWebViewCommonBuilder() {
+ return AgentWeb.with(mContext)
//传入AgentWeb 的父控件 ,如果父控件为 RelativeLayout , 那么第二参数需要传入 RelativeLayout.LayoutParams ,第一个参数和第二个参数应该对应。
.setAgentWebParent(mBinding.container, new LinearLayout.LayoutParams(-1, -1))
.useDefaultIndicator()// 使用默认进度条
@@ -62,13 +48,19 @@ private void initWebView() {
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
- mTopBar.setTitle(title);
+ if (isAutoSetTitle()) {
+ mTopBar.setTitle(title);
+ }
}
- })
+ });
+ }
+
+ protected void initWebView() {
+ mAgentWeb = getWebViewCommonBuilder()
//.defaultProgressBarColor() // 使用默认进度条颜色
.createAgentWeb()
.ready()
- .go(mUrl);
+ .go(mUrl = getUrl());
}
@Override
@@ -107,17 +99,20 @@ protected void onDestroy() {
/**
* 设置url地址
- *
- * @return
*/
public abstract String getUrl();
/**
* 设置标题
- *
- * @return
*/
public String getActivityTitle() {
return "";
}
+
+ /**
+ * 是否监听标题变化
+ */
+ protected boolean isAutoSetTitle() {
+ return true;
+ }
}
diff --git a/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewActivity.java b/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewActivity.java
index bb25502..e053f95 100644
--- a/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewActivity.java
+++ b/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewActivity.java
@@ -5,7 +5,7 @@
import com.sdwfqin.quicklib.base.QuickArouterConstants;
/**
- * 描述:WebViewActivity
+ * 描述:默认WebViewActivity
*
* @author 张钦
* @date 2018/1/16
@@ -19,7 +19,7 @@ public class QuickWebViewActivity extends QuickBaseWebViewActivity {
* @param url 页面地址
*/
public static void launch(String url) {
- launch(url, null);
+ launch(url, "");
}
/**
@@ -29,11 +29,23 @@ public static void launch(String url) {
* @param title 默认标题
*/
public static void launch(String url, String title) {
+ launch(url, "", true);
+ }
+
+ /**
+ * 加载网页,带有默认标题
+ *
+ * @param url 页面地址
+ * @param title 默认标题
+ * @param autoSetTitle 是否自动监听设置标题
+ */
+ public static void launch(String url, String title, boolean autoSetTitle) {
ARouter
.getInstance()
.build(QuickArouterConstants.QUICK_WEBVIEW)
.withString("url", url)
.withString("title", title)
+ .withBoolean("autoSetTitle", autoSetTitle)
.navigation();
}
@@ -49,4 +61,9 @@ public String getActivityTitle() {
}
return super.getActivityTitle();
}
+
+ @Override
+ protected boolean isAutoSetTitle() {
+ return getIntent().getBooleanExtra("autoSetTitle", true);
+ }
}
diff --git a/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewLoadDataActivity.java b/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewLoadDataActivity.java
index 7d088d4..f9fb9df 100644
--- a/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewLoadDataActivity.java
+++ b/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewLoadDataActivity.java
@@ -1,94 +1,94 @@
package com.sdwfqin.quicklib.webview;
import android.view.View;
-import android.widget.LinearLayout;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.StringUtils;
-import com.just.agentweb.AgentWeb;
-import com.sdwfqin.quicklib.base.BaseActivity;
import com.sdwfqin.quicklib.base.QuickArouterConstants;
import com.sdwfqin.quicklib.base.QuickConstants;
-import com.sdwfqin.quicklib.databinding.QuickActivityWebViewBinding;
/**
- * 描述:WebViewActivity
+ * 描述:加载htmlData的WebViewActivity
*
* @author 张钦
* @date 2018/1/16
*/
@Route(path = QuickArouterConstants.QUICK_WEBVIEWLOADDATA)
-public class QuickWebViewLoadDataActivity extends BaseActivity {
+public class QuickWebViewLoadDataActivity extends QuickBaseWebViewActivity {
- private String mTitle;
private String mContent;
private String mBaseUrl;
+ /**
+ * @param title 标题
+ * @param content html文本
+ */
public static void launch(String title, String content) {
launch("", title, content);
}
+ /**
+ * @param baseUrl
+ * @param title 标题
+ * @param content html文本
+ */
public static void launch(String baseUrl, String title, String content) {
+ launch("", title, content, true);
+ }
+
+ /**
+ * @param baseUrl
+ * @param title 标题
+ * @param content html文本
+ * @param autoSetTitle 是否自动监听设置标题
+ */
+ public static void launch(String baseUrl, String title, String content, boolean autoSetTitle) {
ARouter
.getInstance()
- .build(QuickArouterConstants.QUICK_WEBVIEW)
+ .build(QuickArouterConstants.QUICK_WEBVIEWLOADDATA)
.withString("title", title)
.withString("content", content)
.withString("baseUrl", baseUrl)
+ .withBoolean("autoSetTitle", autoSetTitle)
.navigation();
}
- @Override
- protected QuickActivityWebViewBinding getViewBinding() {
- return QuickActivityWebViewBinding.inflate(getLayoutInflater());
- }
-
@Override
protected void initEventAndData() {
+ super.initEventAndData();
- mTitle = getIntent().getStringExtra("title");
mContent = getIntent().getStringExtra("content");
mBaseUrl = getIntent().getStringExtra("baseUrl");
- mTopBar.addLeftBackImageButton().setOnClickListener(v -> finish());
- mTopBar.setTitle(mTitle);
-
- initWebView();
- }
-
- @Override
- protected void initClickListener() {
-
+ loadDataHtml();
}
- private void initWebView() {
- AgentWeb agentWeb = AgentWeb.with(mContext)
- //传入AgentWeb 的父控件 ,如果父控件为 RelativeLayout , 那么第二参数需要传入 RelativeLayout.LayoutParams ,第一个参数和第二个参数应该对应。
- .setAgentWebParent(mBinding.container, new LinearLayout.LayoutParams(-1, -1))
- // 使用默认进度条
- .useDefaultIndicator()
- // .defaultProgressBarColor()
- .createAgentWeb()
- .ready()
- .go(null);
- agentWeb.getWebCreator().getWebView().setLayerType(View.LAYER_TYPE_NONE, null);
+ private void loadDataHtml() {
+ mAgentWeb.getWebCreator().getWebView().setLayerType(View.LAYER_TYPE_NONE, null);
if (StringUtils.isEmpty(mBaseUrl)) {
- agentWeb
+ mAgentWeb
.getUrlLoader()
- .loadData(QuickConstants.HEAD +
- mContent +
- QuickConstants.END
- , "text/html", "UTF-8");
+ .loadData(mContent, "text/html", "UTF-8");
} else {
- agentWeb
+ mAgentWeb
.getUrlLoader()
- .loadDataWithBaseURL(QuickConstants.BASE_URL,
- QuickConstants.HEAD +
- mContent +
- QuickConstants.END
- , "text/html", "UTF-8", null);
+ .loadDataWithBaseURL(QuickConstants.BASE_URL, mContent, "text/html", "UTF-8", null);
}
+ }
+
+ @Override
+ public String getUrl() {
+ return null;
+ }
+ @Override
+ public String getActivityTitle() {
+ return getIntent().getStringExtra("title");
+ }
+
+ @Override
+ protected boolean isAutoSetTitle() {
+ return getIntent().getBooleanExtra("autoSetTitle", true);
}
}