Compare commits
2 Commits
fix-audioP
...
feature-ba
Author | SHA1 | Date | |
---|---|---|---|
105a29f311 | |||
3bf6136bc6 |
@ -16,6 +16,7 @@ import 'package:pilipala/pages/search/index.dart';
|
||||
import 'package:pilipala/pages/video/detail/index.dart';
|
||||
import 'package:pilipala/router/app_pages.dart';
|
||||
import 'package:pilipala/pages/main/view.dart';
|
||||
import 'package:pilipala/services/disable_battery_opt.dart';
|
||||
import 'package:pilipala/services/service_locator.dart';
|
||||
import 'package:pilipala/utils/app_scheme.dart';
|
||||
import 'package:pilipala/utils/data.dart';
|
||||
@ -71,6 +72,7 @@ void main() async {
|
||||
));
|
||||
Data.init();
|
||||
PiliSchame.init();
|
||||
DisableBatteryOpt();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,9 @@ class VideoReplyReplyController extends GetxController {
|
||||
if (type == 'init') {
|
||||
currentPage = 0;
|
||||
}
|
||||
if (isLoadingMore) {
|
||||
return;
|
||||
}
|
||||
isLoadingMore = true;
|
||||
final res = await ReplyHttp.replyReplyList(
|
||||
oid: aid!,
|
||||
@ -41,7 +44,7 @@ class VideoReplyReplyController extends GetxController {
|
||||
final List<ReplyItemModel> replies = res['data'].replies;
|
||||
if (replies.isNotEmpty) {
|
||||
noMore.value = '加载中...';
|
||||
if (replyList.length == res['data'].page.count) {
|
||||
if (replies.length == res['data'].page.count) {
|
||||
noMore.value = '没有更多了';
|
||||
}
|
||||
currentPage++;
|
||||
@ -50,21 +53,6 @@ class VideoReplyReplyController extends GetxController {
|
||||
noMore.value = currentPage == 0 ? '还没有评论' : '没有更多了';
|
||||
}
|
||||
if (type == 'init') {
|
||||
// List<ReplyItemModel> replies = res['data'].replies;
|
||||
// 添加置顶回复
|
||||
// if (res['data'].upper.top != null) {
|
||||
// bool flag = false;
|
||||
// for (var i = 0; i < res['data'].topReplies.length; i++) {
|
||||
// if (res['data'].topReplies[i].rpid == res['data'].upper.top.rpid) {
|
||||
// flag = true;
|
||||
// }
|
||||
// }
|
||||
// if (!flag) {
|
||||
// replies.insert(0, res['data'].upper.top);
|
||||
// }
|
||||
// }
|
||||
// replies.insertAll(0, res['data'].topReplies);
|
||||
// res['data'].replies = replies;
|
||||
replyList.value = replies;
|
||||
} else {
|
||||
// 每次回复之后,翻页请求有且只有相同的一条回复数据
|
||||
|
@ -54,7 +54,8 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
() {
|
||||
if (scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent - 300) {
|
||||
EasyThrottle.throttle('replylist', const Duration(seconds: 2), () {
|
||||
EasyThrottle.throttle('replylist', const Duration(milliseconds: 200),
|
||||
() {
|
||||
_videoReplyReplyController.queryReplyList(type: 'onLoad');
|
||||
});
|
||||
}
|
||||
|
40
lib/services/disable_battery_opt.dart
Normal file
40
lib/services/disable_battery_opt.dart
Normal file
@ -0,0 +1,40 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:disable_battery_optimization/disable_battery_optimization.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
void DisableBatteryOpt() async {
|
||||
if (!Platform.isAndroid) {
|
||||
return;
|
||||
}
|
||||
// 本地缓存中读取 是否禁用了电池优化 默认未禁用
|
||||
bool isDisableBatteryOptLocal =
|
||||
GStrorage.localCache.get('isDisableBatteryOptLocal', defaultValue: false);
|
||||
if (!isDisableBatteryOptLocal) {
|
||||
final isBatteryOptimizationDisabled =
|
||||
await DisableBatteryOptimization.isBatteryOptimizationDisabled;
|
||||
if (isBatteryOptimizationDisabled == false) {
|
||||
final hasDisabled = await DisableBatteryOptimization
|
||||
.showDisableBatteryOptimizationSettings();
|
||||
// 设置为已禁用
|
||||
GStrorage.localCache.put('isDisableBatteryOptLocal', hasDisabled == true);
|
||||
}
|
||||
}
|
||||
|
||||
bool isManufacturerBatteryOptimizationDisabled = GStrorage.localCache
|
||||
.get('isManufacturerBatteryOptimizationDisabled', defaultValue: false);
|
||||
if (!isManufacturerBatteryOptimizationDisabled) {
|
||||
final isManBatteryOptimizationDisabled = await DisableBatteryOptimization
|
||||
.isManufacturerBatteryOptimizationDisabled;
|
||||
if (isManBatteryOptimizationDisabled == false) {
|
||||
final hasDisabled = await DisableBatteryOptimization
|
||||
.showDisableManufacturerBatteryOptimizationSettings(
|
||||
"当前设备可能有额外的电池优化",
|
||||
"按照步骤操作以禁用电池优化,以保证应用在后台正常运行",
|
||||
);
|
||||
// 设置为已禁用
|
||||
GStrorage.localCache.put(
|
||||
'isManufacturerBatteryOptimizationDisabled', hasDisabled == true);
|
||||
}
|
||||
}
|
||||
}
|
@ -170,6 +170,10 @@ class LocalCacheKey {
|
||||
// 代理host port
|
||||
systemProxyHost = 'systemProxyHost',
|
||||
systemProxyPort = 'systemProxyPort';
|
||||
|
||||
static const String isDisableBatteryOptLocal = 'isDisableBatteryOptLocal',
|
||||
isManufacturerBatteryOptimizationDisabled =
|
||||
'isManufacturerBatteryOptimizationDisabled';
|
||||
}
|
||||
|
||||
class VideoBoxKey {
|
||||
|
@ -393,6 +393,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
disable_battery_optimization:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: disable_battery_optimization
|
||||
sha256: "6b2ba802f984af141faf1b6b5fb956d5ef01f9cd555597c35b9cc335a03185ba"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
dismissible_page:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -140,6 +140,8 @@ dependencies:
|
||||
catcher_2: ^1.1.0
|
||||
logger: ^2.0.2+1
|
||||
path: 1.8.3
|
||||
# 电池优化
|
||||
disable_battery_optimization: ^1.1.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Reference in New Issue
Block a user