Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
5c203ec8
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1595
Star
27
Fork
9
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Hello UTS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
5c203ec8
编写于
8月 31, 2022
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
daily update
上级
09ee09e5
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
179 addition
and
25 deletion
+179
-25
manifest.json
manifest.json
+6
-2
pages.json
pages.json
+32
-4
pages/advance/advance.vue
pages/advance/advance.vue
+16
-0
pages/index/index.vue
pages/index/index.vue
+1
-1
pages/lifecycle/lifecycle.vue
pages/lifecycle/lifecycle.vue
+7
-0
pages/resource/resource.vue
pages/resource/resource.vue
+39
-0
pages/static/static.vue
pages/static/static.vue
+10
-0
uni_modules/uts-advance/static/logo.png
uni_modules/uts-advance/static/logo.png
+0
-0
uni_modules/uts-advance/utssdk/app-android/assets/free.mp3
uni_modules/uts-advance/utssdk/app-android/assets/free.mp3
+0
-0
uni_modules/uts-advance/utssdk/app-android/index.uts
uni_modules/uts-advance/utssdk/app-android/index.uts
+68
-18
未找到文件。
manifest.json
浏览文件 @
5c203ec8
...
...
@@ -41,9 +41,13 @@
]
},
/*
ios打包配置
*/
"ios"
:
{},
"ios"
:
{
"dSYMs"
:
false
},
/*
SDK配置
*/
"sdkConfigs"
:
{}
"sdkConfigs"
:
{
"ad"
:
{}
}
}
},
/*
快应用特有相关
*/
...
...
pages.json
浏览文件 @
5c203ec8
...
...
@@ -10,6 +10,7 @@
}
},
{
"path"
:
"pages/advance/advance"
,
"style"
:
...
...
@@ -36,6 +37,33 @@
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/static/static"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/lifecycle/lifecycle"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/resource/resource"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
}
],
...
...
@@ -45,17 +73,17 @@
"borderStyle"
:
"black"
,
"backgroundColor"
:
"#F8F8F8"
,
"list"
:
[{
"pagePath"
:
"pages/
tabBar/Primer/Primer
"
,
"pagePath"
:
"pages/
index/index
"
,
"text"
:
"入门"
},
{
"pagePath"
:
"pages/
tabBar/Advance/A
dvance"
,
"pagePath"
:
"pages/
advance/a
dvance"
,
"text"
:
"进阶"
},
{
"pagePath"
:
"pages/tabBar
/SystemAPI/SystemAPI"
,
"pagePath"
:
"pages
/SystemAPI/SystemAPI"
,
"text"
:
"系统API"
},
{
"pagePath"
:
"pages/
tabBar/
SDKIntegration/SDKIntegration"
,
"pagePath"
:
"pages/SDKIntegration/SDKIntegration"
,
"text"
:
"三方SDK"
}
]
...
...
pages/advance/advance.vue
浏览文件 @
5c203ec8
...
...
@@ -10,8 +10,12 @@
<view
class=
"uni-btn-v uni-common-mt"
>
<button
type=
"primary"
@
tap=
"testAddToDecorView"
>
添加TextView至视图顶层
</button>
<button
type=
"primary"
@
tap=
"testRemoveToDecorView"
>
移除视图顶层的TextView
</button>
<button
type=
"primary"
@
tap=
"testLoadImage"
>
资源加载示例
</button>
<button
type=
"primary"
@
tap=
"testLifecyle"
>
activity生命周期监听
</button>
</view>
</view>
</
template
>
<
script
>
...
...
@@ -80,6 +84,18 @@
removeViewToDecorView
();
},
testLoadImage
:
function
()
{
uni
.
navigateTo
({
url
:
'
/pages/resource/resource
'
})
},
testLifecyle
:
function
()
{
uni
.
navigateTo
({
url
:
'
/pages/lifecycle/lifecycle
'
})
},
}
}
...
...
pages/index/index.vue
浏览文件 @
5c203ec8
...
...
@@ -67,4 +67,4 @@
<
style
>
</
style
>
</
style
>
\ No newline at end of file
pages/lifecycle/lifecycle.vue
0 → 100644
浏览文件 @
5c203ec8
<
template
>
<view>
当前电量:
</view>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
initAppLifecycle
}
from
'
../../uni_modules/uts-advance
'
initAppLifecycle
();
</
script
>
\ No newline at end of file
pages/resource/resource.vue
0 → 100644
浏览文件 @
5c203ec8
<
template
>
<view>
<page-head
:title=
"title"
></page-head>
<image
:src=
"logo"
mode=
"aspectFit"
style=
"width: 100%;"
></image>
<view
class=
"uni-btn-v uni-common-mt"
>
<button
type=
"primary"
>
插件内置图片
</button>
<button
type=
"primary"
@
tap=
"testAssetLoad"
>
asset资源加载
</button>
</view>
</view>
</
template
>
<
script
>
import
{
getLogoPath
,
getAssetAPath
}
from
'
../../uni_modules/uts-advance
'
export
default
{
data
()
{
return
{
title
:
'
资源加载示例
'
,
logo
:
""
}
},
onLoad
:
function
(){
this
.
logo
=
getLogoPath
()
},
methods
:
{
testAssetLoad
(){
let
aseetPath
=
getAssetAPath
();
console
.
log
(
aseetPath
);
}
}
}
</
script
>
<
style
>
</
style
>
pages/static/static.vue
0 → 100644
浏览文件 @
5c203ec8
<
template
>
<view>
<view></view>
</view>
<image
:src=
"logo"
></image>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
getLogoPath
}
from
'
../../uni_modules/uts-advance
'
const
logo
=
getLogoPath
()
</
script
>
\ No newline at end of file
uni_modules/uts-advance/static/logo.png
0 → 100644
浏览文件 @
5c203ec8
3.9 KB
uni_modules/uts-advance/utssdk/app-android/assets/free.mp3
0 → 100644
浏览文件 @
5c203ec8
文件已添加
uni_modules/uts-advance/utssdk/app-android/index.uts
浏览文件 @
5c203ec8
import { getUniActivity } from "io.dcloud.uts.android";
import { getUniActivity
,getAppContext
} from "io.dcloud.uts.android";
import Rect from "android.graphics.Rect";
import Color from "android.graphics.Color";
import TextView from "android.widget.TextView";
import FrameLayout from "android.widget.FrameLayout";
import ViewGroup from "android.view.ViewGroup";
import Gravity from "android.view.Gravity";
import Runnable from 'java.lang.Runnable';
import Exception from 'java.lang.Exception';
import MediaPlayer from 'android.media.MediaPlayer';
type TimerOptions = {
start: (res: string) => void;
...
...
@@ -26,7 +29,7 @@ export function doTimerTask(opts:TimerOptions) {
export function doIntervalTask(opts:TimerOptions) {
var
taskRet = setInterval(function() {
let
taskRet = setInterval(function() {
opts.work("doIntervalTask work");
}, 2000);
opts.start('doIntervalTask start');
...
...
@@ -47,18 +50,18 @@ class AddUIRunnable extends Runnable {
override run():void {
var textView =
TextView(getUniActivity())
textView.
text = "HELLO WORLD"
textView.textSize =
30.0.toFloat();
let textView = new
TextView(getUniActivity())
textView.
setText("HELLO WORLD");
textView.textSize = 30.0.toFloat();
textView.setBackgroundColor(Color.RED)
textView.
tag = "helloText"
textView.
gravity = Gravity.CENTER
textView.
setTag("helloText")
textView.
setGravity(Gravity.CENTER)
var
decorView = getUniActivity()!.window.decorView;
let
decorView = getUniActivity()!.window.decorView;
var
frameContent = decorView.findViewById(android.R.id.content) as FrameLayout
var layoutParam =
FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
let
frameContent = decorView.findViewById(android.R.id.content) as FrameLayout
let layoutParam = new
FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParam.topMargin = 200;
frameContent.addView(textView,layoutParam)
...
...
@@ -71,28 +74,75 @@ class RemoveUIRunnable extends Runnable {
override run():void {
var decorView = getUniActivity()!.window.decorView;
var frameContent = decorView.findViewById(android.R.id.content) as FrameLayout
var targetTV = frameContent.findViewWithTag("helloText") as TextView
frameContent.removeView(targetTV)
let decorView = getUniActivity()!.window.decorView;
let frameContent = decorView.findViewById(android.R.id.content) as FrameLayout
let targetTV = frameContent.findViewWithTag<TextView>("helloText")
frameContent.removeView(targetTV)
}
};
export function addViewToDecorView() {
var uiRunable =
AddUIRunnable();
let uiRunable = new
AddUIRunnable();
// 获取android环境下 宿主decorview的基本信息
getUniActivity()!.runOnUiThread(uiRunable)
}
export function removeViewToDecorView() {
var uiRunable = RemoveUIRunnable();
var uiRunable =
new
RemoveUIRunnable();
// 获取android环境下 宿主decorview的基本信息
getUniActivity()!.runOnUiThread(uiRunable)
}
import logo from "../../static/logo.png";
import {
onAppActivityDestroy,
onAppActivityPause,
onAppActivityResume,
onAppActivityBack,
} from "io.dcloud.uts.android";
export function getLogoPath(): string {
return logo;
}
export function getAssetAPath() {
var assetManager = getAppContext()!.getAssets();
var afd = assetManager.openFd("free.mp3");
var mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(), afd.getLength());
mediaPlayer.prepare();
mediaPlayer.start();
}
export function initAppLifecycle() {
console.log("initAppLifecycle");
onAppActivityDestroy(() => {
console.log("onAppActivityDestroy");
});
onAppActivityPause(() => {
console.log("onAppActivityPause");
});
onAppActivityResume(() => {
console.log("onAppActivityResume");
});
onAppActivityBack(() => {
console.log("onAppActivityBack");
});
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录