|
|
@ -218,7 +218,7 @@ public class Task { |
|
|
|
@Override public void onPre() { |
|
|
|
@Override public void onPre() { |
|
|
|
super.onPre(); |
|
|
|
super.onPre(); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_PRE); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_PRE); |
|
|
|
//sendIntent(DownloadManager.ACTION_PRE, -1);
|
|
|
|
sendIntent(DownloadManager.ACTION_PRE, -1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onPostPre(long fileSize) { |
|
|
|
@Override public void onPostPre(long fileSize) { |
|
|
@ -226,21 +226,22 @@ public class Task { |
|
|
|
downloadEntity.setFileSize(fileSize); |
|
|
|
downloadEntity.setFileSize(fileSize); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_POST_PRE); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_POST_PRE); |
|
|
|
sendInState2Target(DownloadSchedulers.PRE); |
|
|
|
sendInState2Target(DownloadSchedulers.PRE); |
|
|
|
//sendIntent(DownloadManager.ACTION_POST_PRE, -1);
|
|
|
|
sendIntent(DownloadManager.ACTION_POST_PRE, -1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onResume(long resumeLocation) { |
|
|
|
@Override public void onResume(long resumeLocation) { |
|
|
|
super.onResume(resumeLocation); |
|
|
|
super.onResume(resumeLocation); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_DOWNLOAD_ING); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_DOWNLOAD_ING); |
|
|
|
sendInState2Target(DownloadSchedulers.RESUME); |
|
|
|
sendInState2Target(DownloadSchedulers.RESUME); |
|
|
|
//sendIntent(DownloadManager.ACTION_RESUME, resumeLocation);
|
|
|
|
sendIntent(DownloadManager.ACTION_RESUME, resumeLocation); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onStart(long startLocation) { |
|
|
|
@Override public void onStart(long startLocation) { |
|
|
|
super.onStart(startLocation); |
|
|
|
super.onStart(startLocation); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_DOWNLOAD_ING); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_DOWNLOAD_ING); |
|
|
|
|
|
|
|
downloadEntity.setFailNum(0); |
|
|
|
sendInState2Target(DownloadSchedulers.START); |
|
|
|
sendInState2Target(DownloadSchedulers.START); |
|
|
|
//sendIntent(DownloadManager.ACTION_START, startLocation);
|
|
|
|
sendIntent(DownloadManager.ACTION_START, startLocation); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onProgress(long currentLocation) { |
|
|
|
@Override public void onProgress(long currentLocation) { |
|
|
@ -259,7 +260,7 @@ public class Task { |
|
|
|
downloadEntity.setCurrentProgress(currentLocation); |
|
|
|
downloadEntity.setCurrentProgress(currentLocation); |
|
|
|
lastLen = currentLocation; |
|
|
|
lastLen = currentLocation; |
|
|
|
sendInState2Target(DownloadSchedulers.RUNNING); |
|
|
|
sendInState2Target(DownloadSchedulers.RUNNING); |
|
|
|
//context.sendBroadcast(sendIntent);
|
|
|
|
context.sendBroadcast(sendIntent); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -268,14 +269,14 @@ public class Task { |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_STOP); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_STOP); |
|
|
|
downloadEntity.setSpeed(0); |
|
|
|
downloadEntity.setSpeed(0); |
|
|
|
sendInState2Target(DownloadSchedulers.STOP); |
|
|
|
sendInState2Target(DownloadSchedulers.STOP); |
|
|
|
//sendIntent(DownloadManager.ACTION_STOP, stopLocation);
|
|
|
|
sendIntent(DownloadManager.ACTION_STOP, stopLocation); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onCancel() { |
|
|
|
@Override public void onCancel() { |
|
|
|
super.onCancel(); |
|
|
|
super.onCancel(); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_CANCEL); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_CANCEL); |
|
|
|
sendInState2Target(DownloadSchedulers.CANCEL); |
|
|
|
sendInState2Target(DownloadSchedulers.CANCEL); |
|
|
|
//sendIntent(DownloadManager.ACTION_CANCEL, -1);
|
|
|
|
sendIntent(DownloadManager.ACTION_CANCEL, -1); |
|
|
|
downloadEntity.deleteData(); |
|
|
|
downloadEntity.deleteData(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -285,15 +286,16 @@ public class Task { |
|
|
|
downloadEntity.setDownloadComplete(true); |
|
|
|
downloadEntity.setDownloadComplete(true); |
|
|
|
downloadEntity.setSpeed(0); |
|
|
|
downloadEntity.setSpeed(0); |
|
|
|
sendInState2Target(DownloadSchedulers.COMPLETE); |
|
|
|
sendInState2Target(DownloadSchedulers.COMPLETE); |
|
|
|
//sendIntent(DownloadManager.ACTION_COMPLETE, downloadEntity.getFileSize());
|
|
|
|
sendIntent(DownloadManager.ACTION_COMPLETE, downloadEntity.getFileSize()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onFail() { |
|
|
|
@Override public void onFail() { |
|
|
|
super.onFail(); |
|
|
|
super.onFail(); |
|
|
|
|
|
|
|
downloadEntity.setFailNum(downloadEntity.getFailNum() + 1); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_FAIL); |
|
|
|
downloadEntity.setState(DownloadEntity.STATE_FAIL); |
|
|
|
downloadEntity.setSpeed(0); |
|
|
|
downloadEntity.setSpeed(0); |
|
|
|
sendInState2Target(DownloadSchedulers.FAIL); |
|
|
|
sendInState2Target(DownloadSchedulers.FAIL); |
|
|
|
//sendIntent(DownloadManager.ACTION_FAIL, -1);
|
|
|
|
sendIntent(DownloadManager.ACTION_FAIL, -1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void sendIntent(String action, long location) { |
|
|
|
private void sendIntent(String action, long location) { |
|
|
@ -305,7 +307,7 @@ public class Task { |
|
|
|
if (location != -1) { |
|
|
|
if (location != -1) { |
|
|
|
intent.putExtra(DownloadManager.CURRENT_LOCATION, location); |
|
|
|
intent.putExtra(DownloadManager.CURRENT_LOCATION, location); |
|
|
|
} |
|
|
|
} |
|
|
|
context.sendBroadcast(intent); |
|
|
|
//context.sendBroadcast(intent);
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |