提交 2b853412 编写于 作者: 打打卡夫卡's avatar 打打卡夫卡

修复标准基座运行xtoast直接崩溃的问题

上级 e2cc58dc
......@@ -28,7 +28,13 @@
},
methods:{
testToastShow(){
showToast();
let ret = showToast();
if(!ret){
uni.showToast({
icon:'none',
title:'需要在自定义基座中运行'
})
}
}
}
......
......@@ -5,11 +5,14 @@ import {
import XToast from "com.hjq.xtoast.XToast";
import R from "io.dcloud.uni_modules.uts_toast.R";
import Runnable from 'java.lang.Runnable';
import Class from 'java.lang.Class';
import Exception from 'java.lang.Exception';
class UIRunnable extends Runnable {
override run():void {
new XToast<XToast<unknown>>(getUniActivity())
.setDuration(1000)
.setContentView(R.layout.window_hint)
......@@ -20,9 +23,21 @@ class UIRunnable extends Runnable {
}
};
export function showToast(){
export function showToast():boolean{
let hasXToastIntegration = true
try{
let xToastClass = Class.forName("com.hjq.xtoast.XToast")
console.log(xToastClass)
}catch(e:Exception){
hasXToastIntegration = false;
}
if(!hasXToastIntegration){
return false;
}
let toastRunable = new UIRunnable();
getUniActivity()!.runOnUiThread(toastRunable)
return true
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册