Fixed ompl file import bug, add rssUrl vilidate.
This commit is contained in:
parent
a6182973f2
commit
33e34e9966
|
@ -54,6 +54,7 @@ class _PopupMenuState extends State<PopupMenu> {
|
||||||
|
|
||||||
void _saveOmpl(String path) async {
|
void _saveOmpl(String path) async {
|
||||||
var subscribeWorker = Provider.of<GroupList>(context, listen: false);
|
var subscribeWorker = Provider.of<GroupList>(context, listen: false);
|
||||||
|
RegExp rssExp = RegExp(r'^(https?):\/\/(.*)');
|
||||||
final s = context.s;
|
final s = context.s;
|
||||||
File file = File(path);
|
File file = File(path);
|
||||||
try {
|
try {
|
||||||
|
@ -63,9 +64,9 @@ class _PopupMenuState extends State<PopupMenu> {
|
||||||
print(title);
|
print(title);
|
||||||
var list = entry.value.reversed;
|
var list = entry.value.reversed;
|
||||||
for (var rss in list) {
|
for (var rss in list) {
|
||||||
if (rss.xmlUrl != null) {
|
String rssLink = rssExp.stringMatch(rss.xmlUrl);
|
||||||
SubscribeItem item =
|
if (rssLink != null) {
|
||||||
SubscribeItem(rss.xmlUrl, rss.text, group: title);
|
SubscribeItem item = SubscribeItem(rssLink, rss.text, group: title);
|
||||||
await subscribeWorker.setSubscribeItem(item);
|
await subscribeWorker.setSubscribeItem(item);
|
||||||
await Future.delayed(Duration(milliseconds: 200));
|
await Future.delayed(Duration(milliseconds: 200));
|
||||||
print(rss.text);
|
print(rss.text);
|
||||||
|
|
|
@ -76,7 +76,7 @@ class MyHomePageDelegate extends SearchDelegate<int> {
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(top: 400),
|
padding: EdgeInsets.only(top: 400),
|
||||||
child: Image(
|
child: Image(
|
||||||
image: Theme.of(context).brightness == Brightness.light
|
image: context.brightness == Brightness.light
|
||||||
? AssetImage('assets/listennotes.png')
|
? AssetImage('assets/listennotes.png')
|
||||||
: AssetImage('assets/listennotes_light.png'),
|
: AssetImage('assets/listennotes_light.png'),
|
||||||
height: 20,
|
height: 20,
|
||||||
|
|
|
@ -425,7 +425,7 @@ Future<void> subIsolateEntryPoint(SendPort sendPort) async {
|
||||||
var dbHelper = DBHelper();
|
var dbHelper = DBHelper();
|
||||||
String rss = item.url;
|
String rss = item.url;
|
||||||
sendPort.send([item.title, item.url, 1]);
|
sendPort.send([item.title, item.url, 1]);
|
||||||
BaseOptions options = new BaseOptions(
|
BaseOptions options = BaseOptions(
|
||||||
connectTimeout: 20000,
|
connectTimeout: 20000,
|
||||||
receiveTimeout: 20000,
|
receiveTimeout: 20000,
|
||||||
);
|
);
|
||||||
|
@ -436,7 +436,7 @@ Future<void> subIsolateEntryPoint(SendPort sendPort) async {
|
||||||
RssFeed p;
|
RssFeed p;
|
||||||
try {
|
try {
|
||||||
p = RssFeed.parse(response.data);
|
p = RssFeed.parse(response.data);
|
||||||
} on ArgumentError catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
sendPort.send([item.title, item.url, 6]);
|
sendPort.send([item.title, item.url, 6]);
|
||||||
await Future.delayed(Duration(seconds: 2));
|
await Future.delayed(Duration(seconds: 2));
|
||||||
|
@ -460,16 +460,21 @@ Future<void> subIsolateEntryPoint(SendPort sendPort) async {
|
||||||
img.Image thumbnail;
|
img.Image thumbnail;
|
||||||
String imageUrl;
|
String imageUrl;
|
||||||
try {
|
try {
|
||||||
Response<List<int>> imageResponse = await Dio().get<List<int>>(
|
Response<List<int>> imageResponse =
|
||||||
p.itunes.image.href,
|
await Dio().get<List<int>>(p.itunes.image.href,
|
||||||
options: Options(responseType: ResponseType.bytes));
|
options: Options(
|
||||||
|
responseType: ResponseType.bytes,
|
||||||
|
receiveTimeout: 60000,
|
||||||
|
));
|
||||||
imageUrl = p.itunes.image.href;
|
imageUrl = p.itunes.image.href;
|
||||||
img.Image image = img.decodeImage(imageResponse.data);
|
img.Image image = img.decodeImage(imageResponse.data);
|
||||||
thumbnail = img.copyResize(image, width: 300);
|
thumbnail = img.copyResize(image, width: 300);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
try {
|
try {
|
||||||
Response<List<int>> imageResponse = await Dio().get<List<int>>(
|
Response<List<int>> imageResponse = await Dio(BaseOptions(
|
||||||
item.imgUrl,
|
connectTimeout: 20000,
|
||||||
|
receiveTimeout: 60000,
|
||||||
|
)).get<List<int>>(item.imgUrl,
|
||||||
options: Options(responseType: ResponseType.bytes));
|
options: Options(responseType: ResponseType.bytes));
|
||||||
imageUrl = item.imgUrl;
|
imageUrl = item.imgUrl;
|
||||||
img.Image image = img.decodeImage(imageResponse.data);
|
img.Image image = img.decodeImage(imageResponse.data);
|
||||||
|
@ -543,7 +548,7 @@ Future<void> subIsolateEntryPoint(SendPort sendPort) async {
|
||||||
} else
|
} else
|
||||||
sendPort.send("done");
|
sendPort.send("done");
|
||||||
}
|
}
|
||||||
} on DioError catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
sendPort.send([item.title, item.url, 6]);
|
sendPort.send([item.title, item.url, 6]);
|
||||||
await Future.delayed(Duration(seconds: 2));
|
await Future.delayed(Duration(seconds: 2));
|
||||||
|
|
Loading…
Reference in New Issue