add(sample): 护眼模式
fix(floaty): xml.toString() return empty when xml has just one node
This commit is contained in:
10
app/src/main/assets/sample/悬浮窗/护眼模式.js
Normal file
10
app/src/main/assets/sample/悬浮窗/护眼模式.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
var w = floaty.rawWindow(
|
||||||
|
<frame gravity="center" bg="#44ffcc00"/>
|
||||||
|
);
|
||||||
|
|
||||||
|
w.setSize(-1, -1);
|
||||||
|
w.setTouchable(false);
|
||||||
|
|
||||||
|
setTimeout(()=>{
|
||||||
|
w.close();
|
||||||
|
}, 60000);
|
||||||
@@ -4,14 +4,14 @@ module.exports = function(runtime, global){
|
|||||||
|
|
||||||
floaty.window = function(layout){
|
floaty.window = function(layout){
|
||||||
if(typeof(layout) == 'xml'){
|
if(typeof(layout) == 'xml'){
|
||||||
layout = layout.toString();
|
layout = layout.toXMLString();
|
||||||
}
|
}
|
||||||
return wrap(runtime.floaty.window(layout));
|
return wrap(runtime.floaty.window(layout));
|
||||||
}
|
}
|
||||||
|
|
||||||
floaty.rawWindow = function(layout){
|
floaty.rawWindow = function(layout){
|
||||||
if(typeof(layout) == 'xml'){
|
if(typeof(layout) == 'xml'){
|
||||||
layout = layout.toString();
|
layout = layout.toXMLString();
|
||||||
}
|
}
|
||||||
return wrap(runtime.floaty.rawWindow(layout));
|
return wrap(runtime.floaty.rawWindow(layout));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,11 @@ module.exports = function (runtime, global) {
|
|||||||
if(!activity){
|
if(!activity){
|
||||||
throw new Error("需要在ui模式下运行才能使用该函数");
|
throw new Error("需要在ui模式下运行才能使用该函数");
|
||||||
}
|
}
|
||||||
|
if(typeof(xml) == 'xml'){
|
||||||
|
xml = xml.toXMLString();
|
||||||
|
}
|
||||||
runtime.ui.layoutInflater.setContext(activity);
|
runtime.ui.layoutInflater.setContext(activity);
|
||||||
var view = runtime.ui.layoutInflater.inflate(xml.toString());
|
var view = runtime.ui.layoutInflater.inflate(xml);
|
||||||
ui.setContentView(view);
|
ui.setContentView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public class Floaty {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new ScriptInterruptedException();
|
throw new ScriptInterruptedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
JsResizableWindow window = new JsResizableWindow((context, parent) -> view);
|
JsResizableWindow window = new JsResizableWindow((context, parent) -> view);
|
||||||
addWindow(window);
|
addWindow(window);
|
||||||
return window;
|
return window;
|
||||||
|
|||||||
Reference in New Issue
Block a user