dev kit open, connect & eof exception prompt
This commit is contained in:
parent
8da662414b
commit
06a1420821
@ -7,6 +7,7 @@ import android.os.Bundle;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -28,7 +29,8 @@ import pub.doric.Doric;
|
|||||||
import pub.doric.DoricContext;
|
import pub.doric.DoricContext;
|
||||||
import pub.doric.DoricContextManager;
|
import pub.doric.DoricContextManager;
|
||||||
import pub.doric.R;
|
import pub.doric.R;
|
||||||
import pub.doric.dev.event.EOFEvent;
|
import pub.doric.dev.event.ConnectExceptionEvent;
|
||||||
|
import pub.doric.dev.event.EOFExceptionEvent;
|
||||||
import pub.doric.dev.event.OpenEvent;
|
import pub.doric.dev.event.OpenEvent;
|
||||||
|
|
||||||
public class DevPanel extends BottomSheetDialogFragment {
|
public class DevPanel extends BottomSheetDialogFragment {
|
||||||
@ -113,11 +115,19 @@ public class DevPanel extends BottomSheetDialogFragment {
|
|||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onOpenEvent(OpenEvent openEvent) {
|
public void onOpenEvent(OpenEvent openEvent) {
|
||||||
updateUI();
|
updateUI();
|
||||||
|
Toast.makeText(getContext(), "dev kit connected", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onEOFEvent(EOFEvent eofEvent) {
|
public void onEOFEvent(EOFExceptionEvent eofExceptionEvent) {
|
||||||
updateUI();
|
updateUI();
|
||||||
|
Toast.makeText(getContext(), "dev kit eof exception", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onConnectExceptionEvent(ConnectExceptionEvent connectExceptionEvent) {
|
||||||
|
updateUI();
|
||||||
|
Toast.makeText(getContext(), "dev kit connection exception", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateUI() {
|
private void updateUI() {
|
||||||
|
@ -20,6 +20,7 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
|
import java.net.ConnectException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
@ -29,7 +30,8 @@ import okhttp3.WebSocket;
|
|||||||
import okhttp3.WebSocketListener;
|
import okhttp3.WebSocketListener;
|
||||||
import pub.doric.DoricContext;
|
import pub.doric.DoricContext;
|
||||||
import pub.doric.DoricContextManager;
|
import pub.doric.DoricContextManager;
|
||||||
import pub.doric.dev.event.EOFEvent;
|
import pub.doric.dev.event.ConnectExceptionEvent;
|
||||||
|
import pub.doric.dev.event.EOFExceptionEvent;
|
||||||
import pub.doric.dev.event.EnterDebugEvent;
|
import pub.doric.dev.event.EnterDebugEvent;
|
||||||
import pub.doric.dev.event.OpenEvent;
|
import pub.doric.dev.event.OpenEvent;
|
||||||
|
|
||||||
@ -108,7 +110,10 @@ public class WSClient extends WebSocketListener {
|
|||||||
|
|
||||||
if (t instanceof EOFException) {
|
if (t instanceof EOFException) {
|
||||||
DevPanel.isDevConnected = false;
|
DevPanel.isDevConnected = false;
|
||||||
EventBus.getDefault().post(new EOFEvent());
|
EventBus.getDefault().post(new EOFExceptionEvent());
|
||||||
|
} else if (t instanceof ConnectException) {
|
||||||
|
DevPanel.isDevConnected = false;
|
||||||
|
EventBus.getDefault().post(new ConnectExceptionEvent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
package pub.doric.dev.event;
|
||||||
|
|
||||||
|
public class ConnectExceptionEvent {
|
||||||
|
}
|
@ -1,4 +0,0 @@
|
|||||||
package pub.doric.dev.event;
|
|
||||||
|
|
||||||
public class EOFEvent {
|
|
||||||
}
|
|
@ -0,0 +1,4 @@
|
|||||||
|
package pub.doric.dev.event;
|
||||||
|
|
||||||
|
public class EOFExceptionEvent {
|
||||||
|
}
|
Reference in New Issue
Block a user