提交 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';
import WindowManager from 'android.view.WindowManager';
import ActionMode from 'android.view.ActionMode';
// export let onCallBackChange: (event: string) => void = (res) => {};
// #ifdef UNI-APP-X
let callback : (eventLog : string) => void = (res) => { };
let callbackIds : string[] = [];
export function onCallbackChange(fn : (eventLog : string) => void) {
callback = fn
}
export function registerCallbacks() {
let reg1 = UTSAndroid.registerActivityCallback(new UTSAcvitiyLifeCycleCallback())
let reg2 = UTSAndroid.registerActivityCallback(new UTSActivityWindowCallback())
let reg3 = UTSAndroid.registerActivityCallback(new UTSAcvitiyKeyEventCallback())
......@@ -22,6 +24,7 @@ export function registerCallbacks() {
callbackIds.push(reg3)
callbackIds.push(reg4)
callbackIds.push(reg5)
}
export function unRegisterCallbacks() {
......@@ -31,7 +34,7 @@ export function unRegisterCallbacks() {
})
}
export class UTSAcvitiyLifeCycleCallback extends UniActivityLifeCycleCallback {
constructor() {
super()
......@@ -157,4 +160,5 @@ export class UTSActivityComponentCallback extends UniActivityComponentCallback {
console.log('UTSActivityComponentCallback', 'onPreConfigurationChanged', params, '' + newConfig)
callback('onPreConfigurationChanged')
}
}
\ No newline at end of file
}
// #endif
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册