• 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 { HiLog } from '../../../../../common/src/main/ets/util/HiLog';
17import ContactListPresenter from './contact/ContactListPresenter';
18import CallRecordPresenter from './dialer/callRecord/CallRecordPresenter';
19import WorkerWrapper from "../workers/base/WorkerWrapper";
20
21const TAG = 'PageManager'
22
23export default class PresenterManager {
24  static MAIN_PAGE: string = 'pages/index'
25  context: Context;
26  worker: WorkerWrapper;
27  callRecordPresenter: CallRecordPresenter = CallRecordPresenter.getInstance();
28  contactListPresenter: ContactListPresenter = ContactListPresenter.getInstance();
29
30  constructor(context: Context, worker: WorkerWrapper) {
31    this.context = context;
32    this.worker = worker;
33  }
34
35  onCreate() {
36    HiLog.i(TAG, "onCreate")
37    this.callRecordPresenter.onCreate(this.context, this.worker);
38    this.contactListPresenter.onCreate(this.context, this.worker);
39    if (globalThis.config.needCache) {
40      this.initDataCache();
41    }
42  }
43
44  initDataCache() {
45    CallRecordPresenter.getInstance().cachePageOne();
46    ContactListPresenter.getInstance().cachePageOne();
47  }
48
49  onDestroy() {
50    HiLog.i(TAG, "onDestroy")
51    this.callRecordPresenter.onDestroy();
52    this.contactListPresenter.onDestroy();
53  }
54}