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 { Action, UiStateMode } from '../redux/actions/Action' 17import { CameraService } from '../camera/CameraService' 18import EventBusManager from '../worker/eventbus/EventBusManager' 19import { WorkerManager } from '../worker/WorkerManager' 20 21export abstract class BaseFunction { 22 protected mCameraService: CameraService = CameraService.getInstance() 23 protected mWorkerManager: WorkerManager = new WorkerManager() 24 protected mEventBus = EventBusManager.getInstance().getEventBus() 25 26 protected enableUi() { 27 this.mWorkerManager.postMessage(Action.uiState(true)) 28 } 29 30 protected disableUi() { 31 this.mWorkerManager.postMessage(Action.uiState(false)) 32 } 33 34 protected enableUiWithMode(uiStateMode: UiStateMode) { 35 this.mWorkerManager.postMessage(Action.uiStateWithMode(true, uiStateMode)) 36 } 37 38 protected disableUiWithMode(uiStateMode: UiStateMode) { 39 this.mWorkerManager.postMessage(Action.uiStateWithMode(false, uiStateMode)) 40 } 41 42 abstract load(): void 43 44 abstract unload(): void 45}