- Timestamp:
- Jan 13, 2013, 8:11:07 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/backend/mods/download
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/backend/mods/download/ModDownload.java
r604 r605 96 96 */ 97 97 public void start() { 98 state = ModDownloadState.RUNNING; 98 99 downloader.start(); 99 100 } -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/download/ModDownloader.java
r604 r605 67 67 currentDownload++; 68 68 downloadedCurrent = 0; 69 if ( currentDownload < downloads.size()) {69 if ((state == State.RUNNING) && (currentDownload < downloads.size())) { 70 70 downloads.get(currentDownload).start(); 71 71 } else { … … 74 74 } 75 75 76 /** 77 * @return Average download speed for up to now in B/s 78 */ 79 public int getDownloadSpeed() { 80 long duration = new Date().getTime() - startMS; 81 int down = downloadedComplete + downloadedCurrent; 82 return (int) (down * 1000 / duration); 76 private int getTimeElapsed() { 77 int total = (int) (new Date().getTime() - startMS) 78 / 1000; 79 return total; 83 80 } 84 81 85 /** 86 * @return Remaining time for all downloads by avg-speed in seconds 87 */ 88 public int getTimeRemaining() { 82 private int getDownloadSpeed() { 83 int elap = getTimeElapsed(); 84 int down = downloadedComplete + downloadedCurrent; 85 if (elap > 0) 86 return down / elap; 87 else 88 return 1; 89 } 90 91 private int getTimeRemaining() { 89 92 int remainingSize = totalSize 90 93 - (downloadedComplete + downloadedCurrent); … … 94 97 private void notifyListener() { 95 98 listener.updateStatus(this, state, unpacked, downloads.size(), 96 downloadedComplete + downloadedCurrent, totalSize); 99 downloadedComplete + downloadedCurrent, totalSize, 100 getTimeElapsed(), getTimeRemaining(), getDownloadSpeed()); 101 } 102 103 /** 104 * @return total download size 105 */ 106 public int getTotalSize() { 107 return totalSize; 97 108 } 98 109 … … 133 144 } 134 145 146 /** 147 * Abort download process 148 */ 149 public void abort() { 150 if (currentDownload < downloads.size()) { 151 state = State.INTERRUPTED; 152 ModDownload md = downloads.get(currentDownload); 153 md.abort(); 154 } 155 } 156 135 157 } -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/download/ModDownloaderListener.java
r604 r605 22 22 * @param bytesTotal 23 23 * Bytes in total to handle 24 * @param duration 25 * Duration of downloads in seconds 26 * @param remaining 27 * Remaining time in seconds 28 * @param speed 29 * Average download speed in B/s 24 30 */ 25 31 public void updateStatus(ModDownloader source, State state, int filesDown, 26 int filesTotal, int bytesDown, int bytesTotal); 32 int filesTotal, int bytesDown, int bytesTotal, int duration, 33 int remaining, int speed); 27 34 }
Note:
See TracChangeset
for help on using the changeset viewer.