pause and delete all

This commit is contained in:
wgh19
2024-05-17 10:00:36 +08:00
parent 38f57584b6
commit 4b8acfc3ff
3 changed files with 62 additions and 3 deletions

View File

@@ -163,6 +163,10 @@ class DownloadingTask {
_stop = false;
_download();
}
void pause() {
_stop = true;
}
}
class DownloadManager {
@@ -276,8 +280,20 @@ class DownloadManager {
int get maxConcurrentTasks => appdata.settings["maxParallels"];
bool _paused = false;
bool get paused => _paused;
void pause() {
_paused = true;
for(var task in tasks) {
task.pause();
}
}
void run() {
_loop ??= Timer.periodic(const Duration(seconds: 1), (timer) {
if(_paused) return;
_bytesPerSecond = _currentBytes;
_currentBytes = 0;
uiUpdateCallback?.call();
@@ -349,4 +365,8 @@ class DownloadManager {
i++;
}
}
void resume() {
_paused = false;
}
}