From 532ffe2a972a918f49f7b66291eb276c070bdf26 Mon Sep 17 00:00:00 2001 From: dujing Date: Sat, 23 Nov 2024 11:03:57 +0800 Subject: [PATCH] Fix the issue where album assets cannot be retrieved when selecting only and video or only and image conditions Signed-off-by: dujing --- .../plugin/handlers/AlbumHandler.ets | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/ohos/src/main/ets/components/plugin/handlers/AlbumHandler.ets b/ohos/src/main/ets/components/plugin/handlers/AlbumHandler.ets index 9426a989..06140b01 100644 --- a/ohos/src/main/ets/components/plugin/handlers/AlbumHandler.ets +++ b/ohos/src/main/ets/components/plugin/handlers/AlbumHandler.ets @@ -156,21 +156,18 @@ export class AlbumHandler extends HandlerBase implements MethodCallHandlerBase { if (!(await PermissionHandler.permissionReadCheck())) { return []; } - if (onlyAll) { - return [await AlbumHandler.getAllAlbum(RequestType.all)]; - } - let requestType: RequestType = new RequestType(args.get('type')); - - if (!(requestType.containsImage() && requestType.containsVideo())) { - if (requestType.containsImage()) { - return [await AlbumHandler.getAllAlbum(RequestType.image)]; - } - else if (requestType.containsVideo()) { - return [await AlbumHandler.getAllAlbum(RequestType.video)]; + if (onlyAll || !(requestType.containsImage() && requestType.containsVideo())) { + if (!(requestType.containsImage() && requestType.containsVideo())) { + if (requestType.containsImage()) { + return [await AlbumHandler.getAllAlbum(RequestType.image)]; + } else if (requestType.containsVideo()) { + return [await AlbumHandler.getAllAlbum(RequestType.video)]; + } + } else { + return [await AlbumHandler.getAllAlbum(RequestType.all)]; } } - // hasAll 返回的列表里有一个代表所有的相册 // onlyAll 只返回这个代表所有的相册 // 在鸿蒙这边 这个相册 应该是 从 system 这个类型里面获取到的相册的集合