fix: cannot set w and h on root element of ui;

fix: ui.post
This commit is contained in:
hyb1996 2018-09-27 00:22:41 +08:00
parent 00e687f10d
commit dcc09c4034
4 changed files with 11 additions and 8 deletions

View File

@ -51,7 +51,7 @@ public class SplashActivity extends BaseActivity {
mNotStartMainActivity = getIntent().getBooleanExtra(NOT_START_MAIN_ACTIVITY, false);
boolean forceShowAd = getIntent().getBooleanExtra(FORCE_SHOW_AD, false);
setContentView(R.layout.activity_splash);
mFullScreenAdView = (FullScreenAdView) findViewById(R.id.full_screen_view);
mFullScreenAdView = findViewById(R.id.full_screen_view);
if (!forceShowAd && !Pref.shouldShowAd()) {
mFullScreenAdView.setVisibility(View.INVISIBLE);
mHandler.postDelayed(this::enterNextActivity, 1500);

View File

@ -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) {

View File

@ -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);
}

View File

@ -24,7 +24,6 @@ import java.util.concurrent.locks.ReentrantLock;
public class AccessibilityService extends android.accessibilityservice.AccessibilityService {
private static final String TAG = "AccessibilityService";
private static final SortedMap<Integer, AccessibilityDelegate> mDelegates = new TreeMap<>();
@ -55,7 +54,7 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
@Override
public void onAccessibilityEvent(final AccessibilityEvent event) {
instance = this;
Log.v(TAG, "onAccessibilityEvent: " + event);
//Log.v(TAG, "onAccessibilityEvent: " + event);
if (!containsAllEventTypes && !eventTypes.contains(event.getEventType()))
return;
int type = event.getEventType();