mirror of
https://github.com/stonega/tsacdop
synced 2025-02-08 07:38:47 +01:00
FIx bug, podcast image save wrong name.
This commit is contained in:
parent
1ea63a8ba5
commit
d10a12678c
@ -110,7 +110,8 @@ class _PodcastSettingState extends State<PodcastSetting> {
|
|||||||
connectTimeout: 30000,
|
connectTimeout: 30000,
|
||||||
receiveTimeout: 90000,
|
receiveTimeout: 90000,
|
||||||
);
|
);
|
||||||
|
var dir = await getApplicationDocumentsDirectory();
|
||||||
|
var filePath = "${dir.path}/${widget.podcastLocal.id}.png";
|
||||||
var dio = Dio(options);
|
var dio = Dio(options);
|
||||||
String imageUrl;
|
String imageUrl;
|
||||||
|
|
||||||
@ -127,10 +128,7 @@ class _PodcastSettingState extends State<PodcastSetting> {
|
|||||||
developer.log(e.toString());
|
developer.log(e.toString());
|
||||||
if (mounted) setState(() => _coverStatus = RefreshCoverStatus.error);
|
if (mounted) setState(() => _coverStatus = RefreshCoverStatus.error);
|
||||||
}
|
}
|
||||||
if (imageUrl != null &&
|
if (imageUrl != null && imageUrl.contains('http')) {
|
||||||
imageUrl.contains('http') &&
|
|
||||||
(imageUrl != widget.podcastLocal.imageUrl ||
|
|
||||||
!File(widget.podcastLocal.imageUrl).existsSync())) {
|
|
||||||
try {
|
try {
|
||||||
img.Image thumbnail;
|
img.Image thumbnail;
|
||||||
var imageResponse = await dio.get<List<int>>(imageUrl,
|
var imageResponse = await dio.get<List<int>>(imageUrl,
|
||||||
@ -140,9 +138,10 @@ class _PodcastSettingState extends State<PodcastSetting> {
|
|||||||
var image = img.decodeImage(imageResponse.data);
|
var image = img.decodeImage(imageResponse.data);
|
||||||
thumbnail = img.copyResize(image, width: 300);
|
thumbnail = img.copyResize(image, width: 300);
|
||||||
if (thumbnail != null) {
|
if (thumbnail != null) {
|
||||||
var dir = await getApplicationDocumentsDirectory();
|
File(filePath)..writeAsBytesSync(img.encodePng(thumbnail));
|
||||||
File("${dir.path}/${widget.podcastLocal.id}.png")
|
_dbHelper.updatePodcastImage(
|
||||||
..writeAsBytesSync(img.encodePng(thumbnail));
|
id: widget.podcastLocal.id, filePath: filePath);
|
||||||
|
print('saved image');
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() => _coverStatus = RefreshCoverStatus.complete);
|
setState(() => _coverStatus = RefreshCoverStatus.complete);
|
||||||
}
|
}
|
||||||
@ -325,9 +324,7 @@ class _PodcastSettingState extends State<PodcastSetting> {
|
|||||||
height: 18,
|
height: 18,
|
||||||
width: 18,
|
width: 18,
|
||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
painter: ListenedAllPainter(
|
painter: ListenedAllPainter(context.accentColor, stroke: 2),
|
||||||
context.accentColor,
|
|
||||||
stroke: 2),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 20),
|
SizedBox(width: 20),
|
||||||
|
@ -656,13 +656,8 @@ Future<void> subIsolateEntryPoint(SendPort sendPort) async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var uuid = Uuid().v4();
|
var uuid = Uuid().v4();
|
||||||
var imagePath = path.join(dir.path, 'uuid.png');
|
File("${dir.path}/$uuid.png")..writeAsBytesSync(img.encodePng(thumbnail));
|
||||||
try {
|
var imagePath = "${dir.path}/$uuid.png";
|
||||||
File(imagePath).writeAsBytesSync(img.encodePng(thumbnail));
|
|
||||||
} catch (e) {
|
|
||||||
print(e);
|
|
||||||
}
|
|
||||||
//var imagePath = "${dir.path}/$uuid.png";
|
|
||||||
var primaryColor = await _getColor(File(imagePath));
|
var primaryColor = await _getColor(File(imagePath));
|
||||||
var author = p.itunes.author ?? p.author ?? '';
|
var author = p.itunes.author ?? p.author ?? '';
|
||||||
var provider = p.generator ?? '';
|
var provider = p.generator ?? '';
|
||||||
@ -675,7 +670,9 @@ Future<void> subIsolateEntryPoint(SendPort sendPort) async {
|
|||||||
description: p.description);
|
description: p.description);
|
||||||
|
|
||||||
await dbHelper.savePodcastLocal(podcastLocal);
|
await dbHelper.savePodcastLocal(podcastLocal);
|
||||||
|
|
||||||
sendPort.send([item.title, item.url, 2, uuid, item.group]);
|
sendPort.send([item.title, item.url, 2, uuid, item.group]);
|
||||||
|
|
||||||
if (provider.contains('fireside')) {
|
if (provider.contains('fireside')) {
|
||||||
var data = FiresideData(uuid, link);
|
var data = FiresideData(uuid, link);
|
||||||
try {
|
try {
|
||||||
@ -686,13 +683,6 @@ Future<void> subIsolateEntryPoint(SendPort sendPort) async {
|
|||||||
}
|
}
|
||||||
await dbHelper.savePodcastRss(p, uuid);
|
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]);
|
sendPort.send([item.title, item.url, 3, uuid]);
|
||||||
|
|
||||||
await Future.delayed(Duration(seconds: 2));
|
await Future.delayed(Duration(seconds: 2));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user