Fixed MainActivity crash on startup when not bound to server.
This commit is contained in:
@@ -260,7 +260,7 @@ public class MainActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
mUtil.unbindFromServer(this,mConnection);
|
mUtil.unbindFromServer(this, mConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -291,7 +291,6 @@ public class MainActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* updateServerStatus - called by the uiTimer timer periodically.
|
* updateServerStatus - called by the uiTimer timer periodically.
|
||||||
* requests the ui to be updated by calling serverStatusRunnable.
|
* requests the ui to be updated by calling serverStatusRunnable.
|
||||||
@@ -384,27 +383,27 @@ public class MainActivity extends Activity {
|
|||||||
mConnection.mSdServer.mSdData.specPower) /
|
mConnection.mSdServer.mSdData.specPower) /
|
||||||
mConnection.mSdServer.mSdData.alarmRatioThresh;
|
mConnection.mSdServer.mSdData.alarmRatioThresh;
|
||||||
|
|
||||||
((TextView)findViewById(R.id.powerTv)).setText("Power = "+mConnection.mSdServer.mSdData.roiPower+
|
((TextView) findViewById(R.id.powerTv)).setText("Power = " + mConnection.mSdServer.mSdData.roiPower +
|
||||||
" (threshold = "+mConnection.mSdServer.mSdData.alarmThresh+")");
|
" (threshold = " + mConnection.mSdServer.mSdData.alarmThresh + ")");
|
||||||
((TextView)findViewById(R.id.spectrumTv)).setText("Spectrum Ratio = "+10 * mConnection.mSdServer.mSdData.roiPower /
|
((TextView) findViewById(R.id.spectrumTv)).setText("Spectrum Ratio = " + 10 * mConnection.mSdServer.mSdData.roiPower /
|
||||||
mConnection.mSdServer.mSdData.specPower+
|
mConnection.mSdServer.mSdData.specPower +
|
||||||
" (threshold = "+mConnection.mSdServer.mSdData.alarmRatioThresh+")");
|
" (threshold = " + mConnection.mSdServer.mSdData.alarmRatioThresh + ")");
|
||||||
|
|
||||||
ProgressBar pb;
|
ProgressBar pb;
|
||||||
pb = ((ProgressBar)findViewById(R.id.powerProgressBar));
|
pb = ((ProgressBar) findViewById(R.id.powerProgressBar));
|
||||||
pb.setMax(100);
|
pb.setMax(100);
|
||||||
pb.setProgress((int)powerPc);
|
pb.setProgress((int) powerPc);
|
||||||
int colour = Color.BLUE;
|
int colour = Color.BLUE;
|
||||||
if (powerPc>75) colour = Color.YELLOW;
|
if (powerPc > 75) colour = Color.YELLOW;
|
||||||
if (powerPc>100) colour = Color.RED;
|
if (powerPc > 100) colour = Color.RED;
|
||||||
pb.getProgressDrawable().setColorFilter(colour, PorterDuff.Mode.SRC_IN);
|
pb.getProgressDrawable().setColorFilter(colour, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
pb = ((ProgressBar)findViewById(R.id.spectrumProgressBar));
|
pb = ((ProgressBar) findViewById(R.id.spectrumProgressBar));
|
||||||
pb.setMax(100);
|
pb.setMax(100);
|
||||||
pb.setProgress((int)specPc);
|
pb.setProgress((int) specPc);
|
||||||
colour = Color.BLUE;
|
colour = Color.BLUE;
|
||||||
if (specPc>75) colour = Color.YELLOW;
|
if (specPc > 75) colour = Color.YELLOW;
|
||||||
if (specPc>100) colour = Color.RED;
|
if (specPc > 100) colour = Color.RED;
|
||||||
pb.getProgressDrawable().setColorFilter(colour, PorterDuff.Mode.SRC_IN);
|
pb.getProgressDrawable().setColorFilter(colour, PorterDuff.Mode.SRC_IN);
|
||||||
} else {
|
} else {
|
||||||
tv = (TextView) findViewById(R.id.alarmTv);
|
tv = (TextView) findViewById(R.id.alarmTv);
|
||||||
@@ -419,6 +418,7 @@ public class MainActivity extends Activity {
|
|||||||
// Deal with Cancel Audible button
|
// Deal with Cancel Audible button
|
||||||
Button cancelAudibleButton =
|
Button cancelAudibleButton =
|
||||||
(Button) findViewById(R.id.cancelAudibleButton);
|
(Button) findViewById(R.id.cancelAudibleButton);
|
||||||
|
if (mConnection.mBound)
|
||||||
if (mConnection.mSdServer.isAudibleCancelled()) {
|
if (mConnection.mSdServer.isAudibleCancelled()) {
|
||||||
cancelAudibleButton.setText("Audible Alarms Cancelled "
|
cancelAudibleButton.setText("Audible Alarms Cancelled "
|
||||||
+ "for "
|
+ "for "
|
||||||
@@ -479,14 +479,13 @@ public class MainActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void showAbout() {
|
private void showAbout() {
|
||||||
View aboutView = getLayoutInflater().inflate(R.layout.about_layout, null, false);
|
View aboutView = getLayoutInflater().inflate(R.layout.about_layout, null, false);
|
||||||
String versionName = mUtil.getAppVersionName();
|
String versionName = mUtil.getAppVersionName();
|
||||||
Log.v(TAG, "showAbout() - version name = " + versionName);
|
Log.v(TAG, "showAbout() - version name = " + versionName);
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setIcon(R.drawable.icon_24x24);
|
builder.setIcon(R.drawable.icon_24x24);
|
||||||
builder.setTitle("OpenSeizureDetector V"+versionName);
|
builder.setTitle("OpenSeizureDetector V" + versionName);
|
||||||
builder.setView(aboutView);
|
builder.setView(aboutView);
|
||||||
builder.create();
|
builder.create();
|
||||||
builder.show();
|
builder.show();
|
||||||
|
|||||||
Reference in New Issue
Block a user