|
@@ -5,12 +5,15 @@ import 'package:electronic_assistant/resource/string.gen.dart';
|
|
|
import 'package:electronic_assistant/utils/audio_picker_utils.dart';
|
|
import 'package:electronic_assistant/utils/audio_picker_utils.dart';
|
|
|
import 'package:electronic_assistant/utils/file_upload_check_helper.dart';
|
|
import 'package:electronic_assistant/utils/file_upload_check_helper.dart';
|
|
|
import 'package:electronic_assistant/utils/toast_util.dart';
|
|
import 'package:electronic_assistant/utils/toast_util.dart';
|
|
|
|
|
+import 'package:flutter/cupertino.dart';
|
|
|
import 'package:get/get.dart';
|
|
import 'package:get/get.dart';
|
|
|
import 'package:photo_manager/photo_manager.dart';
|
|
import 'package:photo_manager/photo_manager.dart';
|
|
|
|
|
+import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
import 'package:uuid/uuid.dart';
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
|
|
|
|
import '../../data/bean/talks.dart';
|
|
import '../../data/bean/talks.dart';
|
|
|
import '../../data/repositories/talk_repository.dart';
|
|
import '../../data/repositories/talk_repository.dart';
|
|
|
|
|
+import '../../utils/error_handler.dart';
|
|
|
import '../talk/view.dart';
|
|
import '../talk/view.dart';
|
|
|
|
|
|
|
|
class AudioPickerController extends BaseController {
|
|
class AudioPickerController extends BaseController {
|
|
@@ -20,6 +23,11 @@ class AudioPickerController extends BaseController {
|
|
|
final _currentEntity = Rxn<AssetEntity?>();
|
|
final _currentEntity = Rxn<AssetEntity?>();
|
|
|
|
|
|
|
|
AssetEntity? get currentEntity => _currentEntity.value;
|
|
AssetEntity? get currentEntity => _currentEntity.value;
|
|
|
|
|
+ final refreshController = RefreshController(initialRefresh: false);
|
|
|
|
|
+
|
|
|
|
|
+ int limit = 20;
|
|
|
|
|
+
|
|
|
|
|
+ int totalCount = 0;
|
|
|
|
|
|
|
|
@override
|
|
@override
|
|
|
void onReady() async {
|
|
void onReady() async {
|
|
@@ -32,15 +40,31 @@ class AudioPickerController extends BaseController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
currentPath = await initPathEntity();
|
|
currentPath = await initPathEntity();
|
|
|
- requestList();
|
|
|
|
|
|
|
+ totalCount = await currentPath?.assetCountAsync ?? 0;
|
|
|
|
|
+ requestList(0, limit, isClearAll: true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void requestList() {
|
|
|
|
|
|
|
+ void requestList(int offset, int limit, {bool? isClearAll = false}) {
|
|
|
if (currentPath == null) {
|
|
if (currentPath == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- AudioPickerUtils.getAssetList(currentPath!, 0).then((value) {
|
|
|
|
|
- audioList.addAll(value);
|
|
|
|
|
|
|
+ AudioPickerUtils.getAssetListRange(currentPath!, offset, limit)
|
|
|
|
|
+ .then((list) {
|
|
|
|
|
+ if (isClearAll == true) {
|
|
|
|
|
+ audioList.clear();
|
|
|
|
|
+ }
|
|
|
|
|
+ audioList.addAll(list);
|
|
|
|
|
+ if (audioList.length >= totalCount) {
|
|
|
|
|
+ debugPrint("getAssetListRange-没有更多数据了");
|
|
|
|
|
+ refreshController.loadNoData();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ refreshController.loadComplete();
|
|
|
|
|
+ }
|
|
|
|
|
+ refreshController.refreshCompleted();
|
|
|
|
|
+ }).catchError((error) {
|
|
|
|
|
+ debugPrint("requestTalkData-catchError-$error");
|
|
|
|
|
+ refreshController.loadFailed();
|
|
|
|
|
+ refreshController.refreshFailed();
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -81,4 +105,8 @@ class AudioPickerController extends BaseController {
|
|
|
ToastUtil.showToast(e.toString());
|
|
ToastUtil.showToast(e.toString());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ void onLoadMoreData() {
|
|
|
|
|
+ requestList(audioList.length, limit);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|