-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Download Progress Manager | Remote Download JRE
- Loading branch information
Showing
15 changed files
with
183 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1730783037751 | ||
1730879022018 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package pojlib.util.download; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import pojlib.API; | ||
|
||
public class DownloadManager { | ||
private final Map<String, Double> downloadProgress = new ConcurrentHashMap<>(); | ||
private final int totalFiles; | ||
private final AtomicInteger completedFiles = new AtomicInteger(0); | ||
|
||
public DownloadManager(int totalFiles) { | ||
this.totalFiles = totalFiles; | ||
} | ||
|
||
public void updateProgress(String fileName, double progress) { | ||
downloadProgress.put(fileName, progress); | ||
API.currentDownload = fileName; | ||
getOverallProgress(); | ||
} | ||
|
||
public void fileDownloadComplete(String fileName) { | ||
completedFiles.incrementAndGet(); | ||
downloadProgress.remove(fileName); | ||
getOverallProgress(); | ||
} | ||
|
||
private void getOverallProgress() { | ||
int completed = completedFiles.get(); | ||
double overallProgress = ((double) completed / totalFiles) * 100; | ||
if (completed == totalFiles) {API.currentDownload = "Finished! Ready to start.";} | ||
API.downloadStatus = overallProgress; | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.