• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2023 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 */
15import image from '@ohos.multimedia.image';
16import media from '@ohos.multimedia.media';
17import { Album, UserFileManagerAccess } from '../../../access/UserFileManagerAccess';
18
19import type { MediaItem } from '../photo/MediaItem';
20
21export class AlbumInfo {
22  uri: string;
23  coverUri: string;
24  albumName: string;
25  count: number;
26  isSystemAlbum: boolean;
27  isTrashAlbum: boolean;
28  isFavorAlbum: boolean;
29  isVideoAlbum: boolean;
30  isScreenShotAlbum: boolean;
31  isPhotoAlbum: boolean;
32  filterMediaType: string;
33  dateModified: number;
34  videoCount: number;
35  mediaItem: MediaItem;
36  deviceName: string;
37  deviceId: string;
38
39  constructor(album?: Album) {
40    if (album) {
41      this.uri = album.albumUri;
42      this.coverUri = album.coverUri;
43      this.isSystemAlbum = UserFileManagerAccess.getInstance().isSystemAlbum(album);
44      this.isTrashAlbum = UserFileManagerAccess.getInstance().isTrashAlbum(album);
45      this.isFavorAlbum = UserFileManagerAccess.getInstance().isFavorAlbum(album);
46      this.isVideoAlbum = UserFileManagerAccess.getInstance().isVideoAlbum(album);
47      this.isScreenShotAlbum = UserFileManagerAccess.getInstance().isScreenShotAlbum(album);
48      this.isPhotoAlbum = UserFileManagerAccess.getInstance().isPhotoAlbum(album);
49      this.count = album.count; // TODO 相册count都是0
50      this.dateModified = album.dateModified;
51    }
52  }
53
54  setMediaItem(mediaItem: MediaItem) {
55    this.mediaItem = mediaItem;
56  }
57
58  setAlbumName(albumName: string): void {
59    this.albumName = albumName;
60  }
61
62  setCount(count: number): void {
63    this.count = count;
64  }
65
66  setVideoCount(count: number): void {
67    this.videoCount = count;
68  }
69
70  setFilterMediaType(filterMediaType: string): void {
71    this.filterMediaType = filterMediaType;
72  }
73
74  setCoverUri(coverUri: string): void {
75    this.coverUri = coverUri;
76  }
77
78  getHashCode(): string {
79    return `${this.uri}_${this.coverUri}_${this.count}_${this.albumName}`;
80  }
81}
82