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