Improve gpodder sync.
This commit is contained in:
parent
d15f1c7b89
commit
93ed9d3513
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PreviewsEnabled</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PreviewsEnabled</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -191,15 +191,6 @@ class AboutApp extends StatelessWidget {
|
|||
'https://github.com/stonega'),
|
||||
_listItem(context, 'Medium', LineIcons.medium,
|
||||
'https://medium.com/@stonegate'),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
|
||||
child: Text(
|
||||
'I need to pay for podcast search API and '
|
||||
'always get headache without caffeine.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey[500]),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 200,
|
||||
|
@ -221,7 +212,6 @@ class AboutApp extends StatelessWidget {
|
|||
children: <Widget>[
|
||||
Text('Buy me a coffee',
|
||||
style: TextStyle(
|
||||
color: context.accentColor,
|
||||
fontWeight: FontWeight.bold)),
|
||||
SizedBox(width: 10),
|
||||
Image(
|
||||
|
@ -236,6 +226,15 @@ class AboutApp extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
|
||||
child: Text(
|
||||
'I need to pay for podcast search API and '
|
||||
'always get headache without caffeine.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey[500]),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -390,7 +390,6 @@ class __TopPodcastListState extends State<_TopPodcastList> {
|
|||
() {
|
||||
_loading = true;
|
||||
_page++;
|
||||
print(_page);
|
||||
_searchFuture = _getTopPodcasts(
|
||||
genre: widget.genre, page: _page);
|
||||
},
|
||||
|
|
|
@ -194,7 +194,6 @@ class Gpodder {
|
|||
final timeStamp = changes['timestamp'];
|
||||
final addList = changes['add'].cast<String>();
|
||||
final removeList = changes['remove'].cast<String>();
|
||||
print(removeList);
|
||||
await _storage.saveStringList([username, deviceId, timeStamp.toString()]);
|
||||
await _remoteAddStorage.addList(addList);
|
||||
await _remoteRemoveStorage.addList(removeList);
|
||||
|
|
|
@ -12,8 +12,6 @@ import 'package:line_icons/line_icons.dart';
|
|||
import 'package:path/path.dart' as path;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tsacdop/util/custom_widget.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
import 'package:wc_flutter_share/wc_flutter_share.dart';
|
||||
|
||||
import '../local_storage/key_value_storage.dart';
|
||||
|
@ -23,6 +21,7 @@ import '../service/opml_build.dart';
|
|||
import '../state/podcast_group.dart';
|
||||
import '../state/setting_state.dart';
|
||||
import '../type/settings_backup.dart';
|
||||
import '../util/custom_widget.dart';
|
||||
import '../util/extension_helper.dart';
|
||||
|
||||
class DataBackup extends StatefulWidget {
|
||||
|
@ -151,9 +150,11 @@ class _DataBackupState extends State<DataBackup> {
|
|||
}
|
||||
|
||||
Future<void> _syncNow() async {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_syncing = true;
|
||||
});
|
||||
}
|
||||
final gpodder = Gpodder();
|
||||
final status = await gpodder.getChanges();
|
||||
|
||||
|
@ -169,10 +170,12 @@ class _DataBackupState extends State<DataBackup> {
|
|||
}
|
||||
}
|
||||
|
||||
Future<Tuple2<int, int>> _getSyncStatus() async {
|
||||
final syncDateTime = await KeyValueStorage(gpodderSyncDateTimeKey).getInt();
|
||||
final statusIndex = await KeyValueStorage(gpodderSyncStatusKey).getInt();
|
||||
return Tuple2(syncDateTime, statusIndex);
|
||||
Future<List<int>> _getSyncStatus() async {
|
||||
var dateTimeStorage = KeyValueStorage(gpodderSyncDateTimeKey);
|
||||
var statusStorage = KeyValueStorage(gpodderSyncStatusKey);
|
||||
final syncDateTime = await dateTimeStorage.getInt();
|
||||
final statusIndex = await statusStorage.getInt();
|
||||
return [syncDateTime, statusIndex];
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -300,12 +303,12 @@ class _DataBackupState extends State<DataBackup> {
|
|||
const EdgeInsets.only(left: 70.0, right: 20),
|
||||
onTap: _syncNow,
|
||||
title: Text(s.syncNow),
|
||||
subtitle: FutureBuilder<Tuple2<int, int>>(
|
||||
subtitle: FutureBuilder<List<int>>(
|
||||
future: _getSyncStatus(),
|
||||
initialData: Tuple2(0, 0),
|
||||
initialData: [0, 0],
|
||||
builder: (context, snapshot) {
|
||||
final dateTime = snapshot.data.item1;
|
||||
final status = snapshot.data.item2;
|
||||
final dateTime = snapshot.data[0];
|
||||
final status = snapshot.data[1];
|
||||
return Wrap(
|
||||
children: [
|
||||
Text(
|
||||
|
@ -320,6 +323,14 @@ class _DataBackupState extends State<DataBackup> {
|
|||
}
|
||||
return Center();
|
||||
}),
|
||||
// ListTile(
|
||||
// onTap: () async {
|
||||
// final subscribeWorker = context.read<GroupList>();
|
||||
// await subscribeWorker.cancelWork();
|
||||
// subscribeWorker.setWorkManager();
|
||||
// },
|
||||
// title: Text('reset'),
|
||||
// ),
|
||||
Divider(height: 1),
|
||||
Container(
|
||||
height: 30.0,
|
||||
|
@ -489,7 +500,8 @@ class _DataBackupState extends State<DataBackup> {
|
|||
),
|
||||
Divider(height: 1)
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -634,7 +646,7 @@ class __LoginGpodderState extends State<_LoginGpodder> {
|
|||
}
|
||||
}
|
||||
await subscribeWorker.cancelWork();
|
||||
subscribeWorker.setWorkManager(4);
|
||||
subscribeWorker.setWorkManager();
|
||||
}
|
||||
|
||||
String _validateName(String value) {
|
||||
|
@ -750,6 +762,8 @@ class __LoginGpodderState extends State<_LoginGpodder> {
|
|||
child: Text(
|
||||
s.gpodderLoginDes,
|
||||
textAlign: TextAlign.center,
|
||||
style:
|
||||
context.textTheme.subtitle1.copyWith(height: 2),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
|
|
|
@ -107,7 +107,7 @@ class _LanguagesSettingState extends State<LanguagesSetting> {
|
|||
),
|
||||
Divider(height: 1),
|
||||
ListTile(
|
||||
title: Text('português'),
|
||||
title: Text('Português'),
|
||||
onTap: () => _setLocale(Locale('pt')),
|
||||
contentPadding: const EdgeInsets.only(left: 20, right: 20),
|
||||
trailing: Radio<Locale>(
|
||||
|
|
|
@ -30,6 +30,7 @@ void callbackDispatcher() {
|
|||
final status = await gpodder.getChanges();
|
||||
if (status == 200) {
|
||||
await gpodder.updateChange();
|
||||
developer.log('Gpodder sync successfully');
|
||||
}
|
||||
return Future.value(true);
|
||||
});
|
||||
|
@ -310,14 +311,14 @@ class GroupList extends ChangeNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
void setWorkManager(int hour) {
|
||||
void setWorkManager() {
|
||||
Workmanager.initialize(
|
||||
callbackDispatcher,
|
||||
isInDebugMode: false,
|
||||
);
|
||||
Workmanager.registerPeriodicTask("2", "gpodder_sync",
|
||||
frequency: Duration(hours: hour),
|
||||
initialDelay: Duration(seconds: 10),
|
||||
frequency: Duration(hours: 4),
|
||||
initialDelay: Duration(seconds: 1),
|
||||
constraints: Constraints(
|
||||
networkType: NetworkType.connected,
|
||||
));
|
||||
|
|
Loading…
Reference in New Issue