TimeAsXAxisLabelFormatter -> kt
This commit is contained in:
parent
83fc6a0490
commit
06e8e00d37
1 changed files with 12 additions and 22 deletions
|
@ -1,28 +1,20 @@
|
||||||
package info.nightscout.core.graph.data;
|
package info.nightscout.core.graph.data
|
||||||
|
|
||||||
import com.jjoe64.graphview.DefaultLabelFormatter;
|
import com.jjoe64.graphview.DefaultLabelFormatter
|
||||||
|
import java.text.DateFormat
|
||||||
import java.text.DateFormat;
|
import java.text.SimpleDateFormat
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.Locale
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 09.06.2016.
|
* Created by mike on 09.06.2016.
|
||||||
*/
|
*/
|
||||||
public class TimeAsXAxisLabelFormatter extends DefaultLabelFormatter {
|
class TimeAsXAxisLabelFormatter(private val format: String) : DefaultLabelFormatter() {
|
||||||
|
|
||||||
protected final String mFormat;
|
override fun formatLabel(value: Double, isValueX: Boolean): String =
|
||||||
|
|
||||||
public TimeAsXAxisLabelFormatter(String format) {
|
|
||||||
mFormat = format;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String formatLabel(double value, boolean isValueX) {
|
|
||||||
if (isValueX) {
|
if (isValueX) {
|
||||||
// format as date
|
// format as date
|
||||||
DateFormat dateFormat = new SimpleDateFormat(mFormat, Locale.getDefault());
|
val dateFormat: DateFormat = SimpleDateFormat(format, Locale.getDefault())
|
||||||
return dateFormat.format((long) value);
|
dateFormat.format(value.toLong())
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// unknown reason for crashing on this
|
// unknown reason for crashing on this
|
||||||
|
@ -33,11 +25,9 @@ public class TimeAsXAxisLabelFormatter extends DefaultLabelFormatter {
|
||||||
// com.jjoe64.graphview.GridLabelRenderer.drawVerticalSteps (GridLabelRenderer.java:1057)
|
// com.jjoe64.graphview.GridLabelRenderer.drawVerticalSteps (GridLabelRenderer.java:1057)
|
||||||
// com.jjoe64.graphview.GridLabelRenderer.draw (GridLabelRenderer.java:866)
|
// com.jjoe64.graphview.GridLabelRenderer.draw (GridLabelRenderer.java:866)
|
||||||
// com.jjoe64.graphview.GraphView.onDraw (GraphView.java:296)
|
// com.jjoe64.graphview.GraphView.onDraw (GraphView.java:296)
|
||||||
//noinspection ConstantConditions
|
super.formatLabel(value, false)
|
||||||
return super.formatLabel(value, isValueX);
|
} catch (ignored: Exception) {
|
||||||
} catch (Exception ignored) {
|
""
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue