mirror of
https://github.com/stonega/tsacdop
synced 2024-12-16 10:22:23 +01:00
a6fc34e7bb
modified: android/app/build.gradle modified: android/app/src/main/AndroidManifest.xml new file: android/app/src/main/res/drawable/launch_background_night.xml new file: android/app/src/main/res/drawable/normal_background.xml new file: android/app/src/main/res/values-night/styles.xml modified: android/app/src/main/res/values/styles.xml new file: assets/fireside.jpg new file: assets/logo.png modified: lib/class/audiostate.dart modified: lib/class/fireside_data.dart modified: lib/class/podcastlocal.dart modified: lib/class/settingstate.dart modified: lib/episodes/episodedetail.dart modified: lib/episodes/episodedownload.dart modified: lib/home/appbar/about.dart modified: lib/home/appbar/addpodcast.dart modified: lib/home/appbar/importompl.dart modified: lib/home/appbar/popupmenu.dart modified: lib/home/audiopanel.dart modified: lib/home/audioplayer.dart modified: lib/home/homescroll.dart modified: lib/home/hometab.dart new file: lib/home/paly_history.dart modified: lib/local_storage/key_value_storage.dart modified: lib/local_storage/sqflite_localpodcast.dart modified: lib/main.dart modified: lib/podcasts/podcastdetail.dart modified: lib/podcasts/podcastgroup.dart modified: lib/podcasts/podcastlist.dart modified: lib/podcasts/podcastmanage.dart new file: lib/settings/settting.dart new file: lib/settings/theme.dart new file: lib/util/colorize.dart modified: lib/util/episodegrid.dart modified: pubspec.lock modified: pubspec.yaml
70 lines
2.2 KiB
Dart
70 lines
2.2 KiB
Dart
import 'dart:async';
|
|
import 'dart:convert';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:tsacdop/class/podcast_group.dart';
|
|
|
|
class KeyValueStorage {
|
|
final String key;
|
|
KeyValueStorage(this.key);
|
|
|
|
Future<List<GroupEntity>> getGroups() async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
if (prefs.getString(key) == null) {
|
|
PodcastGroup home = PodcastGroup('Home');
|
|
await prefs.setString(
|
|
key,
|
|
json.encode({
|
|
'groups': [home.toEntity().toJson()]
|
|
}));}
|
|
print(prefs.getString(key));
|
|
return json
|
|
.decode(prefs.getString(key))['groups']
|
|
.cast<Map<String, Object>>()
|
|
.map<GroupEntity>(GroupEntity.fromJson)
|
|
.toList(growable: false);
|
|
}
|
|
|
|
Future<bool> saveGroup(List<GroupEntity> groupList) async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
return prefs.setString(
|
|
key,
|
|
json.encode(
|
|
{'groups': groupList.map((group) => group.toJson()).toList()}));
|
|
}
|
|
|
|
Future<bool> saveInt(int setting) async{
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
print(setting.toString());
|
|
return prefs.setInt(key, setting);
|
|
}
|
|
|
|
Future<int> getInt() async{
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
if(prefs.getInt(key) == null) await prefs.setInt(key, 0);
|
|
return prefs.getInt(key);
|
|
}
|
|
|
|
Future<bool> saveStringlist(List<String> playList) async{
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
return prefs.setStringList(key, playList);
|
|
}
|
|
|
|
Future<List<String>> getStringList() async{
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
if(prefs.getStringList(key) == null) {await prefs.setStringList(key, []);}
|
|
return prefs.getStringList(key);
|
|
}
|
|
|
|
Future<bool> saveString(String string) async{
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
return prefs.setString(key, string);
|
|
}
|
|
|
|
Future<String> getString() async{
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
if(prefs.getString(key) == null) {await prefs.setString(key, '');}
|
|
return prefs.getString(key);
|
|
}
|
|
|
|
}
|