Skip to content

Commit bc44cbd

Browse files
AriesHoo@126.comAriesHoo@126.com
AriesHoo@126.com
authored and
AriesHoo@126.com
committed
升级部分三方库增强稳定性
1 parent 890e3b3 commit bc44cbd

File tree

8 files changed

+78
-171
lines changed

8 files changed

+78
-171
lines changed

apk/sample.apk

266 KB
Binary file not shown.

apk/update

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
{
22
"versionCode": 243,
3-
"versionName": "2.2.13_beta12",
3+
"versionName": "2.2.13_beta13",
44
"url": "https://raw.githubusercontent.com/AriesHoo/FastLib/dev/apk/sample.apk",
55
"force": true,
6-
"size": "3.49M",
7-
"message": "1、新增:抽离IStatusBar及INavigationBar分别管理状态栏及导航栏用于Activity个性化
8-
1、新增:抽离IStatusBar及INavigationBar分别管理状态栏及导航栏用于Activity个性化
9-
2、优化:FastMainTabDelegate 回收后tab选中记录并恢复
10-
3、升级:升级widget及SmartRefresh(Androidx版本)
11-
4、优化修改:变更library widget版本以避免软键盘谈起有黑色背景一闪而过得现象"
6+
"size": "3.75M",
7+
"message": "1、升级部分三方库增强稳定性"
128
}

app/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ android {
4242
debug {
4343
//是否debug模式用于控制是否打印log等
4444
debuggable true
45-
zipAlignEnabled true //是否支持Zip Align
45+
zipAlignEnabled false //是否支持Zip Align
4646
shrinkResources false //是否清理无用资源
4747
minifyEnabled false //是否启动混淆
4848
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@@ -89,9 +89,9 @@ dependencies {
8989
//万能适配器--一般都需要吧
9090
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.49-androidx'
9191
//webView库 继承FastWebActivity需要,不需要内置WebView可以不implementation
92-
implementation 'com.just.agentweb:agentweb:4.0.2'
92+
implementation 'com.just.agentweb:agentweb:4.1.2'
9393
//webView提供下载功能
94-
implementation 'com.just.agentweb:download:4.0.2'
94+
implementation'com.download.library:Downloader:4.1.2'
9595
//下拉刷新库注意刷新头SmartRefreshHeader版本最好对应尤其头版本不要低于SmartRefreshLayout版本
9696
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-andx-14'
9797
//Glide图片加载
@@ -110,9 +110,9 @@ dependencies {
110110
//Bugly
111111
implementation 'com.tencent.bugly:crashreport:2.8.6.0'
112112
//哆啦A梦
113-
implementation 'com.didichuxing.doraemonkit:doraemonkit:1.1.2'
114-
// debugImplementation 'com.didichuxing.doraemonkit:doraemonkit:1.1.2'
115-
// releaseImplementation 'com.didichuxing.doraemonkit:doraemonkit-no-op:1.1.2'
113+
implementation 'com.didichuxing.doraemonkit:doraemonkit:1.2.0'
114+
// debugImplementation 'com.didichuxing.doraemonkit:doraemonkit:1.2.0'
115+
// releaseImplementation 'com.didichuxing.doraemonkit:doraemonkit-no-op:1.2.0'
116116
//Multidex 5.0以下
117117
implementation 'androidx.multidex:multidex:2.0.0'
118118
//蒲公英

app/src/main/java/com/aries/library/fast/demo/module/WebViewActivity.java

Lines changed: 54 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@
66
import android.content.Intent;
77
import android.graphics.Color;
88
import android.graphics.drawable.Drawable;
9+
import android.net.Uri;
910
import android.os.Build;
1011
import android.os.Bundle;
1112
import android.text.Html;
1213
import android.text.TextUtils;
1314
import android.util.TypedValue;
1415
import android.view.View;
1516
import android.view.WindowManager;
16-
import android.webkit.WebChromeClient;
1717
import android.webkit.WebView;
1818

19+
import androidx.appcompat.app.AlertDialog;
20+
import androidx.core.content.ContextCompat;
21+
1922
import com.aries.library.fast.demo.R;
2023
import com.aries.library.fast.demo.module.main.MainActivity;
21-
import com.aries.library.fast.demo.util.NotificationUtil;
2224
import com.aries.library.fast.i.IFastRefreshView;
2325
import com.aries.library.fast.manager.LoggerManager;
2426
import com.aries.library.fast.manager.RxJavaManager;
@@ -38,26 +40,25 @@
3840
import com.aries.ui.util.RomUtil;
3941
import com.aries.ui.view.title.TitleBarView;
4042
import com.aries.ui.widget.action.sheet.UIActionSheetDialog;
43+
import com.download.library.DownloadImpl;
44+
import com.download.library.DownloadListenerAdapter;
45+
import com.download.library.Extra;
46+
import com.download.library.ResourceRequest;
4147
import com.just.agentweb.AbsAgentWebSettings;
4248
import com.just.agentweb.AgentWeb;
49+
import com.just.agentweb.AgentWebSettingsImpl;
50+
import com.just.agentweb.DefaultDownloadImpl;
4351
import com.just.agentweb.IAgentWebSettings;
4452
import com.just.agentweb.IVideo;
45-
import com.just.agentweb.LogUtils;
53+
import com.just.agentweb.MiddlewareWebChromeBase;
4654
import com.just.agentweb.VideoImpl;
4755
import com.just.agentweb.WebListenerManager;
48-
import com.just.agentweb.download.AgentWebDownloader;
49-
import com.just.agentweb.download.DefaultDownloadImpl;
50-
import com.just.agentweb.download.DownloadListenerAdapter;
51-
import com.just.agentweb.download.DownloadingService;
5256
import com.scwang.smartrefresh.header.StoreHouseHeader;
5357
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
5458
import com.scwang.smartrefresh.layout.api.RefreshLayout;
5559

5660
import java.io.File;
5761

58-
import androidx.appcompat.app.AlertDialog;
59-
import androidx.core.content.ContextCompat;
60-
6162
/**
6263
* @Author: AriesHoo on 2018/7/30 11:04
6364
* @E-Mail: AriesHoo@126.com
@@ -109,21 +110,16 @@ public void setTitleBar(TitleBarView titleBar) {
109110
.setVisibility(View.GONE);
110111
}
111112
titleBar.setTitleMainTextMarquee(true)
112-
// .setOnRightTextClickListener(new View.OnClickListener() {
113-
// @Override
114-
// public void onClick(View v) {
115-
// WebViewActivity.start(mContext,"www.baidu.com");
116-
// }
117-
// })
118113
.setDividerVisible(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP);
119114
}
120115

121116
@Override
122117
protected void setAgentWeb(AgentWeb.CommonBuilder mAgentBuilder) {
123118
super.setAgentWeb(mAgentBuilder);
124119
//设置 IAgentWebSettings
125-
mAgentBuilder.setAgentWebWebSettings(getSettings())
126-
.setWebChromeClient(new WebChromeClient() {
120+
mAgentBuilder.setAgentWebWebSettings(AgentWebSettingsImpl.getInstance())
121+
.setAgentWebWebSettings(getSettings())
122+
.useMiddlewareWebChrome(new MiddlewareWebChromeBase() {
127123
@Override
128124
public void onProgressChanged(WebView view, int newProgress) {
129125
super.onProgressChanged(view, newProgress);
@@ -135,14 +131,6 @@ public void onProgressChanged(WebView view, int newProgress) {
135131
}
136132
}
137133

138-
@Override
139-
public void onReceivedTitle(WebView view, String title) {
140-
super.onReceivedTitle(view, title);
141-
if (mTitleBar != null) {
142-
mTitleBar.setTitleMainText(title);
143-
}
144-
}
145-
146134
@Override
147135
public void onHideCustomView() {
148136
super.onHideCustomView();
@@ -307,115 +295,6 @@ private IVideo getIVideo() {
307295
return mIVideo;
308296
}
309297

310-
/**
311-
* 更新于 AgentWeb 4.0.0
312-
*/
313-
protected DownloadListenerAdapter mDownloadListenerAdapter = new DownloadListenerAdapter() {
314-
315-
private DownloadingService mDownloadingService;
316-
317-
/**
318-
*
319-
* @param url 下载链接
320-
* @param userAgent UserAgent
321-
* @param contentDisposition ContentDisposition
322-
* @param mimetype 资源的媒体类型
323-
* @param contentLength 文件长度
324-
* @param extra 下载配置 , 用户可以通过 Extra 修改下载icon , 关闭进度条 , 是否强制下载。
325-
* @return true 表示用户处理了该下载事件 , false 交给 AgentWeb 下载
326-
*/
327-
@Override
328-
public boolean onStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength, AgentWebDownloader.Extra extra) {
329-
LogUtils.i(TAG, "onStart:" + url);
330-
// 是否开启断点续传
331-
extra.setOpenBreakPointDownload(true)
332-
//下载通知的icon
333-
.setIcon(R.drawable.ic_file_download_black_24dp)
334-
// 连接最大时长
335-
.setConnectTimeOut(6000)
336-
// 以8KB位单位,默认60s ,如果60s内无法从网络流中读满8KB数据,则抛出异常
337-
.setBlockMaxTime(10 * 60 * 1000)
338-
// 下载最大时长
339-
.setDownloadTimeOut(Long.MAX_VALUE)
340-
// 串行下载更节省资源哦
341-
.setParallelDownload(false)
342-
// false 关闭进度通知
343-
.setEnableIndicator(true)
344-
// 自定义请求头
345-
.addHeader("Cookie", "xx")
346-
// 下载完成自动打开
347-
.setAutoOpen(true)
348-
// 强制下载,不管网络网络类型
349-
.setForceDownload(true);
350-
return false;
351-
}
352-
353-
/**
354-
*
355-
* 不需要暂停或者停止下载该方法可以不必实现
356-
* @param url
357-
* @param downloadingService 用户可以通过 DownloadingService#shutdownNow 终止下载
358-
*/
359-
@Override
360-
public void onBindService(String url, DownloadingService downloadingService) {
361-
super.onBindService(url, downloadingService);
362-
mDownloadingService = downloadingService;
363-
LogUtils.i(TAG, "onBindService:" + url + " DownloadingService:" + downloadingService);
364-
}
365-
366-
/**
367-
* 回调onUnbindService方法,让用户释放掉 DownloadingService。
368-
* @param url
369-
* @param downloadingService
370-
*/
371-
@Override
372-
public void onUnbindService(String url, DownloadingService downloadingService) {
373-
super.onUnbindService(url, downloadingService);
374-
mDownloadingService = null;
375-
LogUtils.i(TAG, "onUnbindService:" + url);
376-
}
377-
378-
/**
379-
*
380-
* @param url 下载链接
381-
* @param loaded 已经下载的长度
382-
* @param length 文件的总大小
383-
* @param usedTime 耗时 ,单位ms
384-
* 注意该方法回调在子线程 ,线程名 AsyncTask #XX 或者 AgentWeb # XX
385-
*/
386-
@Override
387-
public void onProgress(String url, long loaded, long length, long usedTime) {
388-
int mProgress = (int) ((loaded) / Float.valueOf(length) * 100);
389-
LogUtils.i(TAG, "onProgress:" + mProgress);
390-
//进度到100--主动调用关闭下载并重启下载因断点下载直接回调成功
391-
if (mProgress == 100) {
392-
mDownloadingService.shutdownNow().performReDownload();
393-
}
394-
super.onProgress(url, loaded, length, usedTime);
395-
}
396-
397-
/**
398-
*
399-
* @param path 文件的绝对路径
400-
* @param url 下载地址
401-
* @param throwable 如果异常,返回给用户异常
402-
* @return true 表示用户处理了下载完成后续的事件 ,false 默认交给AgentWeb 处理
403-
*/
404-
@Override
405-
public boolean onResult(String path, String url, Throwable throwable) {
406-
NotificationUtil.getInstance().cancelAll();
407-
//下载成功
408-
if (null == throwable) {
409-
if (path.endsWith("apk")) {
410-
FastFileUtil.installApk(new File(path), getPackageName() + ".AgentWebFileProvider");
411-
}
412-
} else {//下载失败
413-
414-
}
415-
// true 不会发出下载完成的通知 , 或者打开文件
416-
return path.endsWith("apk");
417-
}
418-
};
419298

420299
/**
421300
* @return IAgentWebSettings
@@ -431,8 +310,8 @@ protected void bindAgentWebSupport(AgentWeb agentWeb) {
431310

432311
/**
433312
* AgentWeb 4.0.0 内部删除了 DownloadListener 监听 ,以及相关API ,将 Download 部分完全抽离出来独立一个库,
434-
* 如果你需要使用 AgentWeb Download 部分 , 请依赖上 compile 'com.just.agentweb:download:4.0.0
435-
* 如果你需要监听下载结果,请自定义 AgentWebSetting , New 出 DefaultDownloadImpl,传入DownloadListenerAdapter
313+
* 如果你需要使用 AgentWeb Download 部分 , 请依赖上 compile 'com.download.library:Downloader:4.1.1'
314+
* 如果你需要监听下载结果,请自定义 AgentWebSetting , New 出 DefaultDownloadImpl
436315
* 实现进度或者结果监听,例如下面这个例子,如果你不需要监听进度,或者下载结果,下面 setDownloader 的例子可以忽略。
437316
* @param webView
438317
* @param downloadListener
@@ -441,12 +320,44 @@ protected void bindAgentWebSupport(AgentWeb agentWeb) {
441320
@Override
442321
public WebListenerManager setDownloader(WebView webView, android.webkit.DownloadListener downloadListener) {
443322
return super.setDownloader(webView,
444-
DefaultDownloadImpl
445-
.create((Activity) webView.getContext(),
446-
webView,
447-
mDownloadListenerAdapter,
448-
mDownloadListenerAdapter,
449-
this.mAgentWeb.getPermissionInterceptor()));
323+
new DefaultDownloadImpl((Activity) webView.getContext(),
324+
webView,
325+
this.mAgentWeb.getPermissionInterceptor()) {
326+
327+
@Override
328+
protected ResourceRequest createResourceRequest(String url) {
329+
return DownloadImpl.getInstance()
330+
.with(getApplicationContext())
331+
.url(url)
332+
.quickProgress()
333+
.addHeader("", "")
334+
.setEnableIndicator(true)
335+
.autoOpenIgnoreMD5()
336+
.setRetry(5)
337+
.setBlockMaxTime(100000L);
338+
}
339+
340+
@Override
341+
protected void taskEnqueue(ResourceRequest resourceRequest) {
342+
resourceRequest.enqueue(new DownloadListenerAdapter() {
343+
@Override
344+
public void onStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength, Extra extra) {
345+
super.onStart(url, userAgent, contentDisposition, mimetype, contentLength, extra);
346+
}
347+
348+
@MainThread
349+
@Override
350+
public void onProgress(String url, long downloaded, long length, long usedTime) {
351+
super.onProgress(url, downloaded, length, usedTime);
352+
}
353+
354+
@Override
355+
public boolean onResult(Throwable throwable, Uri path, String url, Extra extra) {
356+
return super.onResult(throwable, path, url, extra);
357+
}
358+
});
359+
}
360+
});
450361
}
451362
};
452363
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ ext{
3232
targetSdkVersion = 28
3333
supportVersion = "1.0.0"
3434
versionCode = 243
35-
versionName = "2.2.13_beta12"
35+
versionName = "2.2.13_beta13"
3636
}

library/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ dependencies {
5252
//万能适配器
5353
compileOnly 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.49-androidx'
5454
//webView库
55-
compileOnly 'com.just.agentweb:agentweb:4.0.2'
55+
compileOnly 'com.just.agentweb:agentweb:4.1.2'
5656
//下拉刷新库
5757
compileOnly 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-andx-14'
5858
//图片加载
@@ -68,9 +68,9 @@ dependencies {
6868
//retrofit+rxjava 网络请求及数据解析相关
6969
api "io.reactivex.rxjava2:rxjava:2.2.6"
7070
api 'io.reactivex.rxjava2:rxandroid:2.1.1'
71-
api 'com.squareup.retrofit2:retrofit:2.5.0'
72-
api 'com.squareup.retrofit2:converter-gson:2.5.0'
73-
api 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
71+
api 'com.squareup.retrofit2:retrofit:2.6.1'
72+
api 'com.squareup.retrofit2:converter-gson:2.6.1'
73+
api 'com.squareup.retrofit2:adapter-rxjava2:2.6.1'
7474
//3.12.x是支持Android 4.4的
7575
api 'com.squareup.okhttp3:logging-interceptor:3.12.2'
7676
api 'com.google.code.gson:gson:2.8.5'

library/src/main/java/com/aries/library/fast/FastLifecycleCallbacks.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
172172
public void onActivityDestroyed(Activity activity) {
173173
//横竖屏会重绘将状态重置
174174
if (activity.getIntent() != null) {
175-
activity.getIntent().putExtra(FastConstant.IS_SET_STATUS_VIEW_HELPER, false);
176-
activity.getIntent().putExtra(FastConstant.IS_SET_NAVIGATION_VIEW_HELPER, false);
177-
activity.getIntent().putExtra(FastConstant.IS_SET_CONTENT_VIEW_BACKGROUND, false);
178-
activity.getIntent().putExtra(FastConstant.IS_SET_REFRESH_VIEW, false);
179-
activity.getIntent().putExtra(FastConstant.IS_SET_TITLE_BAR_VIEW, false);
175+
activity.getIntent().removeExtra(FastConstant.IS_SET_STATUS_VIEW_HELPER);
176+
activity.getIntent().removeExtra(FastConstant.IS_SET_NAVIGATION_VIEW_HELPER);
177+
activity.getIntent().removeExtra(FastConstant.IS_SET_CONTENT_VIEW_BACKGROUND);
178+
activity.getIntent().removeExtra(FastConstant.IS_SET_REFRESH_VIEW);
179+
activity.getIntent().removeExtra(FastConstant.IS_SET_TITLE_BAR_VIEW);
180180
}
181181
LoggerManager.i(TAG, "onActivityDestroyed:" + activity.getClass().getSimpleName() + ";isFinishing:" + activity.isFinishing());
182182
FastStackUtil.getInstance().pop(activity, false);

0 commit comments

Comments
 (0)