diff --git a/lib/models_new/download/bili_download_entry_info.dart b/lib/models_new/download/bili_download_entry_info.dart index 7de508775..8de884abe 100644 --- a/lib/models_new/download/bili_download_entry_info.dart +++ b/lib/models_new/download/bili_download_entry_info.dart @@ -36,7 +36,7 @@ class BiliDownloadEntryInfo with MultiSelectData { late String pageDirPath; late String entryDirPath; - DownloadStatus status = .wait; + late DownloadStatus status = .wait; int get cid => source?.cid ?? pageData!.cid; diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index d0e31073e..cd0c8f412 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -115,8 +115,8 @@ class _LiveRoomPageState extends State } await _liveRoomController.playerInit(autoplay: shouldPlay); } + if (!mounted) return; plPlayerController.addStatusLister(playerListener); - super.didPopNext(); } diff --git a/lib/pages/save_panel/view.dart b/lib/pages/save_panel/view.dart index 874ef5f44..86ecf1900 100644 --- a/lib/pages/save_panel/view.dart +++ b/lib/pages/save_panel/view.dart @@ -290,10 +290,10 @@ class _SavePanelState extends State { } Future _onSaveOrSharePic([bool isShare = false]) async { - if (!isShare && PlatformUtils.isMobile) { - if (mounted && !await ImageUtils.checkPermissionDependOnSdkInt()) { - return; - } + if (!isShare && + PlatformUtils.isMobile && + !await ImageUtils.checkPermissionDependOnSdkInt()) { + return; } SmartDialog.showLoading(); try { diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index c156984f5..0733bb4f4 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -313,6 +313,7 @@ class _VideoDetailPageVState extends State } else { await videoDetailController.playerInit(autoplay: true); } + if (!mounted || !isShowing) return; plPlayerController! ..addStatusLister(playerListener) ..addPositionListener(positionListener); @@ -370,7 +371,7 @@ class _VideoDetailPageVState extends State @override // 离开当前页面时 - Future didPushNext() async { + void didPushNext() { if (Get.routing.route is HeroDialogRoute) { videoDetailController.imageview = true; return; @@ -453,7 +454,7 @@ class _VideoDetailPageVState extends State videoDetailController.videoState.value is! Error) { await videoDetailController.playerInit(); } - + if (!mounted || !isShowing) return; plPlayerController ?..addStatusLister(playerListener) ..addPositionListener(positionListener); diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index cb89f11c2..c1206c0bc 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -1582,12 +1582,19 @@ class PlPlayerController { } } - void addPositionListener(Function(Duration position) listener) => - _positionListeners.add(listener); + void addPositionListener(Function(Duration position) listener) { + if (_playerCount == 0) return; + _positionListeners.add(listener); + } + void removePositionListener(Function(Duration position) listener) => _positionListeners.remove(listener); - void addStatusLister(Function(PlayerStatus status) listener) => - _statusListeners.add(listener); + + void addStatusLister(Function(PlayerStatus status) listener) { + if (_playerCount == 0) return; + _statusListeners.add(listener); + } + void removeStatusLister(Function(PlayerStatus status) listener) => _statusListeners.remove(listener); diff --git a/lib/utils/image_utils.dart b/lib/utils/image_utils.dart index c11b20940..ac796db58 100644 --- a/lib/utils/image_utils.dart +++ b/lib/utils/image_utils.dart @@ -128,7 +128,7 @@ abstract final class ImageUtils { }, ); if (success) { - SmartDialog.showToast(' Live Photo 已保存 '); + SmartDialog.showToast(' 已保存 '); } else { SmartDialog.showToast('保存失败'); return false; @@ -198,6 +198,7 @@ abstract final class ImageUtils { } }); final result = await Future.wait(futures, eagerError: true); + bool success = true; if (PlatformUtils.isMobile) { final delList = []; final saveList = []; @@ -211,6 +212,8 @@ abstract final class ImageUtils { androidRelativePath: _androidRelativePath, ), ); + } else { + success = false; } } await SaverGallery.saveFiles(saveList, skipIfExists: false); @@ -225,6 +228,8 @@ abstract final class ImageUtils { fileName: res.name, del: res.del, ); + } else { + success = false; } } } @@ -232,9 +237,9 @@ abstract final class ImageUtils { SmartDialog.showToast('已取消下载'); return false; } else { - SmartDialog.showToast('图片已保存'); + SmartDialog.showToast(success ? ' 已保存 ' : '保存失败'); } - return true; + return success; } catch (e) { if (cancelToken?.isCancelled == true) { SmartDialog.showToast('已取消下载');