Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

Commit

Permalink
Merge pull request #24 from CodyyAndroid/dev
Browse files Browse the repository at this point in the history
新增SimpleDownloadListener
  • Loading branch information
eachann authored Jul 26, 2017
2 parents ef5b512 + fc8dd1f commit 1d80ab9
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ allprojects {
```
dependencies {
//如果项目中已有com.android.support.*包,则从Downloader中剔除;
compile('com.github.CodyyAndroid:Downloader:1.1.5') {
compile('com.github.CodyyAndroid:Downloader:1.1.6') {
exclude group: 'com.android.support'
}
//如果项目中无com.android.support.*包,则保留;
compile('com.github.CodyyAndroid:Downloader:1.1.5')
compile('com.github.CodyyAndroid:Downloader:1.1.6')
}
```
## [API](https://jitpack.io/com/github/CodyyAndroid/Downloader/1.1.5/javadoc/)
## [API](https://jitpack.io/com/github/CodyyAndroid/Downloader/1.1.6/javadoc/)


28 changes: 26 additions & 2 deletions app/src/main/java/com/codyy/downloader/MultiDownloadActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.codyy.download.service.DownLoadListener;
import com.codyy.download.service.DownloadRateListener;
import com.codyy.download.service.DownloadStatus;
import com.codyy.download.service.SimpleDownloadListener;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -252,7 +253,30 @@ public void onClick(View v) {
public void setDataToView(FileEntity data) {
tvName.setText(data.getName());
tvUrl.setText(data.getUrl());
Downloader.getInstance(itemView.getContext()).receiveDownloadStatus(tvUrl.getText().toString(), new DownLoadListener() {
Downloader.getInstance(itemView.getContext()).receiveDownloadStatus(tvUrl.getText().toString(), new SimpleDownloadListener() {
@Override
public void onWaiting() {
btn.setText("等待");
}

@Override
public void onProgress(DownloadStatus status) {
pb.setProgress((int) status.getPercentNumber());
tvName.setText(status.getFormatStatusString());
}

@Override
public void onPause() {
btn.setText("下载");
}

@Override
public void onComplete() {
btn.setText("完成");
}

});
/* Downloader.getInstance(itemView.getContext()).receiveDownloadStatus(tvUrl.getText().toString(), new DownLoadListener() {
@Override
public void onStart() {
btn.setText("暂停");
Expand Down Expand Up @@ -296,7 +320,7 @@ public void onFailure(int code) {
public void onError(Exception e) {
Log.e("Download", " onError :" + e.getMessage());
}
});
});*/
}
}

Expand Down
6 changes: 3 additions & 3 deletions downloadlibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 48
versionName "1.1.5"
versionCode 49
versionName "1.1.6"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down Expand Up @@ -56,7 +56,7 @@ javadoc {
author true
version true
links "http://docs.oracle.com/javase/7/docs/api"
title "下载库1.1.5"
title "下载库1.1.6"
}
}
// 制作文档(Javadoc)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.codyy.download.service;

/**
* Created by lijian on 2017/7/26.
*/

public abstract class SimpleDownloadListener implements DownLoadListener {
@Override
public void onStart() {

}

@Override
public void onWaiting() {

}

@Override
public void onProgress(DownloadStatus status) {

}

@Override
public void onPause() {

}

@Override
public void onComplete() {

}

@Override
public void onDelete() {

}

@Override
public void onFailure(int code) {

}

@Override
public void onError(Exception e) {

}
}

0 comments on commit 1d80ab9

Please sign in to comment.