spare DoricDev class for further usage

This commit is contained in:
王劲鹏 2020-02-24 17:39:20 +08:00 committed by osborn
parent fa2171b3ff
commit 3134a0044b
4 changed files with 4 additions and 18 deletions

View File

@ -1,17 +1,5 @@
package pub.doric.devkit; package pub.doric.devkit;
import com.google.gson.JsonObject;
public class DoricDev { public class DoricDev {
public static void connectDevKit(String url) {
DevKit.getInstance().connectDevKit(url);
}
public static void sendDevCommand(IDevKit.Command command, JsonObject jsonObject) {
DevKit.getInstance().sendDevCommand(command, jsonObject);
}
public static void disconnectDevKit() {
DevKit.getInstance().disconnectDevKit();
}
} }

View File

@ -19,7 +19,7 @@ import org.greenrobot.eventbus.EventBus;
import pub.doric.DoricContext; import pub.doric.DoricContext;
import pub.doric.DoricContextManager; import pub.doric.DoricContextManager;
import pub.doric.devkit.DoricDev; import pub.doric.devkit.DevKit;
import pub.doric.devkit.IDevKit; import pub.doric.devkit.IDevKit;
import pub.doric.devkit.R; import pub.doric.devkit.R;
import pub.doric.devkit.event.StartDebugEvent; import pub.doric.devkit.event.StartDebugEvent;
@ -75,7 +75,7 @@ public class DebugContextPanel extends DialogFragment {
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"));
DoricDev.sendDevCommand(IDevKit.Command.DEBUG, jsonObject); DevKit.getInstance().sendDevCommand(IDevKit.Command.DEBUG, jsonObject);
dismissAllowingStateLoss(); dismissAllowingStateLoss();
} }
}); });

View File

@ -24,7 +24,6 @@ import org.greenrobot.eventbus.ThreadMode;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer; import io.reactivex.functions.Consumer;
import pub.doric.devkit.DevKit; import pub.doric.devkit.DevKit;
import pub.doric.devkit.DoricDev;
import pub.doric.devkit.R; import pub.doric.devkit.R;
import pub.doric.devkit.event.ConnectExceptionEvent; import pub.doric.devkit.event.ConnectExceptionEvent;
import pub.doric.devkit.event.EOFExceptionEvent; import pub.doric.devkit.event.EOFExceptionEvent;
@ -58,7 +57,7 @@ public class DevPanel extends BottomSheetDialogFragment {
public void onClick(View v) { public void onClick(View v) {
if (DevKit.isRunningInEmulator) { if (DevKit.isRunningInEmulator) {
DevKit.ip = "10.0.2.2"; DevKit.ip = "10.0.2.2";
DoricDev.connectDevKit("ws://" + DevKit.ip + ":7777"); DevKit.getInstance().connectDevKit("ws://" + DevKit.ip + ":7777");
} else { } else {
final RxPermissions rxPermissions = new RxPermissions(DevPanel.this); final RxPermissions rxPermissions = new RxPermissions(DevPanel.this);
Disposable disposable = rxPermissions Disposable disposable = rxPermissions

View File

@ -9,7 +9,6 @@ import androidx.appcompat.app.AppCompatActivity;
import cn.bingoogolapple.qrcode.core.QRCodeView; import cn.bingoogolapple.qrcode.core.QRCodeView;
import cn.bingoogolapple.qrcode.zbar.ZBarView; import cn.bingoogolapple.qrcode.zbar.ZBarView;
import pub.doric.devkit.DevKit; import pub.doric.devkit.DevKit;
import pub.doric.devkit.DoricDev;
import pub.doric.devkit.R; import pub.doric.devkit.R;
public class ScanQRCodeActivity extends AppCompatActivity implements QRCodeView.Delegate { public class ScanQRCodeActivity extends AppCompatActivity implements QRCodeView.Delegate {
@ -52,7 +51,7 @@ public class ScanQRCodeActivity extends AppCompatActivity implements QRCodeView.
setTitle("扫描结果为:" + result); setTitle("扫描结果为:" + result);
DevKit.ip = result; DevKit.ip = result;
Toast.makeText(this, "dev kit connecting to " + result, Toast.LENGTH_LONG).show(); Toast.makeText(this, "dev kit connecting to " + result, Toast.LENGTH_LONG).show();
DoricDev.connectDevKit("ws://" + result + ":7777"); DevKit.getInstance().connectDevKit("ws://" + result + ":7777");
finish(); finish();
} }