Skip to content

added feature to show/hide download thread log #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public class SimpleActivity extends BaseActivity implements View.OnClickListener {

public static final String DEFAULT_URL = "https://3b8637d9f6c334dab555e2afbdc16687.dlied1.cdntips.net/imtt.dd.qq.com/16891/apk/49F7A4E3B47E5828D02B2A10C580DB65.apk";
public static final String DEFAULT_URL = "http://212.183.159.230/5MB.zip";


private TextView tv_download_info;
Expand Down Expand Up @@ -122,6 +122,7 @@ private void createDownload() {
String path = d.getAbsolutePath().concat("/").concat("a.apk");
downloadInfo = new DownloadInfo.Builder().setUrl(DEFAULT_URL)
.setPath(path)
.setShowProgressLog(false)
.build();
setDownloadListener();
downloadManager.download(downloadInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ private void executeDownload() {
downloadProgressListener.onProgress();
// }

Log.d(TAG,
"downloadInfo:" + downloadInfo.getId() + " thread:" + downloadThreadInfo.getThreadId()
+ " progress:"
+ downloadThreadInfo.getProgress()
+ ",start:" + downloadThreadInfo.getStart() + ",end:" + downloadThreadInfo
.getEnd());
// if true then show log
if(downloadInfo.isShowDownloadLog()){
Log.d(TAG,
"downloadInfo:" + downloadInfo.getId() + " thread:" + downloadThreadInfo.getThreadId()
+ " progress:"
+ downloadThreadInfo.getProgress()
+ ",start:" + downloadThreadInfo.getStart() + ",end:" + downloadThreadInfo
.getEnd());
}
}

//downloadInfo success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ public class DownloadInfo implements Serializable {
*/
private int supportRanges;

// to show or hide download progress LOG
private boolean showDownloadLog = true;

public boolean isShowDownloadLog() {
return showDownloadLog;
}
public void setShowDownloadLog(boolean showDownloadLog) {
this.showDownloadLog = showDownloadLog;
}

private List<DownloadThreadInfo> downloadThreadInfos;


Expand Down Expand Up @@ -217,6 +227,7 @@ public static final class Builder {
private long createAt = -1;
private String url;
private String path;
private boolean showProgressLog=true;

public Builder() {

Expand All @@ -228,6 +239,12 @@ public Builder setCreateAt(long createAt) {
return this;
}

public Builder setShowProgressLog(boolean showProgressLog) {
this.showProgressLog = showProgressLog;
return this;

}


public Builder setUrl(String url) {
this.url = url;
Expand Down Expand Up @@ -271,6 +288,7 @@ public DownloadInfo build() {
} else {
downloadInfo.setId(id);
}
downloadInfo.setShowDownloadLog(this.showProgressLog);

return downloadInfo;
}
Expand Down