|
|
@ -47,7 +47,7 @@ public class DownloadGroupListener |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSubPre(DownloadEntity subEntity) { |
|
|
|
public void onSubPre(DownloadEntity subEntity) { |
|
|
|
handleSpeed(subEntity, 0); |
|
|
|
handleSubSpeed(subEntity, 0); |
|
|
|
saveSubState(IEntity.STATE_PRE, subEntity); |
|
|
|
saveSubState(IEntity.STATE_PRE, subEntity); |
|
|
|
sendInState2Target(ISchedulers.SUB_PRE, subEntity); |
|
|
|
sendInState2Target(ISchedulers.SUB_PRE, subEntity); |
|
|
|
} |
|
|
|
} |
|
|
@ -59,7 +59,7 @@ public class DownloadGroupListener |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSubStart(DownloadEntity subEntity) { |
|
|
|
public void onSubStart(DownloadEntity subEntity) { |
|
|
|
handleSpeed(subEntity, 0); |
|
|
|
handleSubSpeed(subEntity, 0); |
|
|
|
saveSubState(IEntity.STATE_RUNNING, subEntity); |
|
|
|
saveSubState(IEntity.STATE_RUNNING, subEntity); |
|
|
|
sendInState2Target(ISchedulers.SUB_START, subEntity); |
|
|
|
sendInState2Target(ISchedulers.SUB_START, subEntity); |
|
|
|
} |
|
|
|
} |
|
|
@ -67,7 +67,7 @@ public class DownloadGroupListener |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSubStop(DownloadEntity subEntity, long stopLocation) { |
|
|
|
public void onSubStop(DownloadEntity subEntity, long stopLocation) { |
|
|
|
subEntity.setCurrentProgress(stopLocation); |
|
|
|
subEntity.setCurrentProgress(stopLocation); |
|
|
|
handleSpeed(subEntity, 0); |
|
|
|
handleSubSpeed(subEntity, 0); |
|
|
|
saveSubState(IEntity.STATE_STOP, subEntity); |
|
|
|
saveSubState(IEntity.STATE_STOP, subEntity); |
|
|
|
saveCurrentLocation(); |
|
|
|
saveCurrentLocation(); |
|
|
|
sendInState2Target(ISchedulers.SUB_STOP, subEntity); |
|
|
|
sendInState2Target(ISchedulers.SUB_STOP, subEntity); |
|
|
@ -75,7 +75,7 @@ public class DownloadGroupListener |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSubComplete(DownloadEntity subEntity) { |
|
|
|
public void onSubComplete(DownloadEntity subEntity) { |
|
|
|
handleSpeed(subEntity, 0); |
|
|
|
handleSubSpeed(subEntity, 0); |
|
|
|
saveSubState(IEntity.STATE_COMPLETE, subEntity); |
|
|
|
saveSubState(IEntity.STATE_COMPLETE, subEntity); |
|
|
|
saveCurrentLocation(); |
|
|
|
saveCurrentLocation(); |
|
|
|
sendInState2Target(ISchedulers.SUB_COMPLETE, subEntity); |
|
|
|
sendInState2Target(ISchedulers.SUB_COMPLETE, subEntity); |
|
|
@ -83,7 +83,7 @@ public class DownloadGroupListener |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSubFail(DownloadEntity subEntity, BaseException e) { |
|
|
|
public void onSubFail(DownloadEntity subEntity, BaseException e) { |
|
|
|
handleSpeed(subEntity, 0); |
|
|
|
handleSubSpeed(subEntity, 0); |
|
|
|
saveSubState(IEntity.STATE_FAIL, subEntity); |
|
|
|
saveSubState(IEntity.STATE_FAIL, subEntity); |
|
|
|
saveCurrentLocation(); |
|
|
|
saveCurrentLocation(); |
|
|
|
sendInState2Target(ISchedulers.SUB_FAIL, subEntity); |
|
|
|
sendInState2Target(ISchedulers.SUB_FAIL, subEntity); |
|
|
@ -95,7 +95,7 @@ public class DownloadGroupListener |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSubCancel(DownloadEntity subEntity) { |
|
|
|
public void onSubCancel(DownloadEntity subEntity) { |
|
|
|
handleSpeed(subEntity, 0); |
|
|
|
handleSubSpeed(subEntity, 0); |
|
|
|
saveSubState(IEntity.STATE_CANCEL, subEntity); |
|
|
|
saveSubState(IEntity.STATE_CANCEL, subEntity); |
|
|
|
saveCurrentLocation(); |
|
|
|
saveCurrentLocation(); |
|
|
|
sendInState2Target(ISchedulers.SUB_CANCEL, subEntity); |
|
|
|
sendInState2Target(ISchedulers.SUB_CANCEL, subEntity); |
|
|
@ -104,7 +104,7 @@ public class DownloadGroupListener |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSubRunning(DownloadEntity subEntity, long currentProgress) { |
|
|
|
public void onSubRunning(DownloadEntity subEntity, long currentProgress) { |
|
|
|
|
|
|
|
|
|
|
|
handleSpeed(subEntity, currentProgress); |
|
|
|
handleSubSpeed(subEntity, currentProgress); |
|
|
|
if (System.currentTimeMillis() - mLastSaveTime >= RUN_SAVE_INTERVAL) { |
|
|
|
if (System.currentTimeMillis() - mLastSaveTime >= RUN_SAVE_INTERVAL) { |
|
|
|
saveSubState(IEntity.STATE_RUNNING, subEntity); |
|
|
|
saveSubState(IEntity.STATE_RUNNING, subEntity); |
|
|
|
mLastSaveTime = System.currentTimeMillis(); |
|
|
|
mLastSaveTime = System.currentTimeMillis(); |
|
|
@ -112,7 +112,7 @@ public class DownloadGroupListener |
|
|
|
sendInState2Target(ISchedulers.SUB_RUNNING, subEntity); |
|
|
|
sendInState2Target(ISchedulers.SUB_RUNNING, subEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void handleSpeed(DownloadEntity subEntity, long currentProgress) { |
|
|
|
private void handleSubSpeed(DownloadEntity subEntity, long currentProgress) { |
|
|
|
if (currentProgress == 0){ |
|
|
|
if (currentProgress == 0){ |
|
|
|
subEntity.setSpeed(0); |
|
|
|
subEntity.setSpeed(0); |
|
|
|
subEntity.setConvertSpeed("0kb/s"); |
|
|
|
subEntity.setConvertSpeed("0kb/s"); |
|
|
|