提交 e0056cf8 编写于 作者: DCloud_iOS_XHY's avatar DCloud_iOS_XHY

Merge branch 'dev' of gitcode.net:dcloud/uni-api into dev

* 'dev' of gitcode.net:dcloud/uni-api:
  内存警告先还原会 utscallback 写法
import { UTSAndroid } from "io.dcloud.uts" import { UTSAndroid } from "io.dcloud.uts"
import { OffMemoryWarning, OnMemoryWarning, OnMemoryWarningCallback, OnMemoryWarningCallbackResult } from "../interface.uts"
let listeners: OnMemoryWarningCallback[] = [] let listeners: UTSCallback[] = []
const onAppTrimMemoryListener = (ret: number) => { const onAppTrimMemoryListener = (ret: number) => {
listeners.forEach(listener => { listeners.forEach(listener => {
let res:OnMemoryWarningCallbackResult = { let res = {
level:ret level:ret
} }
listener(res) listener(res)
...@@ -15,7 +14,7 @@ const onAppTrimMemoryListener = (ret: number) => { ...@@ -15,7 +14,7 @@ const onAppTrimMemoryListener = (ret: number) => {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
export function onMemoryWarning(callback: OnMemoryWarningCallback) { export function onMemoryWarning(callback: UTSCallback) {
if (listeners.length == 0) { if (listeners.length == 0) {
// 仅首次执行底层的实际监听 // 仅首次执行底层的实际监听
UTSAndroid.onAppTrimMemory(onAppTrimMemoryListener) UTSAndroid.onAppTrimMemory(onAppTrimMemoryListener)
...@@ -28,7 +27,7 @@ export function onMemoryWarning(callback: OnMemoryWarningCallback) { ...@@ -28,7 +27,7 @@ export function onMemoryWarning(callback: OnMemoryWarningCallback) {
} }
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
export function offMemoryWarning(callback: OnMemoryWarningCallback | null = null) { export function offMemoryWarning(callback: UTSCallback | null = null) {
if(callback == null){ if(callback == null){
// 清除全部回调 // 清除全部回调
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册