Bug fix, refresh page after podcast update.
This commit is contained in:
parent
ffead02039
commit
e97752bea5
|
@ -31,7 +31,7 @@ import 'audioplayer.dart';
|
|||
import 'download_list.dart';
|
||||
import 'home_groups.dart';
|
||||
import 'home_menu.dart';
|
||||
import 'import_ompl.dart';
|
||||
import 'import_opml.dart';
|
||||
import 'playlist.dart';
|
||||
import 'search_podcast.dart';
|
||||
|
||||
|
@ -452,27 +452,27 @@ class __PlaylistButtonState extends State<_PlaylistButton> {
|
|||
),
|
||||
),
|
||||
),
|
||||
PopupMenuDivider(
|
||||
height: 1,
|
||||
),
|
||||
// PopupMenuItem(
|
||||
// value: 2,
|
||||
// child: Container(
|
||||
// padding: EdgeInsets.only(left: 10),
|
||||
// child: Row(
|
||||
// children: <Widget>[
|
||||
// Icon(Icons.history),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 5.0),
|
||||
// ),
|
||||
// Text(s.settingsHistory),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// PopupMenuDivider(
|
||||
// height: 1,
|
||||
// ),
|
||||
//PopupMenuDivider(
|
||||
// height: 1,
|
||||
//),
|
||||
// PopupMenuItem(
|
||||
// value: 2,
|
||||
// child: Container(
|
||||
// padding: EdgeInsets.only(left: 10),
|
||||
// child: Row(
|
||||
// children: <Widget>[
|
||||
// Icon(Icons.history),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 5.0),
|
||||
// ),
|
||||
// Text(s.settingsHistory),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// PopupMenuDivider(
|
||||
// height: 1,
|
||||
// ),
|
||||
],
|
||||
onSelected: (value) {
|
||||
if (value == 0) {
|
||||
|
@ -723,193 +723,187 @@ class _RecentUpdateState extends State<_RecentUpdate>
|
|||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
final s = context.s;
|
||||
return Selector<RefreshWorker, bool>(
|
||||
selector: (_, worker) => worker.complete,
|
||||
builder: (_, complete, __) => Selector<GroupList, bool>(
|
||||
selector: (_, worker) => worker.created,
|
||||
builder: (context, created, child) {
|
||||
return FutureBuilder<List<EpisodeBrief>>(
|
||||
future: _getRssItem(_top, _group, hideListened: _hideListened),
|
||||
builder: (context, snapshot) {
|
||||
return (snapshot.hasData)
|
||||
? snapshot.data.length == 0
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(top: 150),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Icon(LineIcons.cloud_download_alt_solid,
|
||||
size: 80, color: Colors.grey[500]),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsets.symmetric(vertical: 10)),
|
||||
Text(
|
||||
s.noEpisodeRecent,
|
||||
style: TextStyle(color: Colors.grey[500]),
|
||||
)
|
||||
],
|
||||
return Selector2<RefreshWorker, GroupList, Tuple2<bool, bool>>(
|
||||
selector: (_, refreshWorkder, groupWorker) =>
|
||||
Tuple2(refreshWorkder.created, groupWorker.created),
|
||||
builder: (_, data, __) {
|
||||
print('${data.item1}Refresh completed');
|
||||
return FutureBuilder<List<EpisodeBrief>>(
|
||||
future: _getRssItem(_top, _group, hideListened: _hideListened),
|
||||
builder: (context, snapshot) {
|
||||
return (snapshot.hasData)
|
||||
? snapshot.data.length == 0
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(top: 150),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Icon(LineIcons.cloud_download_alt_solid,
|
||||
size: 80, color: Colors.grey[500]),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10)),
|
||||
Text(
|
||||
s.noEpisodeRecent,
|
||||
style: TextStyle(color: Colors.grey[500]),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
: NotificationListener<ScrollNotification>(
|
||||
onNotification: (scrollInfo) {
|
||||
if (scrollInfo is ScrollStartNotification &&
|
||||
mounted &&
|
||||
!_scroll) {
|
||||
setState(() => _scroll = true);
|
||||
}
|
||||
if (scrollInfo.metrics.pixels ==
|
||||
scrollInfo.metrics.maxScrollExtent &&
|
||||
snapshot.data.length == _top) {
|
||||
if (!_loadMore) {
|
||||
_loadMoreEpisode();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
ScrollConfiguration(
|
||||
behavior: NoGrowBehavior(),
|
||||
child: CustomScrollView(
|
||||
key: PageStorageKey<String>('update'),
|
||||
physics:
|
||||
const AlwaysScrollableScrollPhysics(),
|
||||
slivers: <Widget>[
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
),
|
||||
EpisodeGrid(
|
||||
episodes: snapshot.data,
|
||||
layout: _layout,
|
||||
initNum: _scroll ? 0 : 12,
|
||||
multiSelect: _multiSelect,
|
||||
openPodcast: true,
|
||||
selectedList: _selectedEpisodes ?? [],
|
||||
onSelect: (value) => setState(() {
|
||||
_selectedEpisodes = value;
|
||||
}),
|
||||
),
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return _loadMore
|
||||
? Container(
|
||||
height: 2,
|
||||
child:
|
||||
LinearProgressIndicator())
|
||||
: Center();
|
||||
},
|
||||
childCount: 1,
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
)
|
||||
: NotificationListener<ScrollNotification>(
|
||||
onNotification: (scrollInfo) {
|
||||
if (scrollInfo is ScrollStartNotification &&
|
||||
mounted &&
|
||||
!_scroll) {
|
||||
setState(() => _scroll = true);
|
||||
}
|
||||
if (scrollInfo.metrics.pixels ==
|
||||
scrollInfo.metrics.maxScrollExtent &&
|
||||
snapshot.data.length == _top) {
|
||||
if (!_loadMore) {
|
||||
_loadMoreEpisode();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
child: Stack(
|
||||
Column(
|
||||
children: [
|
||||
ScrollConfiguration(
|
||||
behavior: NoGrowBehavior(),
|
||||
child: CustomScrollView(
|
||||
key: PageStorageKey<String>('update'),
|
||||
physics:
|
||||
const AlwaysScrollableScrollPhysics(),
|
||||
slivers: <Widget>[
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
),
|
||||
EpisodeGrid(
|
||||
episodes: snapshot.data,
|
||||
layout: _layout,
|
||||
initNum: _scroll ? 0 : 12,
|
||||
multiSelect: _multiSelect,
|
||||
openPodcast: true,
|
||||
selectedList: _selectedEpisodes ?? [],
|
||||
onSelect: (value) => setState(() {
|
||||
_selectedEpisodes = value;
|
||||
}),
|
||||
),
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return _loadMore
|
||||
? Container(
|
||||
height: 2,
|
||||
child:
|
||||
LinearProgressIndicator())
|
||||
: Center();
|
||||
},
|
||||
childCount: 1,
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
if (!_multiSelect)
|
||||
Container(
|
||||
height: 40,
|
||||
color: context.primaryColor,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
_switchGroupButton(),
|
||||
Spacer(),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: IconButton(
|
||||
tooltip:
|
||||
context.s.refresh,
|
||||
icon: Icon(
|
||||
LineIcons
|
||||
.redo_alt_solid,
|
||||
size: 16),
|
||||
onPressed: () {
|
||||
_updateRssItem();
|
||||
Fluttertoast.showToast(
|
||||
msg: s.refreshStarted,
|
||||
gravity: ToastGravity
|
||||
.BOTTOM,
|
||||
);
|
||||
}),
|
||||
),
|
||||
_addNewButton(),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: IconButton(
|
||||
tooltip:
|
||||
s.hideListenedSetting,
|
||||
icon: SizedBox(
|
||||
width: 30,
|
||||
height: 15,
|
||||
child: HideListened(
|
||||
hideListened:
|
||||
_hideListened ??
|
||||
false,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() =>
|
||||
_hideListened =
|
||||
!_hideListened);
|
||||
},
|
||||
if (!_multiSelect)
|
||||
Container(
|
||||
height: 40,
|
||||
color: context.primaryColor,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
_switchGroupButton(),
|
||||
Spacer(),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: IconButton(
|
||||
tooltip: context.s.refresh,
|
||||
icon: Icon(
|
||||
LineIcons.redo_alt_solid,
|
||||
size: 16),
|
||||
onPressed: () {
|
||||
_updateRssItem();
|
||||
Fluttertoast.showToast(
|
||||
msg: s.refreshStarted,
|
||||
gravity:
|
||||
ToastGravity.BOTTOM,
|
||||
);
|
||||
}),
|
||||
),
|
||||
_addNewButton(),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: IconButton(
|
||||
tooltip: s.hideListenedSetting,
|
||||
icon: SizedBox(
|
||||
width: 30,
|
||||
height: 15,
|
||||
child: HideListened(
|
||||
hideListened:
|
||||
_hideListened ?? false,
|
||||
),
|
||||
),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: LayoutButton(
|
||||
layout: _layout,
|
||||
onPressed: (layout) =>
|
||||
setState(() {
|
||||
_layout = layout;
|
||||
}),
|
||||
),
|
||||
),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: IconButton(
|
||||
icon: SizedBox(
|
||||
width: 20,
|
||||
height: 10,
|
||||
child: CustomPaint(
|
||||
painter: MultiSelectPainter(
|
||||
onPressed: () {
|
||||
setState(() => _hideListened =
|
||||
!_hideListened);
|
||||
},
|
||||
),
|
||||
),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: LayoutButton(
|
||||
layout: _layout,
|
||||
onPressed: (layout) =>
|
||||
setState(() {
|
||||
_layout = layout;
|
||||
}),
|
||||
),
|
||||
),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: IconButton(
|
||||
icon: SizedBox(
|
||||
width: 20,
|
||||
height: 10,
|
||||
child: CustomPaint(
|
||||
painter:
|
||||
MultiSelectPainter(
|
||||
color: context
|
||||
.accentColor)),
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedEpisodes =
|
||||
[];
|
||||
_multiSelect = true;
|
||||
});
|
||||
},
|
||||
)),
|
||||
],
|
||||
),
|
||||
)),
|
||||
if (_multiSelect)
|
||||
MultiSelectMenuBar(
|
||||
selectedList: _selectedEpisodes,
|
||||
onClose: (value) {
|
||||
setState(() {
|
||||
if (value) {
|
||||
_multiSelect = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedEpisodes = [];
|
||||
_multiSelect = true;
|
||||
});
|
||||
},
|
||||
)),
|
||||
],
|
||||
),
|
||||
)),
|
||||
if (_multiSelect)
|
||||
MultiSelectMenuBar(
|
||||
selectedList: _selectedEpisodes,
|
||||
onClose: (value) {
|
||||
setState(() {
|
||||
if (value) {
|
||||
_multiSelect = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Center();
|
||||
},
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Center();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,9 +108,10 @@ class _ScrollPodcastsState extends State<ScrollPodcasts>
|
|||
Widget build(BuildContext context) {
|
||||
final width = MediaQuery.of(context).size.width;
|
||||
final s = context.s;
|
||||
return Selector<GroupList, tuple.Tuple2<List<PodcastGroup>, bool>>(
|
||||
selector: (_, groupList) =>
|
||||
tuple.Tuple2(groupList.groups, groupList.created),
|
||||
return Selector2<GroupList, RefreshWorker,
|
||||
tuple.Tuple3<List<PodcastGroup>, bool, bool>>(
|
||||
selector: (_, groupList, refreshWorker) => tuple.Tuple3(
|
||||
groupList.groups, groupList.created, refreshWorker.created),
|
||||
builder: (_, data, __) {
|
||||
var groups = data.item1;
|
||||
var import = data.item2;
|
||||
|
@ -513,26 +514,23 @@ class _PodcastPreviewState extends State<PodcastPreview> {
|
|||
return Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Selector<RefreshWorker, bool>(
|
||||
selector: (_, worker) => worker.complete,
|
||||
builder: (_, complete, __) => Selector<GroupList, bool>(
|
||||
selector: (_, worker) => worker.created,
|
||||
builder: (context, created, child) {
|
||||
_getRssItem = _getRssItemTop(widget.podcastLocal);
|
||||
return FutureBuilder<List<EpisodeBrief>>(
|
||||
future: _getRssItem,
|
||||
builder: (context, snapshot) {
|
||||
return (snapshot.hasData)
|
||||
? ShowEpisode(
|
||||
episodes: snapshot.data,
|
||||
podcastLocal: widget.podcastLocal,
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
child: Selector2<RefreshWorker, GroupList, tuple.Tuple2<bool, bool>>(
|
||||
selector: (_, refreshWorker, groupWorker) =>
|
||||
tuple.Tuple2(refreshWorker.created, groupWorker.created),
|
||||
builder: (_, data, __) {
|
||||
_getRssItem = _getRssItemTop(widget.podcastLocal);
|
||||
return FutureBuilder<List<EpisodeBrief>>(
|
||||
future: _getRssItem,
|
||||
builder: (context, snapshot) {
|
||||
return (snapshot.hasData)
|
||||
? ShowEpisode(
|
||||
episodes: snapshot.data,
|
||||
podcastLocal: widget.podcastLocal,
|
||||
)
|
||||
: Padding(padding: const EdgeInsets.all(5.0));
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Container(
|
||||
|
|
|
@ -27,6 +27,7 @@ class RefreshWorker extends ChangeNotifier {
|
|||
bool get complete => _complete;
|
||||
|
||||
bool _created = false;
|
||||
bool get created => _created;
|
||||
|
||||
Future<void> _createIsolate() async {
|
||||
receivePort = ReceivePort();
|
||||
|
@ -46,12 +47,12 @@ class RefreshWorker extends ChangeNotifier {
|
|||
notifyListeners();
|
||||
} else if (message is String && message == "done") {
|
||||
_currentRefreshItem = RefreshItem('', RefreshState.none);
|
||||
_complete = true;
|
||||
notifyListeners();
|
||||
_complete = false;
|
||||
refreshIsolate?.kill();
|
||||
refreshIsolate = null;
|
||||
_created = false;
|
||||
_complete = true;
|
||||
notifyListeners();
|
||||
_complete = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue