提交 a2276832 编写于 作者: 杜庆泉's avatar 杜庆泉

内存监控android 按照 3.7.7语法修改

上级 bbec54cb
import { UTSAndroid } from "io.dcloud.uts"
import { OffMemoryWarning, OnMemoryWarning, OnMemoryWarningCallback, OnMemoryWarningCallbackResult } from "../interface.uts"
let listeners: UTSCallback[] = []
const onAppTrimMemoryListener = (res: number) => {
let listeners: OnMemoryWarningCallback[] = []
const onAppTrimMemoryListener = (ret: number) => {
listeners.forEach(listener => {
let res:OnMemoryWarningCallbackResult = {
level:ret
}
listener(res)
})
}
@Suppress("DEPRECATION")
export function onMemoryWarning(callback: (res: number) => void) {
export function onMemoryWarning(callback: OnMemoryWarningCallback) {
if (listeners.length == 0) {
// 仅首次执行底层的实际监听
UTSAndroid.onAppTrimMemory(onAppTrimMemoryListener)
......@@ -23,7 +28,7 @@ export function onMemoryWarning(callback: (res: number) => void) {
}
@Suppress("DEPRECATION")
export function offMemoryWarning(callback: UTSCallback | null = null) {
export function offMemoryWarning(callback: OnMemoryWarningCallback | null = null) {
if(callback == null){
// 清除全部回调
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册