catch NPE
This commit is contained in:
parent
05125af9e7
commit
6bc1549a91
1 changed files with 15 additions and 2 deletions
|
@ -4,6 +4,7 @@ import com.jjoe64.graphview.DefaultLabelFormatter;
|
|||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by mike on 09.06.2016.
|
||||
|
@ -20,10 +21,22 @@ public class TimeAsXAxisLabelFormatter extends DefaultLabelFormatter {
|
|||
public String formatLabel(double value, boolean isValueX) {
|
||||
if (isValueX) {
|
||||
// format as date
|
||||
DateFormat dateFormat = new SimpleDateFormat(mFormat);
|
||||
DateFormat dateFormat = new SimpleDateFormat(mFormat, Locale.getDefault());
|
||||
return dateFormat.format((long) value);
|
||||
} else {
|
||||
return super.formatLabel(value, isValueX);
|
||||
try {
|
||||
// unknown reason for crashing on this
|
||||
// Fatal Exception: java.lang.NullPointerException
|
||||
// Attempt to invoke virtual method 'double com.jjoe64.graphview.Viewport.getMaxY(boolean)' on a null object reference
|
||||
// com.jjoe64.graphview.DefaultLabelFormatter.formatLabel (DefaultLabelFormatter.java:89)
|
||||
// info.nightscout.androidaps.plugins.general.overview.graphExtensions.TimeAsXAxisLabelFormatter.formatLabel (TimeAsXAxisLabelFormatter.java:26)
|
||||
// com.jjoe64.graphview.GridLabelRenderer.drawVerticalSteps (GridLabelRenderer.java:1057)
|
||||
// com.jjoe64.graphview.GridLabelRenderer.draw (GridLabelRenderer.java:866)
|
||||
// com.jjoe64.graphview.GraphView.onDraw (GraphView.java:296)
|
||||
return super.formatLabel(value, isValueX);
|
||||
} catch (Exception ignored) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue