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

daily update

上级 09ee09e5
......@@ -41,9 +41,13 @@
]
},
/* ios打包配置 */
"ios" : {},
"ios" : {
"dSYMs" : false
},
/* SDK配置 */
"sdkConfigs" : {}
"sdkConfigs" : {
"ad" : {}
}
}
},
/* 快应用特有相关 */
......
......@@ -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/Advance",
"pagePath": "pages/advance/advance",
"text": "进阶"
}, {
"pagePath": "pages/tabBar/SystemAPI/SystemAPI",
"pagePath":"pages/SystemAPI/SystemAPI",
"text": "系统API"
}, {
"pagePath": "pages/tabBar/SDKIntegration/SDKIntegration",
"pagePath": "pages/SDKIntegration/SDKIntegration",
"text": "三方SDK"
}
]
......
......@@ -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'
})
},
}
}
......
......@@ -67,4 +67,4 @@
<style>
</style>
</style>
\ No newline at end of file
<template>
<view>当前电量:</view>
</template>
<script lang="ts" setup>
import { initAppLifecycle } from '../../uni_modules/uts-advance'
initAppLifecycle();
</script>
\ No newline at end of file
<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>
<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
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.
先完成此消息的编辑!
想要评论请 注册