Skip to content

Commit

Permalink
fix(AgentWebDownloader.java): fix close indicator invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
Justson committed Mar 6, 2018
1 parent 49ea378 commit 5c5e801
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class Extra implements Serializable {
protected boolean mIsForceDownload = false;
protected boolean mEnableIndicator = true;
@DrawableRes
protected int mIcon = -1;
protected int mIcon = R.drawable.ic_file_download_black_24dp;
protected boolean mIsParallelDownload = true;
protected boolean mIsOpenBreakPointDownload = true;
protected String mUrl;
Expand Down Expand Up @@ -69,7 +69,7 @@ public Extra setHeaders(Map<String, String> headers) {
// 连接超时, 默认10s
protected int connectTimeOut = 10 * 1000;
/**
* 以8KB位单位,默认60s , 如果一秒钟无法从网络中读取数据满1KB,则抛出异常 。
* 以8KB位单位,默认60s ,如果60s内无法从网络流中读满8KB数据,则抛出异常 。
*/
protected int blockMaxTime = 10 * 60 * 1000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
Expand Down Expand Up @@ -516,13 +515,9 @@ public static DefaultDownloadImpl create(@NonNull Activity activity,

public static class ExtraServiceImpl extends AgentWebDownloader.ExtraService implements Cloneable, Serializable {
private transient Activity mActivity;
private boolean mIsForceDownload = false;
private boolean mEnableIndicator = true;
private transient DownloadListener mDownloadListener;
private transient PermissionInterceptor mPermissionInterceptor;
private boolean mIsParallelDownload = true;
private transient WebView mWebView;
protected int mIcon = R.drawable.ic_file_download_black_24dp;
private DefaultDownloadImpl mDefaultDownload;
protected String mUrl;
protected String mUserAgent;
Expand All @@ -537,10 +532,6 @@ public ExtraServiceImpl setDownloadingListener(DownloadingListener downloadingLi
return this;
}

@Override
public boolean isForceDownload() {
return mIsForceDownload;
}

// public static final int PENDDING = 1001;
// public static final int DOWNLOADING = 1002;
Expand Down Expand Up @@ -582,11 +573,6 @@ protected ExtraServiceImpl setContentDisposition(String contentDisposition) {
return this;
}

@Override
@DrawableRes
public int getIcon() {
return mIcon;
}

@Override
public String getMimetype() {
Expand All @@ -610,25 +596,11 @@ protected ExtraServiceImpl setContentLength(long contentLength) {
return this;
}


ExtraServiceImpl setActivity(Activity activity) {
mActivity = activity;
return this;
}


@Override
public ExtraServiceImpl setForceDownload(boolean force) {
mIsForceDownload = force;
return this;
}

@Override
public ExtraServiceImpl setEnableIndicator(boolean enableIndicator) {
this.mEnableIndicator = enableIndicator;
return this;
}

ExtraServiceImpl setDownloadListener(DownloadListener downloadListeners) {
this.mDownloadListener = downloadListeners;
return this;
Expand All @@ -639,24 +611,6 @@ ExtraServiceImpl setPermissionInterceptor(PermissionInterceptor permissionInterc
return this;
}

@Override
public ExtraServiceImpl setIcon(@DrawableRes int icon) {
this.mIcon = icon;
return this;
}

@Override
public ExtraServiceImpl setParallelDownload(boolean parallelDownload) {
mIsParallelDownload = parallelDownload;
return this;
}

@Override
public ExtraServiceImpl setOpenBreakPointDownload(boolean openBreakPointDownload) {
mIsOpenBreakPointDownload = openBreakPointDownload;
return this;
}

ExtraServiceImpl setWebView(WebView webView) {
this.mWebView = webView;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ public boolean intercept(String url, String[] permissions, String action) {
@Override
public boolean onStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength, AgentWebDownloader.Extra extra) {
LogUtils.i(TAG, "onStart:" + url);
extra.setOpenBreakPointDownload(false) // 是否开启断点续传
.setIcon(R.drawable.ic_file_download_black_24dp)
.setConnectTimeOut(6000)
.setBlockMaxTime(2000)
extra.setOpenBreakPointDownload(true) // 是否开启断点续传
.setIcon(R.drawable.ic_file_download_black_24dp) //下载通知的icon
.setConnectTimeOut(6000) // 连接最大时长
.setBlockMaxTime(10 * 60 * 1000) // 以8KB位单位,默认60s ,如果60s内无法从网络流中读满8KB数据,则抛出异常
.setDownloadTimeOut(Long.MAX_VALUE) // 下载最大时长
.setParallelDownload(false) // 串行下载更节省资源哦
.setEnableIndicator(true) // false 关闭进度通知
Expand Down

0 comments on commit 5c5e801

Please sign in to comment.