diff --git a/lib/podcasts/podcast_settings.dart b/lib/podcasts/podcast_settings.dart index b58fcb4..c300dd6 100644 --- a/lib/podcasts/podcast_settings.dart +++ b/lib/podcasts/podcast_settings.dart @@ -110,7 +110,8 @@ class _PodcastSettingState extends State { connectTimeout: 30000, receiveTimeout: 90000, ); - + var dir = await getApplicationDocumentsDirectory(); + var filePath = "${dir.path}/${widget.podcastLocal.id}.png"; var dio = Dio(options); String imageUrl; @@ -127,10 +128,7 @@ class _PodcastSettingState extends State { developer.log(e.toString()); if (mounted) setState(() => _coverStatus = RefreshCoverStatus.error); } - if (imageUrl != null && - imageUrl.contains('http') && - (imageUrl != widget.podcastLocal.imageUrl || - !File(widget.podcastLocal.imageUrl).existsSync())) { + if (imageUrl != null && imageUrl.contains('http')) { try { img.Image thumbnail; var imageResponse = await dio.get>(imageUrl, @@ -140,9 +138,10 @@ class _PodcastSettingState extends State { var image = img.decodeImage(imageResponse.data); thumbnail = img.copyResize(image, width: 300); if (thumbnail != null) { - var dir = await getApplicationDocumentsDirectory(); - File("${dir.path}/${widget.podcastLocal.id}.png") - ..writeAsBytesSync(img.encodePng(thumbnail)); + File(filePath)..writeAsBytesSync(img.encodePng(thumbnail)); + _dbHelper.updatePodcastImage( + id: widget.podcastLocal.id, filePath: filePath); + print('saved image'); if (mounted) { setState(() => _coverStatus = RefreshCoverStatus.complete); } @@ -325,9 +324,7 @@ class _PodcastSettingState extends State { height: 18, width: 18, child: CustomPaint( - painter: ListenedAllPainter( - context.accentColor, - stroke: 2), + painter: ListenedAllPainter(context.accentColor, stroke: 2), ), ), SizedBox(width: 20), diff --git a/lib/state/podcast_group.dart b/lib/state/podcast_group.dart index e1d85d6..d372abc 100644 --- a/lib/state/podcast_group.dart +++ b/lib/state/podcast_group.dart @@ -656,13 +656,8 @@ Future subIsolateEntryPoint(SendPort sendPort) async { } } var uuid = Uuid().v4(); - var imagePath = path.join(dir.path, 'uuid.png'); - try { - File(imagePath).writeAsBytesSync(img.encodePng(thumbnail)); - } catch (e) { - print(e); - } - //var imagePath = "${dir.path}/$uuid.png"; + File("${dir.path}/$uuid.png")..writeAsBytesSync(img.encodePng(thumbnail)); + var imagePath = "${dir.path}/$uuid.png"; var primaryColor = await _getColor(File(imagePath)); var author = p.itunes.author ?? p.author ?? ''; var provider = p.generator ?? ''; @@ -675,7 +670,9 @@ Future subIsolateEntryPoint(SendPort sendPort) async { description: p.description); await dbHelper.savePodcastLocal(podcastLocal); + sendPort.send([item.title, item.url, 2, uuid, item.group]); + if (provider.contains('fireside')) { var data = FiresideData(uuid, link); try { @@ -686,13 +683,6 @@ Future subIsolateEntryPoint(SendPort sendPort) async { } await dbHelper.savePodcastRss(p, uuid); - // if (item.syncWithGpodder) { - // final gpodder = Gpodder(); - // await gpodder.updateChange({ - // 'add': [item.url] - // }); - // } - sendPort.send([item.title, item.url, 3, uuid]); await Future.delayed(Duration(seconds: 2));