1
- package info .nightscout .core .graph .data ;
1
+ package info.nightscout.core.graph.data
2
2
3
- import com .jjoe64 .graphview .DefaultLabelFormatter ;
4
-
5
- import java .text .DateFormat ;
6
- import java .text .SimpleDateFormat ;
7
- import java .util .Locale ;
3
+ import com.jjoe64.graphview.DefaultLabelFormatter
4
+ import java.text.DateFormat
5
+ import java.text.SimpleDateFormat
6
+ import java.util.Locale
8
7
9
8
/* *
10
9
* Created by mike on 09.06.2016.
11
10
*/
12
- public class TimeAsXAxisLabelFormatter extends DefaultLabelFormatter {
13
-
14
- protected final String mFormat ;
15
-
16
- public TimeAsXAxisLabelFormatter (String format ) {
17
- mFormat = format ;
18
- }
11
+ class TimeAsXAxisLabelFormatter (private val format : String ) : DefaultLabelFormatter() {
19
12
20
- @ Override
21
- public String formatLabel (double value , boolean isValueX ) {
13
+ override fun formatLabel (value : Double , isValueX : Boolean ): String =
22
14
if (isValueX) {
23
15
// format as date
24
- DateFormat dateFormat = new SimpleDateFormat (mFormat , Locale .getDefault ());
25
- return dateFormat .format (( long ) value );
16
+ val dateFormat: DateFormat = SimpleDateFormat (format , Locale .getDefault())
17
+ dateFormat.format(value.toLong())
26
18
} else {
27
19
try {
28
20
// unknown reason for crashing on this
@@ -33,11 +25,9 @@ public String formatLabel(double value, boolean isValueX) {
33
25
// com.jjoe64.graphview.GridLabelRenderer.drawVerticalSteps (GridLabelRenderer.java:1057)
34
26
// com.jjoe64.graphview.GridLabelRenderer.draw (GridLabelRenderer.java:866)
35
27
// com.jjoe64.graphview.GraphView.onDraw (GraphView.java:296)
36
- //noinspection ConstantConditions
37
- return super .formatLabel (value , isValueX );
38
- } catch (Exception ignored ) {
39
- return "" ;
28
+ super .formatLabel(value, false )
29
+ } catch (ignored: Exception ) {
30
+ " "
40
31
}
41
32
}
42
- }
43
33
}
0 commit comments