Fixed download size for File and FTP download
This commit is contained in:
parent
79e336c1cc
commit
1c985b8c2d
1 changed files with 4 additions and 2 deletions
|
|
@ -22,6 +22,7 @@ public class UeBehaviourFileDownload extends UeBehaviour {
|
|||
@Configurable("File address")
|
||||
private String url = "http://speedtest.ftp.otenet.gr/files/test1Mb.db";
|
||||
|
||||
private transient long estimatedDataLength = -1;
|
||||
|
||||
@Override
|
||||
protected void execute() throws IOException {
|
||||
|
|
@ -34,15 +35,16 @@ public class UeBehaviourFileDownload extends UeBehaviour {
|
|||
connection.connect();
|
||||
InputStream in = connection.getInputStream();
|
||||
|
||||
long total = in.available();
|
||||
long progress = 0;
|
||||
long read = 0;
|
||||
|
||||
while((read = in.read(data)) != -1 && !stopExecution()){
|
||||
progress += read;
|
||||
super.setProgress((float)progress/total);
|
||||
super.setProgress((float)progress/estimatedDataLength);
|
||||
super.setHandledIncomingData(read);
|
||||
}
|
||||
|
||||
estimatedDataLength = progress;
|
||||
in.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue