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

View File

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