Fixed issue with crash when switching between new and original UI
This commit is contained in:
Binary file not shown.
@@ -185,6 +185,22 @@ public class FragmentCommon extends FragmentOsdBaseClass {
|
|||||||
tv.setTextColor(Color.GRAY);
|
tv.setTextColor(Color.GRAY);
|
||||||
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tv = (TextView) mRootView.findViewById(R.id.dataSourceInfoTv);
|
||||||
|
tv.setBackgroundColor(okColour);
|
||||||
|
tv.setTextColor(okTextColour);
|
||||||
|
if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) {
|
||||||
|
tv.setText(getString(R.string.DataSource) + " = " + "Phone (Demo Mode)");
|
||||||
|
tv.setBackgroundColor(warnColour);
|
||||||
|
tv.setTextColor(warnTextColour);
|
||||||
|
} else if (mConnection.mSdServer.mSdDataSourceName.equals("BLE")) {
|
||||||
|
tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName
|
||||||
|
+ " ("+ mConnection.mSdServer.mSdData.watchSdName + ", "
|
||||||
|
+ mConnection.mSdServer.mSdData.watchPartNo+")");
|
||||||
|
} else {
|
||||||
|
tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tv = (TextView) mRootView.findViewById(R.id.serverStatusTv);
|
tv = (TextView) mRootView.findViewById(R.id.serverStatusTv);
|
||||||
@@ -200,20 +216,6 @@ public class FragmentCommon extends FragmentOsdBaseClass {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
tv = (TextView) mRootView.findViewById(R.id.dataSourceInfoTv);
|
|
||||||
tv.setBackgroundColor(okColour);
|
|
||||||
tv.setTextColor(okTextColour);
|
|
||||||
if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) {
|
|
||||||
tv.setText(getString(R.string.DataSource) + " = " + "Phone (Demo Mode)");
|
|
||||||
tv.setBackgroundColor(warnColour);
|
|
||||||
tv.setTextColor(warnTextColour);
|
|
||||||
} else if (mConnection.mSdServer.mSdDataSourceName.equals("BLE")) {
|
|
||||||
tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName
|
|
||||||
+ " ("+ mConnection.mSdServer.mSdData.watchSdName + ", "
|
|
||||||
+ mConnection.mSdServer.mSdData.watchPartNo+")");
|
|
||||||
} else {
|
|
||||||
tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// deal with latch alarms button
|
// deal with latch alarms button
|
||||||
Button acceptAlarmButton = (Button) mRootView.findViewById(R.id.acceptAlarmButton);
|
Button acceptAlarmButton = (Button) mRootView.findViewById(R.id.acceptAlarmButton);
|
||||||
|
|||||||
@@ -46,143 +46,143 @@ public class FragmentOsdAlg extends FragmentOsdBaseClass {
|
|||||||
//Log.d(TAG,"updateUi()");
|
//Log.d(TAG,"updateUi()");
|
||||||
TextView tv;
|
TextView tv;
|
||||||
|
|
||||||
|
if (mConnection.mBound) {
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
// Set ProgressBars to show margin to alarm.
|
||||||
|
long powerPc;
|
||||||
|
if (mConnection.mSdServer.mSdData.alarmThresh != 0)
|
||||||
|
powerPc = mConnection.mSdServer.mSdData.roiPower * 100 /
|
||||||
|
mConnection.mSdServer.mSdData.alarmThresh;
|
||||||
|
else
|
||||||
|
powerPc = 0;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
long specPc;
|
||||||
// Set ProgressBars to show margin to alarm.
|
if (mConnection.mSdServer.mSdData.specPower != 0 &&
|
||||||
long powerPc;
|
mConnection.mSdServer.mSdData.alarmRatioThresh != 0)
|
||||||
if (mConnection.mSdServer.mSdData.alarmThresh != 0)
|
specPc = 100 * (mConnection.mSdServer.mSdData.roiPower * 10 /
|
||||||
powerPc = mConnection.mSdServer.mSdData.roiPower * 100 /
|
mConnection.mSdServer.mSdData.specPower) /
|
||||||
mConnection.mSdServer.mSdData.alarmThresh;
|
mConnection.mSdServer.mSdData.alarmRatioThresh;
|
||||||
else
|
else
|
||||||
powerPc = 0;
|
specPc = 0;
|
||||||
|
|
||||||
long specPc;
|
long specRatio;
|
||||||
if (mConnection.mSdServer.mSdData.specPower != 0 &&
|
if (mConnection.mSdServer.mSdData.specPower != 0) {
|
||||||
mConnection.mSdServer.mSdData.alarmRatioThresh != 0)
|
specRatio = 10 * mConnection.mSdServer.mSdData.roiPower /
|
||||||
specPc = 100 * (mConnection.mSdServer.mSdData.roiPower * 10 /
|
mConnection.mSdServer.mSdData.specPower;
|
||||||
mConnection.mSdServer.mSdData.specPower) /
|
} else
|
||||||
mConnection.mSdServer.mSdData.alarmRatioThresh;
|
specRatio = 0;
|
||||||
else
|
|
||||||
specPc = 0;
|
|
||||||
|
|
||||||
long specRatio;
|
((TextView) mRootView.findViewById(R.id.powerTv)).setText(getString(R.string.PowerEquals) + mConnection.mSdServer.mSdData.roiPower +
|
||||||
if (mConnection.mSdServer.mSdData.specPower != 0) {
|
" (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmThresh + ")");
|
||||||
specRatio = 10 * mConnection.mSdServer.mSdData.roiPower /
|
|
||||||
mConnection.mSdServer.mSdData.specPower;
|
|
||||||
} else
|
|
||||||
specRatio = 0;
|
|
||||||
|
|
||||||
((TextView) mRootView.findViewById(R.id.powerTv)).setText(getString(R.string.PowerEquals) + mConnection.mSdServer.mSdData.roiPower +
|
ProgressBar pb;
|
||||||
" (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmThresh + ")");
|
Drawable pbDrawable;
|
||||||
|
pb = ((ProgressBar) mRootView.findViewById(R.id.powerProgressBar));
|
||||||
|
pb.setMax(100);
|
||||||
|
pb.setProgress((int) powerPc);
|
||||||
|
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue);
|
||||||
|
if (powerPc > 75)
|
||||||
|
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_yellow);
|
||||||
|
if (powerPc > 100)
|
||||||
|
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red);
|
||||||
|
pb.setProgressDrawable(pbDrawable);
|
||||||
|
|
||||||
ProgressBar pb;
|
((TextView) mRootView.findViewById(R.id.spectrumTv)).setText(getString(R.string.SpectrumRatioEquals) + specRatio +
|
||||||
Drawable pbDrawable;
|
" (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmRatioThresh + ")");
|
||||||
pb = ((ProgressBar) mRootView.findViewById(R.id.powerProgressBar));
|
|
||||||
pb.setMax(100);
|
|
||||||
pb.setProgress((int) powerPc);
|
|
||||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue);
|
|
||||||
if (powerPc > 75)
|
|
||||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_yellow);
|
|
||||||
if (powerPc > 100)
|
|
||||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red);
|
|
||||||
pb.setProgressDrawable(pbDrawable);
|
|
||||||
|
|
||||||
((TextView) mRootView.findViewById(R.id.spectrumTv)).setText(getString(R.string.SpectrumRatioEquals) + specRatio +
|
pb = ((ProgressBar) mRootView.findViewById(R.id.spectrumProgressBar));
|
||||||
" (" + getString(R.string.Threshold) + "=" + mConnection.mSdServer.mSdData.alarmRatioThresh + ")");
|
pb.setMax(100);
|
||||||
|
pb.setProgress((int) specPc);
|
||||||
|
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue);
|
||||||
|
if (specPc > 75)
|
||||||
|
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_yellow);
|
||||||
|
if (specPc > 100)
|
||||||
|
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red);
|
||||||
|
pb.setProgressDrawable(pbDrawable);
|
||||||
|
|
||||||
pb = ((ProgressBar) mRootView.findViewById(R.id.spectrumProgressBar));
|
////////////////////////////////////////////////////////////
|
||||||
pb.setMax(100);
|
// Produce graph
|
||||||
pb.setProgress((int) specPc);
|
BarChart mChart = (BarChart) mRootView.findViewById(R.id.chart1);
|
||||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_blue);
|
mChart.setDrawBarShadow(false);
|
||||||
if (specPc > 75)
|
mChart.setNoDataTextDescription("You need to provide data for the chart.");
|
||||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_yellow);
|
mChart.setDescription("");
|
||||||
if (specPc > 100)
|
|
||||||
pbDrawable = mRootView.getResources().getDrawable(R.drawable.progress_bar_red);
|
|
||||||
pb.setProgressDrawable(pbDrawable);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
// X and Y Values
|
||||||
// Produce graph
|
ArrayList<String> xVals = new ArrayList<String>();
|
||||||
BarChart mChart = (BarChart) mRootView.findViewById(R.id.chart1);
|
ArrayList<BarEntry> yBarVals = new ArrayList<BarEntry>();
|
||||||
mChart.setDrawBarShadow(false);
|
|
||||||
mChart.setNoDataTextDescription("You need to provide data for the chart.");
|
|
||||||
mChart.setDescription("");
|
|
||||||
|
|
||||||
// X and Y Values
|
|
||||||
ArrayList<String> xVals = new ArrayList<String>();
|
|
||||||
ArrayList<BarEntry> yBarVals = new ArrayList<BarEntry>();
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
xVals.add(i + "-" + (i + 1) + " Hz");
|
|
||||||
if (mConnection.mSdServer != null) {
|
|
||||||
yBarVals.add(new BarEntry(mConnection.mSdServer.mSdData.simpleSpec[i], i));
|
|
||||||
} else {
|
|
||||||
yBarVals.add(new BarEntry(i, i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a dataset and give it a type
|
|
||||||
BarDataSet barDataSet = new BarDataSet(yBarVals, "Spectrum");
|
|
||||||
try {
|
|
||||||
int[] barColours = new int[10];
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if ((i < mConnection.mSdServer.mSdData.alarmFreqMin) ||
|
xVals.add(i + "-" + (i + 1) + " Hz");
|
||||||
(i > mConnection.mSdServer.mSdData.alarmFreqMax)) {
|
if (mConnection.mSdServer != null) {
|
||||||
barColours[i] = Color.GRAY;
|
yBarVals.add(new BarEntry(mConnection.mSdServer.mSdData.simpleSpec[i], i));
|
||||||
} else {
|
} else {
|
||||||
barColours[i] = Color.RED;
|
yBarVals.add(new BarEntry(i, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
barDataSet.setColors(barColours);
|
|
||||||
} catch (NullPointerException e) {
|
// create a dataset and give it a type
|
||||||
Log.e(TAG, "Null pointer exception setting bar colours");
|
BarDataSet barDataSet = new BarDataSet(yBarVals, "Spectrum");
|
||||||
}
|
try {
|
||||||
barDataSet.setBarSpacePercent(20f);
|
int[] barColours = new int[10];
|
||||||
barDataSet.setBarShadowColor(Color.WHITE);
|
for (int i = 0; i < 10; i++) {
|
||||||
BarData barData = new BarData(xVals, barDataSet);
|
if ((i < mConnection.mSdServer.mSdData.alarmFreqMin) ||
|
||||||
barData.setValueFormatter(new ValueFormatter() {
|
(i > mConnection.mSdServer.mSdData.alarmFreqMax)) {
|
||||||
@Override
|
barColours[i] = Color.GRAY;
|
||||||
public String getFormattedValue(float v) {
|
} else {
|
||||||
DecimalFormat format = new DecimalFormat("####");
|
barColours[i] = Color.RED;
|
||||||
return format.format(v);
|
}
|
||||||
|
}
|
||||||
|
barDataSet.setColors(barColours);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
Log.e(TAG, "Null pointer exception setting bar colours");
|
||||||
}
|
}
|
||||||
});
|
barDataSet.setBarSpacePercent(20f);
|
||||||
mChart.setData(barData);
|
barDataSet.setBarShadowColor(Color.WHITE);
|
||||||
|
BarData barData = new BarData(xVals, barDataSet);
|
||||||
|
barData.setValueFormatter(new ValueFormatter() {
|
||||||
|
@Override
|
||||||
|
public String getFormattedValue(float v) {
|
||||||
|
DecimalFormat format = new DecimalFormat("####");
|
||||||
|
return format.format(v);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mChart.setData(barData);
|
||||||
|
|
||||||
// format the axes
|
// format the axes
|
||||||
XAxis xAxis = mChart.getXAxis();
|
XAxis xAxis = mChart.getXAxis();
|
||||||
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
|
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
|
||||||
xAxis.setTextSize(10f);
|
xAxis.setTextSize(10f);
|
||||||
xAxis.setDrawAxisLine(true);
|
xAxis.setDrawAxisLine(true);
|
||||||
xAxis.setDrawLabels(true);
|
xAxis.setDrawLabels(true);
|
||||||
// Note: the default text colour is BLACK, so does not show up on black background!!!
|
// Note: the default text colour is BLACK, so does not show up on black background!!!
|
||||||
// This took a lot of finding....
|
// This took a lot of finding....
|
||||||
xAxis.setTextColor(Color.WHITE);
|
xAxis.setTextColor(Color.WHITE);
|
||||||
xAxis.setDrawGridLines(false);
|
xAxis.setDrawGridLines(false);
|
||||||
|
|
||||||
YAxis yAxis = mChart.getAxisLeft();
|
YAxis yAxis = mChart.getAxisLeft();
|
||||||
yAxis.setAxisMinValue(0f);
|
yAxis.setAxisMinValue(0f);
|
||||||
yAxis.setAxisMaxValue(3000f);
|
yAxis.setAxisMaxValue(3000f);
|
||||||
yAxis.setDrawGridLines(true);
|
yAxis.setDrawGridLines(true);
|
||||||
yAxis.setDrawLabels(true);
|
yAxis.setDrawLabels(true);
|
||||||
yAxis.setTextColor(Color.WHITE);
|
yAxis.setTextColor(Color.WHITE);
|
||||||
yAxis.setValueFormatter(new ValueFormatter() {
|
yAxis.setValueFormatter(new ValueFormatter() {
|
||||||
@Override
|
@Override
|
||||||
public String getFormattedValue(float v) {
|
public String getFormattedValue(float v) {
|
||||||
DecimalFormat format = new DecimalFormat("#####");
|
DecimalFormat format = new DecimalFormat("#####");
|
||||||
return format.format(v);
|
return format.format(v);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
YAxis yAxis2 = mChart.getAxisRight();
|
||||||
|
yAxis2.setDrawGridLines(false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
mChart.getLegend().setEnabled(false);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
Log.e(TAG, "Null Pointer Exception setting legend");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
YAxis yAxis2 = mChart.getAxisRight();
|
mChart.invalidate();
|
||||||
yAxis2.setDrawGridLines(false);
|
|
||||||
|
|
||||||
try {
|
|
||||||
mChart.getLegend().setEnabled(false);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
Log.e(TAG, "Null Pointer Exception setting legend");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mChart.invalidate();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,14 +74,14 @@ public class FragmentSystem extends FragmentOsdBaseClass {
|
|||||||
if (mConnection.mBound) {
|
if (mConnection.mBound) {
|
||||||
if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) {
|
if (mConnection.mSdServer.mSdDataSourceName.equals("Phone")) {
|
||||||
if (mConnection.mSdServer.mLogNDA)
|
if (mConnection.mSdServer.mLogNDA)
|
||||||
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + "\n" + "(Demo Mode)" + "\nNDA Logging");
|
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + " " + "(Demo Mode)" + "\nNDA Logging");
|
||||||
else
|
else
|
||||||
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + "\n" + "(Demo Mode)");
|
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + "Phone" + " " + "(Demo Mode)");
|
||||||
tv.setBackgroundColor(warnColour);
|
tv.setBackgroundColor(warnColour);
|
||||||
tv.setTextColor(warnTextColour);
|
tv.setTextColor(warnTextColour);
|
||||||
} else {
|
} else {
|
||||||
if (mConnection.mSdServer.mLogNDA)
|
if (mConnection.mSdServer.mLogNDA)
|
||||||
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName + "\nNDA Logging");
|
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName + ": NDA Logging");
|
||||||
else
|
else
|
||||||
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName);
|
tv.setText(getString(R.string.ServerRunningOK) + getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName);
|
||||||
tv.setBackgroundColor(okColour);
|
tv.setBackgroundColor(okColour);
|
||||||
|
|||||||
Reference in New Issue
Block a user