Add resfresh all in popupmenu
modified: lib/class/sqflite_localpodcast.dart modified: lib/home/appbar/addpodcast.dart modified: lib/home/appbar/popupmenu.dart
This commit is contained in:
parent
b471c15b52
commit
9d2154f34a
|
@ -4,7 +4,7 @@ Enjoy podcasts with tsacdop!
|
|||
Tsacdop is a podcasts player developed with flutter.
|
||||
The development is still on early stage.
|
||||
|
||||
Thanks for flutter team and all plugin developers, especially [webfeed](https://github.com/witochandra/webfeed) and [audiofileplayer](https://github.com/google/flutter.plugins/tree/master/packages/audiofileplayer/).
|
||||
Thanks for flutter team and all involved plugin developers, especially [webfeed](https://github.com/witochandra/webfeed) and [audiofileplayer](https://github.com/google/flutter.plugins/tree/master/packages/audiofileplayer/).
|
||||
|
||||
The podcasts search engine is powered by [ListenNotes](https://listennotes.com).
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import 'package:flutter_downloader/flutter_downloader.dart';
|
|||
import 'package:path_provider/path_provider.dart';
|
||||
import 'podcastlocal.dart';
|
||||
import 'episodebrief.dart';
|
||||
import '../webfeed/webfeed.dart';
|
||||
import 'package:tsacdop/webfeed/webfeed.dart';
|
||||
|
||||
class DBHelper {
|
||||
static Database _db;
|
||||
|
@ -133,12 +133,11 @@ class DBHelper {
|
|||
return ximalaya.hasMatch(input);
|
||||
}
|
||||
|
||||
Future<int> savePodcastRss(String rss) async {
|
||||
Future<int> savePodcastRss(RssFeed _p) async {
|
||||
String _title;
|
||||
String _url;
|
||||
String _description;
|
||||
int _duration;
|
||||
var _p = RssFeed.parse(rss);
|
||||
int _result = _p.items.length;
|
||||
var dbClient = await database;
|
||||
int _count = Sqflite.firstIntValue(await dbClient.rawQuery(
|
||||
|
|
|
@ -207,6 +207,7 @@ class _SearchResultState extends State<SearchResult> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final importOmpl = Provider.of<ImportOmpl>(context);
|
||||
|
||||
savePodcast(String rss) async {
|
||||
print(rss);
|
||||
if (mounted) setState(() => _adding = true);
|
||||
|
@ -240,7 +241,7 @@ class _SearchResultState extends State<SearchResult> {
|
|||
|
||||
importOmpl.importState = ImportState.parse;
|
||||
|
||||
await dbHelper.savePodcastRss(response.data);
|
||||
await dbHelper.savePodcastRss(_p);
|
||||
|
||||
importOmpl.importState = ImportState.complete;
|
||||
importOmpl.importState = ImportState.stop;
|
||||
|
|
|
@ -32,7 +32,6 @@ class OmplOutline {
|
|||
}
|
||||
|
||||
class PopupMenu extends StatelessWidget {
|
||||
|
||||
Future<String> getColor(File file) async {
|
||||
final imageProvider = FileImage(file);
|
||||
var colorImage = await getImageFromProvider(imageProvider);
|
||||
|
@ -45,6 +44,21 @@ class PopupMenu extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final importOmpl = Provider.of<ImportOmpl>(context);
|
||||
|
||||
_refreshAll() async {
|
||||
var dbHelper = DBHelper();
|
||||
List<PodcastLocal> podcastList = await dbHelper.getPodcastLocal();
|
||||
await Future.forEach(podcastList, (podcastLocal) async {
|
||||
importOmpl.rssTitle = podcastLocal.title;
|
||||
importOmpl.importState = ImportState.parse;
|
||||
Response response = await Dio().get(podcastLocal.rssUrl);
|
||||
var _p = RssFeed.parse(response.data);
|
||||
await dbHelper.savePodcastRss(_p);
|
||||
print('Refresh ' + podcastLocal.title);
|
||||
});
|
||||
importOmpl.importState = ImportState.complete;
|
||||
importOmpl.importState = ImportState.stop;
|
||||
}
|
||||
|
||||
saveOmpl(String rss) async {
|
||||
var dbHelper = DBHelper();
|
||||
try {
|
||||
|
@ -74,7 +88,7 @@ class PopupMenu extends StatelessWidget {
|
|||
|
||||
importOmpl.importState = ImportState.parse;
|
||||
|
||||
await dbHelper.savePodcastRss(response.data);
|
||||
await dbHelper.savePodcastRss(_p);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
|
@ -120,24 +134,30 @@ class PopupMenu extends StatelessWidget {
|
|||
}
|
||||
|
||||
return PopupMenuButton<int>(
|
||||
elevation: 2,
|
||||
elevation: 3,
|
||||
tooltip: 'Menu',
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 1,
|
||||
child: Text('Impoer OMPL'),
|
||||
child: Text('Refresh All'),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 2,
|
||||
child: Text('Impoer OMPL'),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 3,
|
||||
child: Text('About'),
|
||||
),
|
||||
],
|
||||
onSelected: (value) {
|
||||
if (value == 2) {
|
||||
if (value == 3) {
|
||||
Navigator.push(
|
||||
context, MaterialPageRoute(builder: (context) => AboutApp()));
|
||||
} else if (value == 1) {
|
||||
} else if (value == 2) {
|
||||
_getFilePath();
|
||||
} else if (value == 1) {
|
||||
_refreshAll();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name: Tsacdop
|
||||
name: tsacdop
|
||||
description: An easy-use podacasts player.
|
||||
|
||||
# The following defines the version and build number for your application.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:Tsacdop/main.dart';
|
||||
import 'package:tsacdop/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
|
|
Loading…
Reference in New Issue