提交 9ec015ca 编写于 作者: M mahaifeng

[activity-callback]更新示例

上级 065a0f9b
...@@ -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() {
...@@ -31,7 +34,7 @@ export function unRegisterCallbacks() { ...@@ -31,7 +34,7 @@ export function unRegisterCallbacks() {
}) })
} }
export class UTSAcvitiyLifeCycleCallback extends UniActivityLifeCycleCallback { export class UTSAcvitiyLifeCycleCallback extends UniActivityLifeCycleCallback {
constructor() { constructor() {
super() super()
...@@ -157,4 +160,5 @@ export class UTSActivityComponentCallback extends UniActivityComponentCallback { ...@@ -157,4 +160,5 @@ export class UTSActivityComponentCallback extends UniActivityComponentCallback {
console.log('UTSActivityComponentCallback', 'onPreConfigurationChanged', params, '' + newConfig) console.log('UTSActivityComponentCallback', 'onPreConfigurationChanged', params, '' + newConfig)
callback('onPreConfigurationChanged') 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.
先完成此消息的编辑!
想要评论请 注册