diff --git a/uni_modules/uni-memorywarning/utssdk/app-android/index.uts b/uni_modules/uni-memorywarning/utssdk/app-android/index.uts index b364d0431a189b41ce5eb855e5d4a475b8b54889..ddc8859d2418900a4156a54d0375875a2b522930 100644 --- a/uni_modules/uni-memorywarning/utssdk/app-android/index.uts +++ b/uni_modules/uni-memorywarning/utssdk/app-android/index.uts @@ -1,16 +1,21 @@ 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){ // 清除全部回调