From 5a533d951b6ba5dbc23b90475f60e84af1bed7c8 Mon Sep 17 00:00:00 2001 From: stonegate Date: Wed, 19 Aug 2020 18:10:08 +0800 Subject: [PATCH] Minor change. --- lib/home/playlist.dart | 2 ++ lib/podcasts/podcast_detail.dart | 2 +- lib/podcasts/podcast_settings.dart | 32 +++++++++++++++--------------- lib/state/podcast_group.dart | 4 ++-- pubspec.yaml | 2 +- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/lib/home/playlist.dart b/lib/home/playlist.dart index 4ac4b1e..a12745d 100644 --- a/lib/home/playlist.dart +++ b/lib/home/playlist.dart @@ -366,6 +366,7 @@ class __DismissibleContainerState extends State<_DismissibleContainer> { final c = widget.episode.backgroudColor(context); return AnimatedContainer( duration: Duration(milliseconds: 300), + curve: Curves.easeInSine, alignment: Alignment.center, height: _delete ? 0 : 90.0, child: _delete @@ -413,6 +414,7 @@ class __DismissibleContainerState extends State<_DismissibleContainer> { var index = await audio.delFromPlaylist(widget.episode); widget.onRemove(true); final episodeRemove = widget.episode; + Scaffold.of(context).removeCurrentSnackBar(); Scaffold.of(context).showSnackBar(SnackBar( behavior: SnackBarBehavior.floating, backgroundColor: Colors.grey[800], diff --git a/lib/podcasts/podcast_detail.dart b/lib/podcasts/podcast_detail.dart index fc96d23..e9feb1e 100644 --- a/lib/podcasts/podcast_detail.dart +++ b/lib/podcasts/podcast_detail.dart @@ -336,7 +336,7 @@ class _PodcastDetailState extends State { context, title: s.settings, child: PodcastSetting(podcastLocal: widget.podcastLocal), - ); + ).then((value) => setState(() {})); break; } }, diff --git a/lib/podcasts/podcast_settings.dart b/lib/podcasts/podcast_settings.dart index a39a33c..22faf46 100644 --- a/lib/podcasts/podcast_settings.dart +++ b/lib/podcasts/podcast_settings.dart @@ -96,17 +96,18 @@ class _PodcastSettingState extends State { Future _refreshArtWork() async { setState(() => _coverStatus = RefreshCoverStatus.start); var options = BaseOptions( - connectTimeout: 20000, - receiveTimeout: 20000, + connectTimeout: 30000, + receiveTimeout: 90000, ); + + var dio = Dio(options); String imageUrl; try { - var response = await Dio(options).get(widget.podcastLocal.rssUrl); + var response = await dio.get(widget.podcastLocal.rssUrl); try { - RssFeed p; - p = RssFeed.parse(response.data); - imageUrl == p.itunes.image.href; + var p = RssFeed.parse(response.data); + imageUrl = p.itunes.image.href ?? p.image.url; } catch (e) { developer.log(e.toString()); if (mounted) setState(() => _coverStatus = RefreshCoverStatus.error); @@ -121,10 +122,9 @@ class _PodcastSettingState extends State { !File(widget.podcastLocal.imageUrl).existsSync())) { try { img.Image thumbnail; - var imageResponse = await Dio().get>(imageUrl, + var imageResponse = await dio.get>(imageUrl, options: Options( responseType: ResponseType.bytes, - receiveTimeout: 90000, )); var image = img.decodeImage(imageResponse.data); thumbnail = img.copyResize(image, width: 300); @@ -137,10 +137,10 @@ class _PodcastSettingState extends State { } } } catch (e) { + developer.log(e.toString()); if (mounted) setState(() => _coverStatus = RefreshCoverStatus.error); } - } - if (mounted) { + } else if (_coverStatus == RefreshCoverStatus.start && mounted) { setState(() => _coverStatus = RefreshCoverStatus.complete); } } @@ -181,7 +181,7 @@ class _PodcastSettingState extends State { case RefreshCoverStatus.complete: return Icon(Icons.done); break; - case RefreshCoverStatus.complete: + case RefreshCoverStatus.error: return Icon(Icons.refresh, color: Colors.red); break; default: @@ -307,11 +307,11 @@ class _PodcastSettingState extends State { }, title: Text(s.refreshArtwork), leading: Icon(Icons.refresh), - trailing: SizedBox( - height: 20, - width: 20, - child: Padding( - padding: const EdgeInsets.only(right: 10.0), + trailing: Padding( + padding: const EdgeInsets.only(right: 15.0), + child: SizedBox( + height: 20, + width: 20, child: _getRefreshStatusIcon(_coverStatus)))), Divider(height: 1), ]); diff --git a/lib/state/podcast_group.dart b/lib/state/podcast_group.dart index ab462a4..b78dadc 100644 --- a/lib/state/podcast_group.dart +++ b/lib/state/podcast_group.dart @@ -462,8 +462,8 @@ Future subIsolateEntryPoint(SendPort sendPort) async { var rss = item.url; sendPort.send([item.title, item.url, 1]); var options = BaseOptions( - connectTimeout: 20000, - receiveTimeout: 20000, + connectTimeout: 30000, + receiveTimeout: 90000, ); try { diff --git a/pubspec.yaml b/pubspec.yaml index eb64322..e4f9c5c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: color_thief_flutter: ^1.0.2 cupertino_icons: ^0.1.3 connectivity: ^0.4.9 - dio: ^3.0.9 + dio: ^3.0.10 extended_nested_scroll_view: ^1.0.1 effective_dart: ^1.2.4 equatable: ^1.2.3