Fix ompl import bug.

This commit is contained in:
stonegate 2020-07-16 21:55:41 +08:00
parent bd350dac27
commit 0a8084f0ef
3 changed files with 33 additions and 12 deletions

View File

@ -168,7 +168,7 @@ class _ScrollPodcastsState extends State<ScrollPodcasts> {
)),
Container(
height: (_width - 20) / 3 + 40,
color: Theme.of(context).primaryColor,
color: context.primaryColor,
margin: EdgeInsets.symmetric(horizontal: 15),
child: Center(
child: _groupIndex == 0
@ -302,6 +302,11 @@ class _ScrollPodcastsState extends State<ScrollPodcasts> {
tabs: groups[_groupIndex]
.podcasts
.map<Widget>((PodcastLocal podcastLocal) {
Color color = (Theme.of(context).brightness ==
Brightness.light)
? podcastLocal.primaryColor.colorizedark()
: podcastLocal.primaryColor
.colorizeLight();
return Tab(
child: ClipRRect(
borderRadius: BorderRadius.all(
@ -312,8 +317,14 @@ class _ScrollPodcastsState extends State<ScrollPodcasts> {
LimitedBox(
maxHeight: 50,
maxWidth: 50,
child: Image.file(File(
"${podcastLocal.imagePath}")),
child: CircleAvatar(
backgroundColor:
color.withOpacity(0.5),
backgroundImage: FileImage(File(
"${podcastLocal.imagePath}")),
),
// child: Image.file(File(
// "${podcastLocal.imagePath}")),
),
FutureBuilder<int>(
future: getPodcastUpdateCounts(

View File

@ -60,13 +60,14 @@ class _PopupMenuState extends State<PopupMenu> {
Map<String, List<OmplOutline>> data = PodcastsBackup.parseOMPL(file);
for (var entry in data.entries) {
String title = entry.key;
var list = entry.value;
print(title);
var list = entry.value.reversed;
for (var rss in list) {
if (rss.xmlUrl != null) {
SubscribeItem item =
SubscribeItem(rss.xmlUrl, rss.text, group: title);
await subscribeWorker.setSubscribeItem(item);
await Future.delayed(Duration(milliseconds: 500));
await Future.delayed(Duration(milliseconds: 200));
print(rss.text);
}
}

View File

@ -323,25 +323,34 @@ class GroupList extends ChangeNotifier {
}
/// Subscribe podcast from OMPL.
Future _subscribeNewPodcast({String id, String groupName = 'Home'}) async {
Future<bool> _subscribeNewPodcast(
{String id, String groupName = 'Home'}) async {
//List<String> groupNames = _groups.map((e) => e.name).toList();
for (PodcastGroup group in _groups) {
if (group.name == groupName) {
if (!group.podcastList.contains(id)) {
if (group.podcastList.contains(id))
return true;
else {
_isLoading = true;
notifyListeners();
group.podcastList.insert(0, id);
await _saveGroup();
await group.getPodcasts();
_isLoading = false;
notifyListeners();
return;
return true;
}
}
}
_isLoading = true;
_groups.add(PodcastGroup(groupName));
_groups.last.podcastList.insert(0, id);
notifyListeners();
_groups.add(PodcastGroup(groupName, podcastList: [id]));
//_groups.last.podcastList.insert(0, id);
await _saveGroup();
await _groups.last.getPodcasts();
_isLoading = false;
notifyListeners();
return true;
}
List<PodcastGroup> getPodcastGroup(String id) {
@ -519,7 +528,7 @@ Future<void> subIsolateEntryPoint(SendPort sendPort) async {
await Future.delayed(Duration(seconds: 2));
sendPort.send([item.title, item.url, 4]);
items.removeWhere((element) => element.url == item.url);
items.removeAt(0);
if (items.length > 0) {
await _subscribe(items.first);
} else
@ -528,7 +537,7 @@ Future<void> subIsolateEntryPoint(SendPort sendPort) async {
sendPort.send([item.title, realUrl, 5, checkUrl, item.group]);
await Future.delayed(Duration(seconds: 2));
sendPort.send([item.title, item.url, 4]);
items.removeWhere((element) => element.url == item.url);
items.removeAt(0);
if (items.length > 0) {
await _subscribe(items.first);
} else