Skip to content

Commit

Permalink
disconnect bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
changliu98 committed Dec 3, 2020
1 parent d1fd5ad commit 794a398
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Android/app/src/main/java/com/cns/encom/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ public void connect_onclick(View view){
TextView indicator_host = findViewById(R.id.Indicator_hostip);
indicator_host.setText("Host: "+tarip);
switchCam = true;
// TextView spd = findViewById(R.id.Indicator_speed);
connectionUp = true;
if(mConnThread != null && mConnThread.isAlive())
logsWindows.append("You have already connected\n");
else{
Expand All @@ -240,17 +238,23 @@ public void connect_onclick(View view){
}

public void disconnect_onclick(View view) {
connectionUp = false;
if(mConnThread != null){
try{mConnThread.join();}
catch(InterruptedException e){mConnThread.interrupt();}

if(connectionUp) {
if (mConnThread != null) {
try {
mConnThread.join();
} catch (InterruptedException e) {
mConnThread.interrupt();
}
}
TextView logsWindows = findViewById(R.id.textView);
logsWindows.append("You have disconnected\n");
TextView indicator_host = findViewById(R.id.Indicator_hostip);
indicator_host.setText("Host: 0.0.0.0");
mConnThread = null;
switchCam = false;
connectionUp = false;
}
TextView logsWindows = findViewById(R.id.textView);
logsWindows.append("You have disconnected\n");
TextView indicator_host = findViewById(R.id.Indicator_hostip);
indicator_host.setText("Host: 0.0.0.0");
mConnThread = null;
switchCam = false;
}

public class connectionThread extends Thread{
Expand Down Expand Up @@ -288,6 +292,7 @@ public void run(){

if(rtspServerStarted)
mainActivity.stopService(service);
connectionUp = true;

mainActivity.startService(service);
rtspServerStarted = true;
Expand Down

0 comments on commit 794a398

Please sign in to comment.