提交 8a4262b6 编写于 作者: WOSHIMAHAIFENG's avatar WOSHIMAHAIFENG

Merge branch 'dev-activitycb' into 'dev'

[activity-callback]更新示例

See merge request !4
...@@ -6,12 +6,14 @@ import KeyboardShortcutGroup from 'android.view.KeyboardShortcutGroup'; ...@@ -6,12 +6,14 @@ import KeyboardShortcutGroup from 'android.view.KeyboardShortcutGroup';
import WindowManager from 'android.view.WindowManager'; import WindowManager from 'android.view.WindowManager';
import ActionMode from 'android.view.ActionMode'; import ActionMode from 'android.view.ActionMode';
// export let onCallBackChange: (event: string) => void = (res) => {}; // export let onCallBackChange: (event: string) => void = (res) => {};
// #ifdef UNI-APP-X
let callback : (eventLog : string) => void = (res) => { }; let callback : (eventLog : string) => void = (res) => { };
let callbackIds : string[] = []; let callbackIds : string[] = [];
export function onCallbackChange(fn : (eventLog : string) => void) { export function onCallbackChange(fn : (eventLog : string) => void) {
callback = fn callback = fn
} }
export function registerCallbacks() { export function registerCallbacks() {
let reg1 = UTSAndroid.registerActivityCallback(new UTSAcvitiyLifeCycleCallback()) let reg1 = UTSAndroid.registerActivityCallback(new UTSAcvitiyLifeCycleCallback())
let reg2 = UTSAndroid.registerActivityCallback(new UTSActivityWindowCallback()) let reg2 = UTSAndroid.registerActivityCallback(new UTSActivityWindowCallback())
let reg3 = UTSAndroid.registerActivityCallback(new UTSAcvitiyKeyEventCallback()) let reg3 = UTSAndroid.registerActivityCallback(new UTSAcvitiyKeyEventCallback())
...@@ -22,6 +24,7 @@ export function registerCallbacks() { ...@@ -22,6 +24,7 @@ export function registerCallbacks() {
callbackIds.push(reg3) callbackIds.push(reg3)
callbackIds.push(reg4) callbackIds.push(reg4)
callbackIds.push(reg5) callbackIds.push(reg5)
} }
export function unRegisterCallbacks() { export function unRegisterCallbacks() {
...@@ -158,3 +161,4 @@ export class UTSActivityComponentCallback extends UniActivityComponentCallback { ...@@ -158,3 +161,4 @@ export class UTSActivityComponentCallback extends UniActivityComponentCallback {
callback('onPreConfigurationChanged') callback('onPreConfigurationChanged')
} }
} }
// #endif
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册