1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_MEDIALIBRARY_SYSTEM_ALBUM_INFO_CALCULATION_H 17 #define OHOS_MEDIALIBRARY_SYSTEM_ALBUM_INFO_CALCULATION_H 18 19 #include <functional> 20 #include <map> 21 #include <vector> 22 23 #include "photo_asset_change_info.h" 24 #include "album_change_info.h" 25 26 namespace OHOS { 27 namespace Media::AccurateRefresh { 28 29 class SystemAlbumInfoCalculation { 30 public: SystemAlbumInfoCalculation(std::function<bool (const PhotoAssetChangeInfo &)> isSystemAsset,std::function<bool (const PhotoAssetChangeInfo &)> isVideoAsset,std::function<bool (const PhotoAssetChangeInfo &)> isHiddenSystemAsset,std::function<bool (const PhotoAssetChangeInfo &,const PhotoAssetChangeInfo &)> isNewerAsset,std::function<bool (const PhotoAssetChangeInfo &,const PhotoAssetChangeInfo &)> isNewerHiddenAsset_,int32_t subType)31 SystemAlbumInfoCalculation(std::function<bool(const PhotoAssetChangeInfo&)> isSystemAsset, 32 std::function<bool(const PhotoAssetChangeInfo&)> isVideoAsset, 33 std::function<bool(const PhotoAssetChangeInfo&)> isHiddenSystemAsset, 34 std::function<bool(const PhotoAssetChangeInfo&, const PhotoAssetChangeInfo&)> isNewerAsset, 35 std::function<bool(const PhotoAssetChangeInfo&, const PhotoAssetChangeInfo&)> isNewerHiddenAsset_, 36 int32_t subType) :isSystemAsset_(isSystemAsset), isVideoAsset_(isVideoAsset), 37 isHiddenSystemAsset_(isHiddenSystemAsset), isNewerAsset_(isNewerAsset), 38 isNewerHiddenAsset_(isNewerHiddenAsset_), subType_(subType) { } 39 bool CalAlbumRefreshInfo(const PhotoAssetChangeData &assetChangeData, AlbumRefreshInfo &refreshInfo, 40 int32_t albumId); 41 42 private: 43 bool UpdateCover(const PhotoAssetChangeData &assetChangeData, 44 std::function<bool(const PhotoAssetChangeInfo&)> isSystemAsset, 45 std::function<bool(const PhotoAssetChangeInfo&, const PhotoAssetChangeInfo&)> isNewerAsset, 46 PhotoAssetChangeInfo &addCover, std::unordered_set<int32_t> &removeFileIds); 47 bool UpdateCount(const PhotoAssetChangeData &assetChangeData, 48 std::function<bool(PhotoAssetChangeInfo)> isSystemAsset, int32_t &count); 49 bool UpdateRefreshNormalInfo(const PhotoAssetChangeData &assetChangeData, AlbumRefreshInfo& refreshInfo); 50 bool UpdateRefreshHiddenInfo(const PhotoAssetChangeData &assetChangeData, AlbumRefreshInfo& refreshInfo); 51 bool IsSystemAlbumInfoChange(const PhotoAssetChangeData &assetChangeData, 52 std::function<bool(PhotoAssetChangeInfo)> isAlbumAsset); 53 54 public: 55 std::function<bool(const PhotoAssetChangeInfo&)> isSystemAsset_; 56 std::function<bool(const PhotoAssetChangeInfo&)> isVideoAsset_; 57 std::function<bool(const PhotoAssetChangeInfo&)> isHiddenSystemAsset_; 58 std::function<bool(const PhotoAssetChangeInfo&, const PhotoAssetChangeInfo&)> isNewerAsset_; 59 std::function<bool(const PhotoAssetChangeInfo&, const PhotoAssetChangeInfo&)> isNewerHiddenAsset_; 60 int32_t subType_; 61 }; 62 63 } // namespace Media 64 } // namespace OHOS 65 66 #endif