提交 35ad20ce 编写于 作者: 杜庆泉's avatar 杜庆泉

完善xtoast 使用示例

上级 6bb96332
......@@ -35,6 +35,24 @@
"enablePullDownRefresh": false
}
},
{
"path" : "pages/SDKIntegration/TencentLocation/TencentLocation",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/SDKIntegration/XToast/XToast",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/lifecycle/lifecycle",
......
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 腾讯定位sdk需在腾讯地图官网申请key。https://lbs.qq.com/mobile/androidMapSDK/
developerGuide/getKey。
</view>
<view class="uni-hello-text">
2. 将key配置在uts插件uts-tencentgeolocation/utssdk/app-android/AndroidManifest.xml中。
</view>
<view class="uni-hello-text">
3. 打包自定义基座,注意将uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0.jar先移到其他目录。
</view>
<view class="uni-hello-text">
4. 打包自定义基座后将androix-core-1.0.0.jar移回原位,然后真机运行自定义基座。这个临时的移出移入问题后续会升级解决,详见uts插件开发文档的临时注意。
</view>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="checkLocationPermission">请求定位权限</button>
<button type="primary" @tap="testGetlocation">腾讯地图获取定位(需自定义基座)</button>
</view>
<uni-list>
<uni-list-item @tap="gotoTencentLocation" title="腾讯定位sdk集成示例" class="itemButton" :clickable="true" link/>
<uni-list-item @tap="gotoXToast" title="XToast集成示例" class="itemButton" :clickable="true" link/>
</uni-list>
</view>
</template>
<script>
import {requestPremission,getLocation} from "@/uni_modules/uts-tencentgeolocation";
export default {
data() {
return {
title: '腾讯定位SDK集成示例',
title: 'SDK集成示例',
}
},
methods: {
checkLocationPermission:function(e){
requestPremission();
},
testGetlocation:function(e){
let startRet = getLocation({
geocode:true,
success:function(response){
console.log(response);
var addressDesc = response.name + '-' + response.address
uni.showToast({
title:'执行结果:' + addressDesc,
icon:'none'
});
},
fail:function(msg) {
uni.showToast({
title: msg,
icon:"none"
gotoXToast:function(e){
uni.navigateTo({
url:'/pages/SDKIntegration/XToast/XToast'
})
}
},
gotoTencentLocation:function(e){
uni.navigateTo({
url:'/pages/SDKIntegration/TencentLocation/TencentLocation'
})
if(!startRet){
uni.showToast({
title:'定位启动失败,请检查配置',
icon:'none'
});
}
},
}
}
</script>
......
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 腾讯定位sdk需在腾讯地图官网申请key。https://lbs.qq.com/mobile/androidMapSDK/
developerGuide/getKey。
</view>
<view class="uni-hello-text">
2. 将key配置在uts插件uts-tencentgeolocation/utssdk/app-android/AndroidManifest.xml中。
</view>
<view class="uni-hello-text">
3. 打包自定义基座,注意将uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0.jar先移到其他目录。
</view>
<view class="uni-hello-text">
4. 打包自定义基座后将androix-core-1.0.0.jar移回原位,然后真机运行自定义基座。这个临时的移出移入问题后续会升级解决,详见uts插件开发文档的临时注意。
</view>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="checkLocationPermission">请求定位权限</button>
<button type="primary" @tap="testGetlocation">腾讯地图获取定位(需自定义基座)</button>
</view>
</view>
</template>
<script>
import {requestPremission,getLocation} from "@/uni_modules/uts-tencentgeolocation";
export default {
data() {
return {
title: '腾讯定位SDK集成示例',
}
},
methods: {
checkLocationPermission:function(e){
requestPremission();
},
testGetlocation:function(e){
let startRet = getLocation({
geocode:true,
success:function(response){
console.log(response);
var addressDesc = response.name + '-' + response.address
uni.showToast({
title:'执行结果:' + addressDesc,
icon:'none'
});
},
fail:function(msg) {
uni.showToast({
title: msg,
icon:"none"
})
}
})
if(!startRet){
uni.showToast({
title:'定位启动失败,请检查配置',
icon:'none'
});
}
},
}
}
</script>
<style>
</style>
<template>
<button @tap="testToastShow">调用XToast弹窗</button>
</template>
<script>
import { showToast } from '@/uni_modules/uts-toast'
export default {
data() {
return {
}
},
methods:{
testToastShow(){
showToast();
}
}
}
</script>
<style>
</style>
\ No newline at end of file
......@@ -9,6 +9,7 @@
import { getLogoPath } from '../../uni_modules/uts-advance'
export default {
data() {
......
......@@ -202,24 +202,24 @@ export function goOtherActivity(imageDone: (event:string) => void):boolean {
return false;
}
onAppActivityResult((requestCode: Int, resultCode: Int, data?: Intent) => {
let eventName = "onAppActivityResult - requestCode:" + requestCode + " -resultCode:"+resultCode + " -data:"+JSON.stringify(data);
console.log(eventName);
if ((requestCode == 1001) && (resultCode == Activity.RESULT_OK)) {
if (data != null) {
let bundle = data.getExtras();
let mImageBitmap = bundle!.get("data") as Bitmap;
let bitmapPath = getUniActivity()!.getExternalCacheDir()!.getPath() + "/photo.png"
console.log(bitmapPath);
try{
mImageBitmap.compress(Bitmap.CompressFormat.PNG,100,new FileOutputStream(bitmapPath))
}catch(e){
}
imageDone(bitmapPath);
}
}
});
// onAppActivityResult((requestCode: Int, resultCode: Int, data?: Intent) => {
// let eventName = "onAppActivityResult - requestCode:" + requestCode + " -resultCode:"+resultCode + " -data:"+JSON.stringify(data);
// console.log(eventName);
// if ((requestCode == 1001) && (resultCode == Activity.RESULT_OK)) {
// if (data != null) {
// let bundle = data.getExtras();
// let mImageBitmap = bundle!.get("data") as Bitmap;
// let bitmapPath = getUniActivity()!.getExternalCacheDir()!.getPath() + "/photo.png"
// console.log(bitmapPath);
// try{
// mImageBitmap.compress(Bitmap.CompressFormat.PNG,100,new FileOutputStream(bitmapPath))
// }catch(e){
// }
// imageDone(bitmapPath);
// }
// }
// });
let takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//resolveActivity 返回可处理 Intent 的第一个 Activity 组件
......@@ -240,18 +240,18 @@ export function initAppLifecycle(onLifecycleChange: (event:string) => void) {
onAppTrimMemory((level:Number) => {
let eventName = "onAppTrimMemory - " + level;
onLifecycleChange(eventName);
console.log(eventName);
});
// onAppTrimMemory((level:Number) => {
// let eventName = "onAppTrimMemory - " + level;
// onLifecycleChange(eventName);
// console.log(eventName);
// });
onAppConfigChange((ret:UTSJSONObject) => {
let eventName = "onAppConfigChange - " + JSON.stringify(ret);
onLifecycleChange(eventName);
console.log(eventName);
});
// onAppConfigChange((ret:UTSJSONObject) => {
// let eventName = "onAppConfigChange - " + JSON.stringify(ret);
// onLifecycleChange(eventName);
// console.log(eventName);
// });
/**
......
......@@ -4,8 +4,11 @@ import {
import XToast from "com.hjq.xtoast.XToast";
import R from "io.dcloud.uni_modules.uts_toast.R";
import Runnable from 'java.lang.Runnable';
export function showToast():string{
class UIRunnable extends Runnable {
override run():void {
new XToast<XToast<unknown>>(getUniActivity())
.setDuration(1000)
......@@ -14,5 +17,12 @@ export function showToast():string{
.setText(android.R.id.message, "一秒后自动消失")
.show()
return ""
}
};
export function showToast(){
let toastRunable = new UIRunnable();
getUniActivity()!.runOnUiThread(toastRunable)
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册