feat:add debug option:start debugging

This commit is contained in:
pengfei.zhou
2021-03-02 15:11:16 +08:00
committed by osborn
parent de4188b74e
commit cf888e3655
7 changed files with 117 additions and 22 deletions

View File

@@ -142,6 +142,12 @@ public class DoricDev {
}
}
public void requestDebugging(DoricContext context) {
wsClient.sendToServer("DEBUG", new JSONBuilder()
.put("source", context.getSource())
.toJSONObject());
}
public void stopDebugging(boolean resume) {
wsClient.sendToDebugger("DEBUG_STOP", new JSONBuilder()
.put("msg", "Stop debugging")

View File

@@ -301,8 +301,12 @@ public class DoricDevActivity extends AppCompatActivity implements DoricDev.Stat
public void onClick(View v) {
ArrayList<String> list = new ArrayList<>();
list.add("View source");
if (context.getDriver() instanceof DoricDebugDriver) {
list.add("Stop debugging");
if (DoricDev.getInstance().isInDevMode()) {
if (context.getDriver() instanceof DoricDebugDriver) {
list.add("Stop debugging");
} else {
list.add("Start debugging");
}
}
final String[] items = list.toArray(new String[0]);
AlertDialog.Builder builder = new AlertDialog.Builder(holder.itemView.getContext(), R.style.Theme_Doric_Modal);
@@ -333,6 +337,8 @@ public class DoricDevActivity extends AppCompatActivity implements DoricDev.Stat
builder.show();
} else if ("Stop debugging".equals(items[which])) {
DoricDev.getInstance().stopDebugging(true);
} else if ("Start debugging".equals(items[which])) {
DoricDev.getInstance().requestDebugging(context);
}
dialog.dismiss();
}