• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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
16import { MediaItem } from '../../model/browser/photo/MediaItem';
17import { SelectManager } from '../../model/browser/SelectManager';
18import { BroadCast } from '../../utils/BroadCast';
19import { AlbumSetDataSource } from '../../model/browser/album/AlbumSetDataSource';
20import { AlbumInfo } from '../../model/browser/album/AlbumInfo';
21
22export enum SourceSceneType {
23  INVALID,
24  SYSTEM_ALBUM,
25  USER_ALBUM,
26  PICKER,
27  BIG_PHOTO_COMPONENT
28}
29
30export class MenuContext {
31  mediaItem: MediaItem;
32  albumUri: string;
33  selectManager: SelectManager;
34  onOperationStart: Function;
35  onOperationCancel: Function;
36  onOperationEnd: Function;
37  broadCast: BroadCast
38  latlng: number[];
39  jumpSourceToMain: number;
40  albumSetDataSource: AlbumSetDataSource;
41  deviceId: string;
42  albumInfo: AlbumInfo;
43  fromSelectMode: boolean;
44  targetAlbumName: string;
45  sourceScene: SourceSceneType = SourceSceneType.INVALID;
46
47  withMediaItem(mediaItem: MediaItem): MenuContext {
48    this.mediaItem = mediaItem;
49    return this;
50  }
51
52  withAlbumUri(albumUri: string): MenuContext {
53    this.albumUri = albumUri;
54    return this;
55  }
56
57  withSelectManager(selectManager: SelectManager): MenuContext {
58    this.selectManager = selectManager;
59    return this;
60  }
61
62  withOperationStartCallback(onOperationStart: Function): MenuContext {
63    this.onOperationStart = onOperationStart;
64    return this;
65  }
66
67  withOperationCancelCallback(onOperationCancel: Function): MenuContext {
68    this.onOperationCancel = onOperationCancel;
69    return this;
70  }
71
72  withOperationEndCallback(onOperationEnd: Function): MenuContext {
73    this.onOperationEnd = onOperationEnd;
74    return this;
75  }
76
77  withBroadCast(param: BroadCast): MenuContext {
78    this.broadCast = param;
79    return this;
80  }
81
82  withLatlng(latlng: number[]): MenuContext {
83    this.latlng = latlng;
84    return this;
85  }
86
87  withJumpSourceToMain(jumpSourceToMain: number): MenuContext {
88    this.jumpSourceToMain = jumpSourceToMain;
89    return this;
90  }
91
92  withAlbumSetDataSource(albumSetDataSource: AlbumSetDataSource | null): MenuContext {
93    this.albumSetDataSource = albumSetDataSource;
94    return this;
95  }
96
97  withRemoteDevice(deviceId) {
98    this.deviceId = deviceId;
99    return this;
100  }
101
102  withAlbumInfo(albumInfo: AlbumInfo | null | undefined): MenuContext {
103    this.albumInfo = albumInfo;
104    return this;
105  }
106
107  withTargetAlbumName(albumName) {
108    this.targetAlbumName = albumName;
109    return this;
110  }
111
112  withFromSelectMode(fromSelectMode) {
113    this.fromSelectMode = fromSelectMode;
114    return this;
115  }
116}