From 1685eb3a4d0b72fcf36ab3d09076f92709d68ef7 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Thu, 1 Sep 2022 15:51:40 +0800 Subject: [PATCH] lifecycle add --- pages.json | 9 ---- pages/lifecycle/lifecycle.vue | 48 +++++++++++++++++-- pages/resource/resource.vue | 11 ++--- pages/static/static.vue | 10 ---- uni_modules/uts-advance/readme.md | 4 +- .../uts-advance/utssdk/app-android/index.uts | 43 ++++++++++------- .../app-android/res/value-zh/strings.xml | 3 -- .../app-android/res/values-en/strings.xml | 3 -- uni_modules/uts-helloworld/readme.md | 4 +- 9 files changed, 79 insertions(+), 56 deletions(-) delete mode 100644 pages/static/static.vue delete mode 100644 uni_modules/uts-advance/utssdk/app-android/res/value-zh/strings.xml delete mode 100644 uni_modules/uts-advance/utssdk/app-android/res/values-en/strings.xml diff --git a/pages.json b/pages.json index b1533b5..824a514 100644 --- a/pages.json +++ b/pages.json @@ -37,15 +37,6 @@ "enablePullDownRefresh": false } - }, - { - "path" : "pages/static/static", - "style" : - { - "navigationBarTitleText": "", - "enablePullDownRefresh": false - } - }, { "path" : "pages/lifecycle/lifecycle", diff --git a/pages/lifecycle/lifecycle.vue b/pages/lifecycle/lifecycle.vue index 962f0ef..66f9d9d 100644 --- a/pages/lifecycle/lifecycle.vue +++ b/pages/lifecycle/lifecycle.vue @@ -1,7 +1,45 @@ + - \ No newline at end of file + + + diff --git a/pages/resource/resource.vue b/pages/resource/resource.vue index 9f3522f..2855b46 100644 --- a/pages/resource/resource.vue +++ b/pages/resource/resource.vue @@ -3,15 +3,14 @@ - + - diff --git a/pages/static/static.vue b/pages/static/static.vue deleted file mode 100644 index 12d521c..0000000 --- a/pages/static/static.vue +++ /dev/null @@ -1,10 +0,0 @@ - - \ No newline at end of file diff --git a/uni_modules/uts-advance/readme.md b/uni_modules/uts-advance/readme.md index e55e4f8..7f435d9 100644 --- a/uni_modules/uts-advance/readme.md +++ b/uni_modules/uts-advance/readme.md @@ -1 +1,3 @@ -# uts-advance \ No newline at end of file +# uts-advance + +UTS进阶示例插件 \ No newline at end of file diff --git a/uni_modules/uts-advance/utssdk/app-android/index.uts b/uni_modules/uts-advance/utssdk/app-android/index.uts index 1516b87..aab779c 100644 --- a/uni_modules/uts-advance/utssdk/app-android/index.uts +++ b/uni_modules/uts-advance/utssdk/app-android/index.uts @@ -10,13 +10,18 @@ import Runnable from 'java.lang.Runnable'; import Exception from 'java.lang.Exception'; import MediaPlayer from 'android.media.MediaPlayer'; +/** + * 定时任务参数封装 + */ type TimerOptions = { start: (res: string) => void; work: (res: string) => void; }; - +/** + * 执行延时任务 + */ export function doTimerTask(opts:TimerOptions) { opts.start('doTimerTask start'); setTimeout(function() { @@ -26,7 +31,9 @@ export function doTimerTask(opts:TimerOptions) { return { name: "doTimerTask" }; } - +/** + * 执行周期任务 + */ export function doIntervalTask(opts:TimerOptions) { let taskRet = setInterval(function() { @@ -37,6 +44,9 @@ export function doIntervalTask(opts:TimerOptions) { return { name: "doIntervalTask",taskId:taskRet}; } +/** + * 清除周期任务 + */ export function clearIntervalTask(taskId:number) { clearInterval(taskId); @@ -85,14 +95,12 @@ class RemoveUIRunnable extends Runnable { export function addViewToDecorView() { let uiRunable = new AddUIRunnable(); - // 获取android环境下 宿主decorview的基本信息 getUniActivity()!.runOnUiThread(uiRunable) } export function removeViewToDecorView() { var uiRunable = new RemoveUIRunnable(); - // 获取android环境下 宿主decorview的基本信息 getUniActivity()!.runOnUiThread(uiRunable) } @@ -124,31 +132,32 @@ export function playAssetAudio() { } -const RTEXT:number = 10020; -export function getResText() :string{ - // let text = "aaa " + com.sina.weibo.sdk.R2.string.com_sina_weibo_sdk_logout; - // let resText = getAppContext()!.getString(io.dcloud.uni_modules.uts_advance.R.string.dcloud_common_app_res_download_failed) - return "222"; -} - -export function initAppLifecycle() { - console.log("initAppLifecycle"); +export function initAppLifecycle(onLifecycleChange: (event:string) => void) { onAppActivityDestroy(() => { - console.log("onAppActivityDestroy"); + + let eventName = "onAppActivityDestroy - " + Date.now(); + onLifecycleChange(eventName); + console.log(eventName); }); onAppActivityPause(() => { - console.log("onAppActivityPause"); + let eventName = "onAppActivityPause - " + Date.now(); + onLifecycleChange(eventName); + console.log(eventName); }); onAppActivityResume(() => { - console.log("onAppActivityResume"); + let eventName = "onAppActivityResume - " + Date.now(); + onLifecycleChange(eventName); + console.log(eventName); }); onAppActivityBack(() => { - console.log("onAppActivityBack"); + let eventName = "onAppActivityBack - " + Date.now(); + onLifecycleChange(eventName); + console.log(eventName); }); } diff --git a/uni_modules/uts-advance/utssdk/app-android/res/value-zh/strings.xml b/uni_modules/uts-advance/utssdk/app-android/res/value-zh/strings.xml deleted file mode 100644 index 08100b9..0000000 --- a/uni_modules/uts-advance/utssdk/app-android/res/value-zh/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Chinese Text - \ No newline at end of file diff --git a/uni_modules/uts-advance/utssdk/app-android/res/values-en/strings.xml b/uni_modules/uts-advance/utssdk/app-android/res/values-en/strings.xml deleted file mode 100644 index 5775c64..0000000 --- a/uni_modules/uts-advance/utssdk/app-android/res/values-en/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - English Text - \ No newline at end of file diff --git a/uni_modules/uts-helloworld/readme.md b/uni_modules/uts-helloworld/readme.md index 0643d4a..ffa1050 100644 --- a/uni_modules/uts-helloworld/readme.md +++ b/uni_modules/uts-helloworld/readme.md @@ -1 +1,3 @@ -# uts-helloworld \ No newline at end of file +# uts-helloworld + +UTS入门示例插件 \ No newline at end of file -- GitLab