readme 修改

This commit is contained in:
AriaLyy
2017-01-02 17:13:13 +08:00
parent 98db25f832
commit 2a0348e61b
2 changed files with 58 additions and 35 deletions

View File

@ -6,32 +6,32 @@ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
//可以通过intent获取到下载实体下载实体中包含了各种下载状态
DownloadEntity entity = intent.getParcelableExtra(DownloadManager.ENTITY);
DownloadEntity entity = intent.getParcelableExtra(Aria.ENTITY);
switch (action) {
case DownloadManager.ACTION_PRE: //预处理
case Aria.ACTION_PRE: //预处理
break;
case DownloadManager.ACTION_POST_PRE: //预处理完成
case Aria.ACTION_POST_PRE: //预处理完成
//预处理完成,便可以获取文件的下载长度了
len = entity.getFileSize();
break;
case DownloadManager.ACTION_START: //开始下载
case Aria.ACTION_START: //开始下载
L.d(TAG, "download start");
break;
case DownloadManager.ACTION_RESUME: //恢复下载
case Aria.ACTION_RESUME: //恢复下载
L.d(TAG, "download resume");
long location = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 1);
break;
case DownloadManager.ACTION_RUNNING: //下载中
case Aria.ACTION_RUNNING: //下载中
long current = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 0);
break;
case DownloadManager.ACTION_STOP: //停止下载
case Aria.ACTION_STOP: //停止下载
L.d(TAG, "download stop");
break;
case DownloadManager.ACTION_COMPLETE: //下载完成
case Aria.ACTION_COMPLETE: //下载完成
break;
case DownloadManager.ACTION_CANCEL: //取消下载
case Aria.ACTION_CANCEL: //取消下载
break;
case DownloadManager.ACTION_FAIL: // 下载失败
case Aria.ACTION_FAIL: // 下载失败
break;
}
}
@ -44,15 +44,15 @@ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
super.onResume();
IntentFilter filter = new IntentFilter();
filter.addDataScheme(getPackageName());
filter.addAction(DownloadManager.ACTION_PRE);
filter.addAction(DownloadManager.ACTION_POST_PRE);
filter.addAction(DownloadManager.ACTION_RESUME);
filter.addAction(DownloadManager.ACTION_START);
filter.addAction(DownloadManager.ACTION_RUNNING);
filter.addAction(DownloadManager.ACTION_STOP);
filter.addAction(DownloadManager.ACTION_CANCEL);
filter.addAction(DownloadManager.ACTION_COMPLETE);
filter.addAction(DownloadManager.ACTION_FAIL);
filter.addAction(Aria.ACTION_PRE);
filter.addAction(Aria.ACTION_POST_PRE);
filter.addAction(Aria.ACTION_RESUME);
filter.addAction(Aria.ACTION_START);
filter.addAction(Aria.ACTION_RUNNING);
filter.addAction(Aria.ACTION_STOP);
filter.addAction(Aria.ACTION_CANCEL);
filter.addAction(Aria.ACTION_COMPLETE);
filter.addAction(Aria.ACTION_FAIL);
registerReceiver(mReceiver, filter);
}
```
```