• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_OWNER_ALBUM_INFO_CALCULATION_H
17 #define OHOS_MEDIALIBRARY_OWNER_ALBUM_INFO_CALCULATION_H
18 
19 #include <unordered_map>
20 #include "album_change_info.h"
21 #include "photo_asset_change_info.h"
22 
23 namespace OHOS {
24 namespace Media::AccurateRefresh {
25 
26 class OwnerAlbumInfoCalculation {
27 public:
28     static std::unordered_map<int32_t, AlbumRefreshInfo> CalOwnerAlbumRefreshInfo(
29         const std::vector<PhotoAssetChangeData> &assetChangeDatas);
30 
31 private:
32     static bool IsOwnerAlbumAsset(const PhotoAssetChangeInfo &assetInfo, int32_t albumId);
33     static bool IsOwnerAlbumHiddenAsset(const PhotoAssetChangeInfo &assetInfo, int32_t albumId);
34     static bool IsOwnerAlbumVideoAsset(const PhotoAssetChangeInfo &assetInfo, int32_t albumId);
35     static bool IsNewerAsset(const PhotoAssetChangeInfo &compareAssetInfo,
36         const PhotoAssetChangeInfo &currentAssetInfo, int32_t albumId);
37     static bool IsNewerHiddenAsset(const PhotoAssetChangeInfo &compareAssetInfo,
38         const PhotoAssetChangeInfo &currentAssetInfo, int32_t albumId);
39     static bool CalOwnerAlbumRefreshInfo(const PhotoAssetChangeData &assetChangeData, int32_t albumId,
40         AlbumRefreshInfo &refreshInfo);
41     static bool UpdateCover(const PhotoAssetChangeData &assetChangeData,
42         std::function<bool(const PhotoAssetChangeInfo&, int32_t)> isAsset, int32_t albumId,
43         std::function<bool(const PhotoAssetChangeInfo&, const PhotoAssetChangeInfo&, int32_t)> isNewerAsset,
44         PhotoAssetChangeInfo &addCover, std::unordered_set<int32_t> &removeFileIds);
45     static bool UpdateCount(const PhotoAssetChangeData &assetChangeData,
46         std::function<bool(const PhotoAssetChangeInfo&, int32_t)> isAsset, int32_t albumId,
47         int32_t &count);
48     static bool UpdateRefreshNormalInfo(const PhotoAssetChangeData &assetChangeData, int32_t albumId,
49         AlbumRefreshInfo& refreshInfo);
50     static bool UpdateRefreshHiddenInfo(const PhotoAssetChangeData &assetChangeData, int32_t albumId,
51         AlbumRefreshInfo& refreshInfo);
52     static bool IsOwnerAlbumInfoChange(const PhotoAssetChangeData &assetChangeData,
53         std::function<bool(PhotoAssetChangeInfo, int32_t)> isAlbumAsset, int32_t albumId);
54     static void UpdateOwnerRefreshInfo(int32_t albumId, const PhotoAssetChangeData &assetChangeData,
55         std::unordered_map<int32_t, AlbumRefreshInfo> &ownerAlbumInfos);
56 };
57 
58 } // namespace Media
59 } // namespace OHOS
60 
61 #endif