debugging exclude hot load

This commit is contained in:
王劲鹏 2019-12-10 20:55:31 +08:00
parent 75f1aacb8b
commit 30f61eb47c
2 changed files with 15 additions and 3 deletions

View File

@ -7,15 +7,18 @@ import pub.doric.DoricNativeDriver;
public class DoricContextDebuggable {
private DoricContext doricContext;
private DoricDebugDriver doricDebugDriver;
public boolean isDebugging = false;
public DoricContextDebuggable(String contextId) {
this.doricContext = DoricContextManager.getContext(contextId);
}
public void startDebug() {
doricDebugDriver = new DoricDebugDriver(new IStatusCallback() {
@Override
public void start() {
isDebugging = true;
doricContext.setDriver(doricDebugDriver);
doricContext.reInit();
}
@ -23,8 +26,13 @@ public class DoricContextDebuggable {
}
public void stopDebug() {
isDebugging = false;
doricDebugDriver.destroy();
doricContext.setDriver(DoricNativeDriver.getInstance());
doricContext.reInit();
}
public DoricContext getContext() {
return doricContext;
}
}

View File

@ -85,9 +85,13 @@ public class DemoDebugActivity extends DoricActivity {
@Subscribe(threadMode = ThreadMode.MAIN)
public void onReloadEvent(ReloadEvent reloadEvent) {
for (DoricContext context : DoricContextManager.aliveContexts()) {
if (reloadEvent.source.contains(context.getSource())) {
context.reload(reloadEvent.script);
if (doricContextDebuggable != null && doricContextDebuggable.isDebugging) {
System.out.println("is debugging");
} else {
for (DoricContext context : DoricContextManager.aliveContexts()) {
if (reloadEvent.source.contains(context.getSource())) {
context.reload(reloadEvent.script);
}
}
}
}