From c963aeface36610e38ef915db6a3c42ec83bcbec Mon Sep 17 00:00:00 2001 From: zhangqin Date: Mon, 25 May 2020 15:30:09 +0800 Subject: [PATCH] =?UTF-8?q?webview=20=E6=B7=BB=E5=8A=A0=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=A0=8F=E5=8D=A0=E4=BD=8DView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++---- app/build.gradle | 2 ++ app/src/main/AndroidManifest.xml | 1 - .../quickseed/base/ArouterConstants.java | 1 - .../ui/components/CustomWebviewActivity.java | 4 ++-- .../quickseed/ui/main/MainFragment.java | 4 ++-- config.gradle | 4 ++-- quicklib/src/main/AndroidManifest.xml | 4 ++-- ...iew.java => QuickBaseWebViewActivity.java} | 8 ++------ ...ctivity.java => QuickWebViewActivity.java} | 2 +- ...java => QuickWebViewLoadDataActivity.java} | 9 ++------- .../res/layout/quick_activity_web_view.xml | 19 +++++++++++++++---- .../java/com/sdwfqin/widget/AmountView.java | 1 + 13 files changed, 35 insertions(+), 32 deletions(-) rename quicklib/src/main/java/com/sdwfqin/quicklib/webview/{BaseWebView.java => QuickBaseWebViewActivity.java} (90%) rename quicklib/src/main/java/com/sdwfqin/quicklib/webview/{WebViewActivity.java => QuickWebViewActivity.java} (94%) rename quicklib/src/main/java/com/sdwfqin/quicklib/webview/{WebViewLoadDataActivity.java => QuickWebViewLoadDataActivity.java} (90%) diff --git a/README.md b/README.md index cec78f1..c518ecc 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ ``` groovy // 测试版 -def quicklib = "4.0.0" +def quicklib = "4.0.4" // quicklib(Base) implementation "com.sdwfqin.quicklib:quicklib:$quicklib" @@ -172,9 +172,9 @@ implementation 'com.sdwfqin.quick:widget:3.2.0' | BaseViewModel | ViewModel基类 | | WechatShareTools | 微信分享工具类 | | ImagePreviewActivity | 图片预览Activity(多图/单图) | -| BaseWebView | ViewActivity基类 | -| WebViewActivity | 传入url即可 | -| WebViewLoadDataActivity | 针对非url链接的网页 | +| QuickBaseWebViewActivity | ViewActivity基类 | +| QuickWebViewActivity | 传入url即可 | +| QuickWebViewLoadDataActivity | 针对非url链接的网页 | | GsonUtil | Gson工具类 | | RxSchedulersUtils | compose()统一线程处理 | | RxTimerUtil | RxJava定时任务 | diff --git a/app/build.gradle b/app/build.gradle index efe1eab..5a811b2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -94,6 +94,8 @@ dependencies { implementation project(':paylib') implementation project(':widget') + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.3' annotationProcessor compilerDependencies["arouter-compiler"] diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index be90ba0..2b5d3a0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,7 +33,6 @@ android:supportsRtl="true" android:theme="@style/AppTheme" tools:ignore="GoogleAppIndexingWarning"> - { - protected LinearLayout mContainer; +public abstract class QuickBaseWebViewActivity extends BaseActivity { protected String mUrl; protected AgentWeb mAgentWeb; @@ -31,8 +29,6 @@ protected QuickActivityWebViewBinding getViewBinding() { @Override protected void initEventAndData() { - mContainer = (LinearLayout) findViewById(R.id.container); - if (!StringUtils.isEmpty(getUrl())) { mUrl = getUrl(); } else { @@ -60,7 +56,7 @@ protected void initClickListener() { private void initWebView() { mAgentWeb = AgentWeb.with(mContext) //传入AgentWeb 的父控件 ,如果父控件为 RelativeLayout , 那么第二参数需要传入 RelativeLayout.LayoutParams ,第一个参数和第二个参数应该对应。 - .setAgentWebParent(mContainer, new LinearLayout.LayoutParams(-1, -1)) + .setAgentWebParent(mBinding.container, new LinearLayout.LayoutParams(-1, -1)) .useDefaultIndicator()// 使用默认进度条 .setWebChromeClient(new WebChromeClient() { @Override diff --git a/quicklib/src/main/java/com/sdwfqin/quicklib/webview/WebViewActivity.java b/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewActivity.java similarity index 94% rename from quicklib/src/main/java/com/sdwfqin/quicklib/webview/WebViewActivity.java rename to quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewActivity.java index e5d0014..bb25502 100644 --- a/quicklib/src/main/java/com/sdwfqin/quicklib/webview/WebViewActivity.java +++ b/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewActivity.java @@ -11,7 +11,7 @@ * @date 2018/1/16 */ @Route(path = QuickArouterConstants.QUICK_WEBVIEW) -public class WebViewActivity extends BaseWebView { +public class QuickWebViewActivity extends QuickBaseWebViewActivity { /** * 加载网页 diff --git a/quicklib/src/main/java/com/sdwfqin/quicklib/webview/WebViewLoadDataActivity.java b/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewLoadDataActivity.java similarity index 90% rename from quicklib/src/main/java/com/sdwfqin/quicklib/webview/WebViewLoadDataActivity.java rename to quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewLoadDataActivity.java index 7ac2454..7d088d4 100644 --- a/quicklib/src/main/java/com/sdwfqin/quicklib/webview/WebViewLoadDataActivity.java +++ b/quicklib/src/main/java/com/sdwfqin/quicklib/webview/QuickWebViewLoadDataActivity.java @@ -7,7 +7,6 @@ import com.alibaba.android.arouter.launcher.ARouter; import com.blankj.utilcode.util.StringUtils; import com.just.agentweb.AgentWeb; -import com.sdwfqin.quicklib.R; import com.sdwfqin.quicklib.base.BaseActivity; import com.sdwfqin.quicklib.base.QuickArouterConstants; import com.sdwfqin.quicklib.base.QuickConstants; @@ -20,9 +19,7 @@ * @date 2018/1/16 */ @Route(path = QuickArouterConstants.QUICK_WEBVIEWLOADDATA) -public class WebViewLoadDataActivity extends BaseActivity { - - LinearLayout mContainer; +public class QuickWebViewLoadDataActivity extends BaseActivity { private String mTitle; private String mContent; @@ -50,8 +47,6 @@ protected QuickActivityWebViewBinding getViewBinding() { @Override protected void initEventAndData() { - mContainer = (LinearLayout) findViewById(R.id.container); - mTitle = getIntent().getStringExtra("title"); mContent = getIntent().getStringExtra("content"); mBaseUrl = getIntent().getStringExtra("baseUrl"); @@ -70,7 +65,7 @@ protected void initClickListener() { private void initWebView() { AgentWeb agentWeb = AgentWeb.with(mContext) //传入AgentWeb 的父控件 ,如果父控件为 RelativeLayout , 那么第二参数需要传入 RelativeLayout.LayoutParams ,第一个参数和第二个参数应该对应。 - .setAgentWebParent(mContainer, new LinearLayout.LayoutParams(-1, -1)) + .setAgentWebParent(mBinding.container, new LinearLayout.LayoutParams(-1, -1)) // 使用默认进度条 .useDefaultIndicator() // .defaultProgressBarColor() diff --git a/quicklib/src/main/res/layout/quick_activity_web_view.xml b/quicklib/src/main/res/layout/quick_activity_web_view.xml index a20e38d..ea728f1 100644 --- a/quicklib/src/main/res/layout/quick_activity_web_view.xml +++ b/quicklib/src/main/res/layout/quick_activity_web_view.xml @@ -1,7 +1,18 @@ - + android:orientation="vertical"> + + + + + diff --git a/widget/src/main/java/com/sdwfqin/widget/AmountView.java b/widget/src/main/java/com/sdwfqin/widget/AmountView.java index 829f259..720558b 100644 --- a/widget/src/main/java/com/sdwfqin/widget/AmountView.java +++ b/widget/src/main/java/com/sdwfqin/widget/AmountView.java @@ -41,6 +41,7 @@ public AmountView(Context context, AttributeSet attrs) { super(context, attrs); mBinding = QuickAmountViewBinding.inflate(LayoutInflater.from(context)); + addView(mBinding.getRoot()); mBinding.btnDecrease.setOnClickListener(this); mBinding.btnIncrease.setOnClickListener(this); mBinding.etAmount.addTextChangedListener(this);