debugging status timing

This commit is contained in:
王劲鹏 2019-12-10 21:09:12 +08:00
parent 30f61eb47c
commit aa02bd3e8e
3 changed files with 4 additions and 4 deletions

View File

@ -7,18 +7,16 @@ 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 static 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();
} }

View File

@ -17,6 +17,7 @@ import com.google.gson.JsonObject;
import pub.doric.DoricContext; import pub.doric.DoricContext;
import pub.doric.DoricContextManager; import pub.doric.DoricContextManager;
import pub.doric.devkit.DoricContextDebuggable;
import pub.doric.devkit.DoricDev; import pub.doric.devkit.DoricDev;
import pub.doric.devkit.IDevKit; import pub.doric.devkit.IDevKit;
import pub.doric.devkit.R; import pub.doric.devkit.R;
@ -68,6 +69,7 @@ public class DebugContextPanel extends DialogFragment {
cell.findViewById(R.id.debug_text_view).setOnClickListener(new View.OnClickListener() { cell.findViewById(R.id.debug_text_view).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
DoricContextDebuggable.isDebugging = true;
JsonObject jsonObject = new JsonObject(); JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("contextId", doricContext.getContextId()); jsonObject.addProperty("contextId", doricContext.getContextId());
jsonObject.addProperty("source", doricContext.getSource().replace(".js", ".ts")); jsonObject.addProperty("source", doricContext.getSource().replace(".js", ".ts"));

View File

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