修复网络异常时,过度回调的问题
This commit is contained in:
@@ -12,7 +12,7 @@ public class ConnectionChangeReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = ConnectionChangeReceiver.class.getSimpleName();
|
||||
|
||||
@Override public void onReceive(Context context, Intent intent) {
|
||||
Log.d(TAG, "网络状态改变");
|
||||
|
||||
/**
|
||||
* 获得网络连接服务
|
||||
*/
|
||||
@@ -23,11 +23,12 @@ public class ConnectionChangeReceiver extends BroadcastReceiver {
|
||||
|
||||
if (NetworkInfo.State.CONNECTED == state) {
|
||||
Aria.download(this).resumeAllTask();
|
||||
Log.w(TAG, "恢复所有任务");
|
||||
return;
|
||||
}
|
||||
|
||||
Aria.download(this).stopAllTask();
|
||||
|
||||
//Log.w(TAG, "停止所有任务");
|
||||
//state = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
|
||||
//if (NetworkInfo.State.CONNECTED == state) {
|
||||
//
|
||||
|
||||
@@ -70,15 +70,15 @@ final class FileListAdapter extends AbsRVAdapter<FileListEntity, FileListAdapter
|
||||
Toast.makeText(getContext(), "开始下载:" + item.name, Toast.LENGTH_SHORT).show();
|
||||
if (item.isGroup) {
|
||||
Aria.download(getContext())
|
||||
.load(Arrays.asList(item.urls))
|
||||
.loadGroup(Arrays.asList(item.urls))
|
||||
.setSubFileName(Arrays.asList(item.names))
|
||||
.setDownloadDirPath(item.downloadPath)
|
||||
.setDirPath(item.downloadPath)
|
||||
.setGroupAlias(item.name)
|
||||
.start();
|
||||
} else {
|
||||
Aria.download(getContext())
|
||||
.load(item.key)
|
||||
.setDownloadPath(item.downloadPath)
|
||||
.setFilePath(item.downloadPath)
|
||||
.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +144,7 @@ public class MultiDownloadActivity extends BaseActivity<ActivityMultiDownloadBin
|
||||
}
|
||||
|
||||
@DownloadGroup.onTaskRunning() void groupTaskRunning(DownloadGroupTask task) {
|
||||
ALog.d(TAG, String.format("group【%s】running", task.getTaskName()));
|
||||
mAdapter.setProgress(task.getEntity());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user