• 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 */
15
16import UIAbility from '@ohos.app.ability.UIAbility'
17import window from '@ohos.window'
18import Logger from '../../../../../WindowComponent/src/main/ets/components/util/Logger'
19import WindowManger from "../../../../../WindowComponent/src/main/ets/components/feature/WindowManger"
20
21export default class MainAbility extends UIAbility {
22  private TAG: string = 'WindowManger'
23  private subWindow: window.WindowStage
24
25  onCreate(want) {
26    const that = this
27    this.context.eventHub.on("createWindow", (data) => {
28      data.context = that.context
29      data.launchWant = want
30      data.subWindow = that.subWindow
31    })
32  }
33
34  onDestroy() {
35    Logger.info(this.TAG, 'MainAbility onDestroy')
36  }
37
38  onWindowStageCreate(windowStage) {
39    this.subWindow = windowStage
40    WindowManger.initMainWindow(windowStage)
41    windowStage.loadContent("pages/Index")
42  }
43
44  onWindowStageDestroy() {
45    // Main window is destroyed, release UI related resources
46    Logger.info(this.TAG, 'MainAbility onWindowStageDestroy')
47  }
48
49  onForeground() {
50    // Ability has brought to foreground
51    Logger.info(this.TAG, 'MainAbility onForeground')
52  }
53
54  onBackground() {
55    // Ability has back to background
56    Logger.info(this.TAG, 'MainAbility onBackground')
57  }
58}
59