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 #26 from CodyyAndroid/dev
Browse files Browse the repository at this point in the history
增加wifi网络状态变换时,控制是否需要自动停止或自动开始下载任务
  • Loading branch information
eachann authored Jul 27, 2017
2 parents fc4c33d + d6c790f commit b468455
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 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.7') {
compile('com.github.CodyyAndroid:Downloader:1.1.8') {
exclude group: 'com.android.support'
}
//如果项目中无com.android.support.*包,则保留;
compile('com.github.CodyyAndroid:Downloader:1.1.7')
compile('com.github.CodyyAndroid:Downloader:1.1.8')
}
```
## [API](https://jitpack.io/com/github/CodyyAndroid/Downloader/1.1.7/javadoc/)
## [API](https://jitpack.io/com/github/CodyyAndroid/Downloader/1.1.8/javadoc/)


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 50
versionName "1.1.7"
versionCode 51
versionName "1.1.8"

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.7"
title "下载库1.1.8"
}
}
// 制作文档(Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* 文件下载器
* Created by lijian on 2017/6/7.
*
* @version 1.1.7
* @version 1.1.8
*/

public class Downloader {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* 文件下载状态
* Created by lijian on 2017/6/7.
* @version 0.2.9
* @version 1.1.8
*/
@IntDef({DownloadFlag.NORMAL,
DownloadFlag.WAITING,
Expand All @@ -20,7 +20,7 @@
DownloadFlag.FAILED,
DownloadFlag.ERROR,
DownloadFlag.DELETED,
DownloadFlag.RATING})
DownloadFlag.RATE})
@Documented
@Retention(RetentionPolicy.SOURCE)
public @interface DownloadFlag {
Expand All @@ -32,5 +32,5 @@
int FAILED = 9995;
int ERROR = 9996;
int DELETED = 9999;
int RATING = -1;
int RATE = -1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void run() {
*/
private void sendRatingMessage(List<DownloadEntity> downloadEntities) {
Message message = new Message();
message.what = DownloadFlag.RATING;
message.what = DownloadFlag.RATE;
Bundle bundle = new Bundle();
bundle.putString(DownloadExtra.EXTRA_RATE, DownloadStatus.formatRate(sRates));
bundle.putInt(DownloadExtra.EXTRA_COUNT, downloadEntities.size());
Expand Down Expand Up @@ -683,7 +683,7 @@ public boolean handleMessage(Message msg) {
downLoadListener.onDelete();
}
break;
case DownloadFlag.RATING:
case DownloadFlag.RATE:
if (mRateListener != null) {
// Cog.d(TAG, "Download Rating" + msg.getData().getString(DownloadExtra.EXTRA_ID) + msg.getData().getString(DownloadExtra.EXTRA_RATE) + msg.getData().getInt(DownloadExtra.EXTRA_COUNT, 0));
mRateListener.onRate(msg.getData().getString(DownloadExtra.EXTRA_RATE), msg.getData().getInt(DownloadExtra.EXTRA_COUNT, 0));
Expand All @@ -693,6 +693,9 @@ public boolean handleMessage(Message msg) {
return true;
}

/**
* 网络状态变换时,切换下载状态
*/
private class NetReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Expand All @@ -708,7 +711,7 @@ public void onReceive(Context context, Intent intent) {
startToDownload(context, Downloader.getInstance(context).isHoneyCombDownload());
break;
case NETWORK_WIFI:
startToDownload(context, true);
startToDownload(context, Downloader.getInstance(context).isWifiDownload());
break;
default:
startToDownload(context, false);
Expand Down

0 comments on commit b468455

Please sign in to comment.