Change task mode to immunate.
This commit is contained in:
parent
656e5ccdea
commit
2e14835bd9
|
@ -53,8 +53,10 @@ class AutoDownloader {
|
||||||
|
|
||||||
for (var episodeTask in _episodeTasks) {
|
for (var episodeTask in _episodeTasks) {
|
||||||
if (episodeTask.taskId == id) {
|
if (episodeTask.taskId == id) {
|
||||||
episodeTask.status = status;
|
// episodeTask.status = status;
|
||||||
episodeTask.progress = progress;
|
// episodeTask.progress = progress;
|
||||||
|
episodeTask =
|
||||||
|
episodeTask.copyWith(progress: progress, status: status);
|
||||||
if (status == DownloadTaskStatus.complete) {
|
if (status == DownloadTaskStatus.complete) {
|
||||||
_saveMediaId(episodeTask);
|
_saveMediaId(episodeTask);
|
||||||
} else if (status == DownloadTaskStatus.failed) {
|
} else if (status == DownloadTaskStatus.failed) {
|
||||||
|
@ -213,8 +215,10 @@ class DownloadState extends ChangeNotifier {
|
||||||
|
|
||||||
for (var episodeTask in _episodeTasks) {
|
for (var episodeTask in _episodeTasks) {
|
||||||
if (episodeTask.taskId == id) {
|
if (episodeTask.taskId == id) {
|
||||||
episodeTask.status = status;
|
//episodeTask.status = status;
|
||||||
episodeTask.progress = progress;
|
//episodeTask.progress = progress;
|
||||||
|
episodeTask =
|
||||||
|
episodeTask.copyWith(progress: progress, status: status);
|
||||||
if (status == DownloadTaskStatus.complete) {
|
if (status == DownloadTaskStatus.complete) {
|
||||||
_saveMediaId(episodeTask).then((value) {
|
_saveMediaId(episodeTask).then((value) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
@ -228,7 +232,7 @@ class DownloadState extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _saveMediaId(EpisodeTask episodeTask) async {
|
Future _saveMediaId(EpisodeTask episodeTask) async {
|
||||||
episodeTask.status = DownloadTaskStatus.complete;
|
episodeTask = episodeTask.copyWith(status: DownloadTaskStatus.complete);
|
||||||
final completeTask = await FlutterDownloader.loadTasksWithRawQuery(
|
final completeTask = await FlutterDownloader.loadTasksWithRawQuery(
|
||||||
query: "SELECT * FROM task WHERE task_id = '${episodeTask.taskId}'");
|
query: "SELECT * FROM task WHERE task_id = '${episodeTask.taskId}'");
|
||||||
var filePath =
|
var filePath =
|
||||||
|
@ -343,7 +347,8 @@ class DownloadState extends ChangeNotifier {
|
||||||
|
|
||||||
for (var episodeTask in _episodeTasks) {
|
for (var episodeTask in _episodeTasks) {
|
||||||
if (episodeTask.taskId == task.taskId) {
|
if (episodeTask.taskId == task.taskId) {
|
||||||
episodeTask.status = DownloadTaskStatus.undefined;
|
//episodeTask.status = DownloadTaskStatus.undefined;
|
||||||
|
episodeTask = episodeTask.copyWith(status: DownloadTaskStatus.undefined);
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ import 'episodebrief.dart';
|
||||||
class EpisodeTask extends Equatable {
|
class EpisodeTask extends Equatable {
|
||||||
final String taskId;
|
final String taskId;
|
||||||
final EpisodeBrief episode;
|
final EpisodeBrief episode;
|
||||||
int progress;
|
final int progress;
|
||||||
DownloadTaskStatus status;
|
final DownloadTaskStatus status;
|
||||||
EpisodeTask(
|
EpisodeTask(
|
||||||
this.episode,
|
this.episode,
|
||||||
this.taskId, {
|
this.taskId, {
|
||||||
|
@ -15,9 +15,9 @@ class EpisodeTask extends Equatable {
|
||||||
this.status = DownloadTaskStatus.undefined,
|
this.status = DownloadTaskStatus.undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
EpisodeTask copyWith({String taskId}) {
|
EpisodeTask copyWith({String taskId, int progress, DownloadTaskStatus status}) {
|
||||||
return EpisodeTask(episode, taskId ?? this.taskId,
|
return EpisodeTask(episode, taskId ?? this.taskId,
|
||||||
progress: progress, status: status);
|
progress: progress ?? this.progress, status: status ?? this.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
Loading…
Reference in New Issue