decibelChart.postDelayed(new Runnable() {
@Override
public void run() {
int chartValue;
decibelChart.setNoDataText("Drawing Decibel Chart Error !");
decibelChart.setDragEnabled(false);
decibelChart.setScaleEnabled(false);
decibelChart.setDrawGridBackground(false);
decibelChart.setPinchZoom(false);
decibelChart.setBackgroundColor(Color.TRANSPARENT);
decibelChart.setData(lineData);
if (mediaRecorderForDB != null) {
chartValue = mediaRecorderForDB.getMaxAmplitude();
} else if (mediaRecorder != null) {
chartValue = mediaRecorder.getMaxAmplitude();
} else
chartValue = 0;
LineData myData = decibelChart.getData();
if (myData != null) {
ILineDataSet set = myData.getDataSetByIndex(0);
if (set == null){
LineDataSet dataSet = new LineDataSet(null,"Dynamic");
dataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
dataSet.setLineWidth(3f);
dataSet.setColor(Color.WHITE);
dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
dataSet.setCubicIntensity(1f);
myData.addDataSet(dataSet);
}
myData.addEntry(new Entry(set.getEntryCount(), chartValue + 5), 0);
myData.notifyDataChanged();
decibelChart.setMaxVisibleValueCount(150);
decibelChart.moveViewToX(myData.getEntryCount());
}
Log.e("[CHART_ERROR]", "CHART DRAWING");
}
},250);
set.getEntryCount()
returns null and throws exception. How can i get over it ? I tried a lot things but cannot achived.
The values are coming from the microphone they are decibel values. I want to draw a line chart for these values.