为 audioplayers_android 模块单独设置 Java 1.8,其他模块保持 Java 17
This commit is contained in:
@@ -28,7 +28,6 @@ class AutoRefreshManager {
|
||||
Future<void> init() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_isEnabled = prefs.getBool(_autoRefreshKey) ?? false;
|
||||
_debugLog('自动刷新初始化,状态: $_isEnabled');
|
||||
}
|
||||
|
||||
bool get isEnabled => _isEnabled;
|
||||
@@ -37,7 +36,6 @@ class AutoRefreshManager {
|
||||
_isEnabled = enabled;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool(_autoRefreshKey, enabled);
|
||||
_debugLog('自动刷新状态已设置: $enabled');
|
||||
|
||||
if (enabled) {
|
||||
_startTimer();
|
||||
@@ -48,25 +46,21 @@ class AutoRefreshManager {
|
||||
|
||||
void setOnRefresh(VoidCallback? callback) {
|
||||
_onRefresh = callback;
|
||||
_debugLog('设置刷新回调');
|
||||
}
|
||||
|
||||
void _startTimer() {
|
||||
_stopTimer();
|
||||
_refreshTimer = Timer.periodic(_refreshInterval, (timer) {
|
||||
_debugLog('自动刷新触发');
|
||||
if (_onRefresh != null) {
|
||||
_onRefresh!();
|
||||
}
|
||||
});
|
||||
_debugLog('自动刷新定时器已启动');
|
||||
}
|
||||
|
||||
void _stopTimer() {
|
||||
if (_refreshTimer != null) {
|
||||
_refreshTimer!.cancel();
|
||||
_refreshTimer = null;
|
||||
_debugLog('自动刷新定时器已停止');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,11 +71,6 @@ class AutoRefreshManager {
|
||||
void dispose() {
|
||||
_stopTimer();
|
||||
_onRefresh = null;
|
||||
_debugLog('自动刷新管理器已释放');
|
||||
}
|
||||
|
||||
void _debugLog(String message) {
|
||||
if (kDebugMode) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +92,6 @@ class DebugInfoManager {
|
||||
Future<void> init() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_isEnabled = prefs.getBool(_debugInfoKey) ?? false;
|
||||
_debugLog('调试信息初始化,状态: $_isEnabled');
|
||||
}
|
||||
|
||||
bool get isEnabled => _isEnabled;
|
||||
@@ -113,7 +101,6 @@ class DebugInfoManager {
|
||||
_isEnabled = enabled;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool(_debugInfoKey, enabled);
|
||||
_debugLog('调试信息状态已设置: $enabled');
|
||||
|
||||
if (!enabled) {
|
||||
_messageNotifier.value = '';
|
||||
@@ -124,12 +111,10 @@ class DebugInfoManager {
|
||||
if (!_isEnabled) return;
|
||||
|
||||
_messageNotifier.value = message;
|
||||
_debugLog('显示调试信息: $message');
|
||||
|
||||
_messageTimer?.cancel();
|
||||
_messageTimer = Timer(const Duration(seconds: 2), () {
|
||||
_messageNotifier.value = '';
|
||||
_debugLog('调试信息已隐藏');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -176,11 +161,6 @@ class DebugInfoManager {
|
||||
void dispose() {
|
||||
_messageTimer?.cancel();
|
||||
_messageNotifier.value = '';
|
||||
_debugLog('调试信息管理器已清理');
|
||||
}
|
||||
|
||||
void _debugLog(String message) {
|
||||
if (kDebugMode) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +181,6 @@ class OfflineDataManager {
|
||||
|
||||
Future<void> init() async {
|
||||
await _loadCachedData();
|
||||
_debugLog('离线数据管理器初始化,缓存数量: ${_cachedPoetryList.length}');
|
||||
}
|
||||
|
||||
Future<bool> isOnline() async {
|
||||
@@ -273,7 +252,7 @@ class OfflineDataManager {
|
||||
|
||||
_cachedPoetryList.add(map);
|
||||
} catch (e) {
|
||||
_debugLog('解析缓存数据失败: $e');
|
||||
// 解析失败
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -320,12 +299,7 @@ class OfflineDataManager {
|
||||
updateTime: updateTime,
|
||||
);
|
||||
} catch (e) {
|
||||
_debugLog('转换为PoetryData失败: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void _debugLog(String message) {
|
||||
if (kDebugMode) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,8 +293,8 @@ class _HomePageState extends State<HomePage>
|
||||
Future<void> _toggleLike() async {
|
||||
if (_poetryData == null || _isLoadingLike) return;
|
||||
|
||||
// 播放点赞音效
|
||||
await AudioManager().playLikeSound();
|
||||
// 播放点赞音效(不等待完成)
|
||||
AudioManager().playLikeSound();
|
||||
|
||||
// 立即切换按钮状态和显示加载
|
||||
setState(() {
|
||||
@@ -397,7 +397,7 @@ class _HomePageState extends State<HomePage>
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
print('加载历史记录失败: $e');
|
||||
// 加载失败
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ class _HomePageState extends State<HomePage>
|
||||
|
||||
await HistoryController.addToHistory(poetryMap);
|
||||
} catch (e) {
|
||||
print('保存历史记录失败: $e');
|
||||
// 保存失败
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,8 +434,8 @@ class _HomePageState extends State<HomePage>
|
||||
void _loadNextPoetry() async {
|
||||
if (_isLoadingNext) return;
|
||||
|
||||
// 播放下一条音效
|
||||
await AudioManager().playNextSound();
|
||||
// 播放下一条音效(不等待完成)
|
||||
AudioManager().playNextSound();
|
||||
|
||||
setState(() {
|
||||
_isLoadingNext = true;
|
||||
|
||||
@@ -106,9 +106,9 @@ class _PoetryCardState extends State<PoetryCard> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
// 播放点击音效
|
||||
await AudioManager().playClickSound();
|
||||
onTap: () {
|
||||
// 播放点击音效(不等待完成)
|
||||
AudioManager().playClickSound();
|
||||
// 调用原始的onTap回调
|
||||
widget.onTap?.call();
|
||||
},
|
||||
@@ -715,6 +715,7 @@ class FloatingPreviousButton extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
onTap: () {
|
||||
HapticFeedback.lightImpact();
|
||||
AudioManager().playClickSound();
|
||||
onPrevious();
|
||||
},
|
||||
child: const Center(
|
||||
@@ -755,6 +756,7 @@ class FloatingNextButton extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
onTap: () {
|
||||
HapticFeedback.lightImpact();
|
||||
AudioManager().playNextSound();
|
||||
onNext();
|
||||
},
|
||||
child: const Center(
|
||||
@@ -805,6 +807,7 @@ class FloatingLikeButton extends StatelessWidget {
|
||||
? null
|
||||
: () {
|
||||
HapticFeedback.mediumImpact();
|
||||
AudioManager().playLikeSound();
|
||||
onToggleLike();
|
||||
},
|
||||
child: Center(
|
||||
|
||||
Reference in New Issue
Block a user