Prevent startup activity from sleeping. Changed mainactivity graph to bar chart.
This commit is contained in:
@@ -57,6 +57,7 @@ import java.util.TimerTask;
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
@@ -512,49 +513,47 @@ public class MainActivity extends Activity {
|
||||
mChart.setDescription("Simple Spectrum");
|
||||
mChart.setDrawBarShadow(false);
|
||||
mChart.setNoDataTextDescription("You need to provide data for the chart.");
|
||||
// X Values
|
||||
|
||||
// X and Y Values
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
xVals.add((i) + "");
|
||||
}
|
||||
XAxis xAxis = mChart.getXAxis();
|
||||
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
|
||||
xAxis.setTextSize(10f);
|
||||
xAxis.setDrawAxisLine(true);
|
||||
xAxis.setDrawLabels(true);
|
||||
xAxis.setEnabled(true);
|
||||
// Y Values
|
||||
//ArrayList<Entry> yVals = new ArrayList<Entry>();
|
||||
ArrayList<BarEntry> yBarVals = new ArrayList<BarEntry>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
xVals.add("x "+i+" Hz");
|
||||
if (mConnection.mSdServer != null) {
|
||||
//yVals.add(new Entry(mConnection.mSdServer.mSdData.simpleSpec[i], i));
|
||||
yBarVals.add(new BarEntry(mConnection.mSdServer.mSdData.simpleSpec[i], i));
|
||||
}
|
||||
else {
|
||||
//yVals.add(new Entry(i, i));
|
||||
yBarVals.add(new BarEntry(i,i));
|
||||
}
|
||||
}
|
||||
//for (int i = 0;i<10;i++)
|
||||
// Log.v(TAG,"x="+xVals.get(i)+" y="+yBarVals.get(i));
|
||||
|
||||
// create a dataset and give it a type
|
||||
//LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
|
||||
//set1.setColor(Color.BLACK);
|
||||
//set1.setLineWidth(1f);
|
||||
|
||||
//ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
|
||||
//dataSets.add(set1); // add the datasets
|
||||
//LineData data = new LineData(xVals, dataSets);
|
||||
|
||||
BarDataSet barDataSet = new BarDataSet(yBarVals,"Spectrum");
|
||||
barDataSet.setColor(Color.GRAY);
|
||||
barDataSet.setBarSpacePercent(20f);
|
||||
barDataSet.setBarShadowColor(Color.WHITE);
|
||||
ArrayList<BarDataSet> barDataSets = new ArrayList<BarDataSet>();
|
||||
barDataSets.add(barDataSet);
|
||||
BarData barData = new BarData(xVals,barDataSets);
|
||||
//ArrayList<BarDataSet> barDataSets = new ArrayList<BarDataSet>();
|
||||
//barDataSets.add(barDataSet);
|
||||
BarData barData = new BarData(xVals,barDataSet);
|
||||
mChart.setData(barData);
|
||||
|
||||
XAxis xAxis = mChart.getXAxis();
|
||||
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
|
||||
xAxis.setTextSize(30f);
|
||||
xAxis.setDrawAxisLine(true);
|
||||
xAxis.setDrawLabels(true);
|
||||
xAxis.setEnabled(true);
|
||||
xAxis.setDrawGridLines(false);
|
||||
|
||||
YAxis yAxis = mChart.getAxisLeft();
|
||||
yAxis.setAxisMinValue(0f);
|
||||
yAxis.setAxisMaxValue(3000f);
|
||||
yAxis.setDrawGridLines(true);
|
||||
|
||||
YAxis yAxis2 = mChart.getAxisRight();
|
||||
yAxis2.setDrawGridLines(false);
|
||||
|
||||
//data.setValueTextSize(10f);
|
||||
//mChart.setData(data);
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
@@ -72,6 +73,10 @@ public class StartupActivity extends Activity {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new OsdUncaughtExceptionHandler(StartupActivity.this));
|
||||
//int i = 5/0; // Force exception to test handler.
|
||||
|
||||
// Force the screen to stay on when the app is running
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
|
||||
setContentView(R.layout.startup_activity);
|
||||
mUtil = new OsdUtil(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user