var logList = [];
floaty.close(‘myLog’)
utils.f1 = floaty.showFloatXml(‘myLog’, ‘logf.xml’, 0, device.getScreenHeight() * 0.7)
floaty.updateSize(‘myLog’, device.getScreenWidth(), 300)
floaty.touchable(‘myLog’, false)
setStopCallback(function () {
floaty.close(‘myLog’)
})
thread.execAsync(function () {
var log = utils.f1.findViewWithTag(‘log’)
var c = utils.f1.findViewWithTag(‘closemylog’)
/* ui.getHandler().post(function () {
ui.setEvent(c, ‘click’, function () {
floaty.close(‘myLog’)
})
})*/
while (1) {
sleep(50)
let str = logList.join('\n')
ui.getHandler().post(function () {
log.text = str;
})
}
})
var i = 0
while (1) {
sleep(1000)
logList.unshift(‘哈哈哈’ + i++)
}
function showMylog() {
utils.logList = [];
floaty.close(‘myLog’)
utils.f1 = floaty.showFloatXml(‘myLog’, ‘logf.xml’, 0, device.getScreenHeight() * 0.7)
floaty.updateSize(‘myLog’, device.getScreenWidth(), 300)
floaty.touchable(‘myLog’, false)
setStopCallback(function () {
//floaty.close('myLog')
floaty.touchable('myLog', true)
})
utils.mylog = function (msg) {
utils.logList.unshift(new Date().Format() + '>>>' + msg)
if (utils.logList.length > 100) {
utils.logList.length = 5
}
}
thread.execAsync(function () {
var log = utils.f1.findViewWithTag('log')
var c = utils.f1.findViewWithTag('closemylog')
ui.getHandler().post(function () {
ui.setEvent(c, 'click', function () {
floaty.close('myLog')
})
})
var ol = -1;
while (1) {
sleep(10)
var ol=-1
if(utils.logList.length!==ol){
ol = utils.logList.length;
if(utils.logList.length>100){
utils.logList.length=10
}
let str = utils.logList.join('\n')
ui.getHandler().post(function () {
log.text = str;
})
}
}
})
}