fix: cannot set w and h on root element of ui;
fix: ui.post
This commit is contained in:
@@ -19,7 +19,7 @@ module.exports = function (runtime, global) {
|
||||
xml = xml.toXMLString();
|
||||
}
|
||||
runtime.ui.layoutInflater.setContext(activity);
|
||||
var view = runtime.ui.layoutInflater.inflate(xml);
|
||||
var view = runtime.ui.layoutInflater.inflate(xml, activity.window.decorView, false);
|
||||
ui.setContentView(view);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ module.exports = function (runtime, global) {
|
||||
|
||||
ui.post = function (action, delay) {
|
||||
delay = delay || 0;
|
||||
runtime.getUiHandler().postDelay(wrapUiAction(action), delay);
|
||||
runtime.getUiHandler().postDelayed(wrapUiAction(action), delay);
|
||||
}
|
||||
|
||||
ui.statusBarColor = function (color) {
|
||||
|
||||
@@ -146,20 +146,24 @@ public class DynamicLayoutInflater {
|
||||
}
|
||||
|
||||
public View inflate(String xml, @Nullable ViewGroup parent) {
|
||||
return inflate(xml, parent, parent != null);
|
||||
}
|
||||
|
||||
public View inflate(String xml, @Nullable ViewGroup parent, boolean attachToParent) {
|
||||
View view = mLayoutInflaterDelegate.beforeInflation(xml, parent);
|
||||
if (view != null)
|
||||
return view;
|
||||
xml = convertXml(xml);
|
||||
return mLayoutInflaterDelegate.afterInflation(doInflation(xml, parent), xml, parent);
|
||||
return mLayoutInflaterDelegate.afterInflation(doInflation(xml, parent, attachToParent), xml, parent);
|
||||
}
|
||||
|
||||
protected View doInflation(String xml, @Nullable ViewGroup parent) {
|
||||
protected View doInflation(String xml, @Nullable ViewGroup parent, boolean attachToParent) {
|
||||
try {
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
dbf.setNamespaceAware(true);
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
Document document = db.parse(new ByteArrayInputStream(xml.getBytes()));
|
||||
return inflate(document.getDocumentElement(), parent, true);
|
||||
return inflate(document.getDocumentElement(), parent, attachToParent);
|
||||
} catch (Exception e) {
|
||||
throw new InflateException(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user