• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2021-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 { ShortcutInfo } from 'bundle/shortcutInfo';
17import { AppListViewModel } from './AppListViewModel';
18
19const TAG = 'AppGridViewModel';
20
21/**
22 * AppGridViewModel
23 */
24export class AppGridViewModel extends AppListViewModel {
25  private constructor() {
26    super();
27  }
28
29  /**
30   * get instance
31   */
32  static getInstance(): AppGridViewModel {
33    if (globalThis.AppGridViewModel == null) {
34      globalThis.AppGridViewModel = new AppGridViewModel();
35    }
36    return globalThis.AppGridViewModel;
37  }
38
39  /**
40   * Register to listen to events
41   */
42  registerAppListChange() {
43    this.registerAppListChangeCallback();
44  }
45
46  /**
47   * Unregister listener events
48   */
49  unregisterAppListChange() {
50    this.unregisterAppListChangeCallback();
51  }
52
53  registerEventListener() {
54    this.onAppListViewCreate();
55  }
56
57  unregisterEventListener() {
58    this.onAppListViewDestroy();
59  }
60
61  /**
62   * Get shortcut information by bundleName
63   */
64  getShortcutInfo(bundleName: string): ShortcutInfo[] | undefined {
65    return this.mAppModel.getShortcutInfo(bundleName);
66  }
67}