提交 065a0f9b 编写于 作者: WOSHIMAHAIFENG's avatar WOSHIMAHAIFENG

Merge branch 'dev-privacy' into 'dev'

[activity-callback]修改示例

See merge request !3
......@@ -94,7 +94,9 @@ import {
UTSActivityWindowCallback,
UTSActivityCallback,
UTSActivityComponentCallback,
onCallbackChange
onCallbackChange,
registerCallbacks,
unRegisterCallbacks
} from '@/uni_modules/uts-syntaxcase/utssdk/app-android/index.uts'
// #endif
......@@ -321,22 +323,10 @@ export default {
let nextLineFlag = that.cbText + '\n'
that.cbText = nextLineFlag
})
let reg1= UTSAndroid.registerActivityCallback( new UTSAcvitiyLifeCycleCallback())
let reg2=UTSAndroid.registerActivityCallback(new UTSActivityWindowCallback())
let reg3=UTSAndroid.registerActivityCallback(new UTSAcvitiyKeyEventCallback())
let reg4= UTSAndroid.registerActivityCallback(new UTSActivityCallback())
let reg5= UTSAndroid.registerActivityCallback(new UTSActivityComponentCallback())
this.callbackIds.push(reg1)
this.callbackIds.push(reg2)
this.callbackIds.push(reg3)
this.callbackIds.push(reg4)
this.callbackIds.push(reg5)
registerCallbacks()
},
unRegActivityCallback(){
this.callbackIds.forEach((value)=>{
console.log(value)
UTSAndroid.unRegisterActivityCallback(value)
})
unRegisterCallbacks()
}
// #endif
......
......@@ -6,11 +6,30 @@ 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) => {};
let callback : (eventLog : string) => void= (res) => {};
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())
let reg4 = UTSAndroid.registerActivityCallback(new UTSActivityCallback())
let reg5 = UTSAndroid.registerActivityCallback(new UTSActivityComponentCallback())
callbackIds.push(reg1)
callbackIds.push(reg2)
callbackIds.push(reg3)
callbackIds.push(reg4)
callbackIds.push(reg5)
}
export function unRegisterCallbacks() {
callbackIds.forEach((value) => {
console.log(value)
UTSAndroid.unRegisterActivityCallback(value)
})
}
export class UTSAcvitiyLifeCycleCallback extends UniActivityLifeCycleCallback {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册