Search in sources :

Example 1 with StatsResult

use of com.eveningoutpost.dexdrip.stats.StatsResult in project xDrip by NightscoutFoundation.

the class Telemetry method sendCaptureReport.

/*

    No personal information is sent.

    Only the level of success in receiving sensor data and
    the make/model/version/settings/type of phone and collector used.

    This is to try to find any patterns relating to successful combinations, for example
    G5 collection working better with Samsung devices or not.

     */
public static void sendCaptureReport() {
    try {
        if (JoH.ratelimit("capture-report", 50000)) {
            Log.d(TAG, "SEND EVENT START");
            if (Pref.getBooleanDefaultFalse("enable_crashlytics") && Pref.getBooleanDefaultFalse("enable_telemetry")) {
                final Sensor sensor = Sensor.currentSensor();
                if (sensor != null) {
                    if (JoH.msSince(sensor.started_at) > 86400000) {
                        final StatsResult statsResult = new StatsResult(PreferenceManager.getDefaultSharedPreferences(xdrip.getAppContext()), true);
                        final int capture_percentage = statsResult.getCapturePercentage();
                        final int capture_set = (capture_percentage / 10) * 10;
                        if (capture_set > 60) {
                            final boolean use_transmiter_pl_bluetooth = Pref.getBooleanDefaultFalse("use_transmiter_pl_bluetooth");
                            final boolean use_rfduino_bluetooth = Pref.getBooleanDefaultFalse("use_rfduino_bluetooth");
                            final String subtype = (use_transmiter_pl_bluetooth ? "TR" : "") + (use_rfduino_bluetooth ? "RF" : "") + (Home.get_forced_wear() ? "W" : "") + (NFCReaderX.used_nfc_successfully ? "N" : "");
                            final String capture_id = DexCollectionType.getDexCollectionType().toString() + subtype + " Captured " + capture_set;
                            Log.d(TAG, "SEND CAPTURE EVENT PROCESS: " + capture_id);
                            String watch_model = "";
                            if (Home.get_forced_wear()) {
                                // anonymize watch model
                                final String wear_node = Pref.getStringDefaultBlank("node_wearG5");
                                if (wear_node.length() > 0) {
                                    final String[] wear_array = wear_node.split(" ");
                                    for (String ii : wear_array) {
                                        if (!ii.contains("|"))
                                            watch_model = watch_model + ii;
                                    }
                                }
                            }
                            if (watch_model.length() > 0) {
                                Answers.getInstance().logCustom(new CustomEvent(capture_id).putCustomAttribute("Model", Build.MODEL + " " + Build.VERSION.RELEASE).putCustomAttribute("Manufacturer", Build.MANUFACTURER).putCustomAttribute("Version", Build.VERSION.RELEASE).putCustomAttribute("xDrip", getVersionDetails()).putCustomAttribute("Watch", watch_model).putCustomAttribute("Percentage", capture_percentage));
                            } else {
                                Answers.getInstance().logCustom(new CustomEvent(capture_id).putCustomAttribute("Model", Build.MODEL + " " + Build.VERSION.RELEASE).putCustomAttribute("Manufacturer", Build.MANUFACTURER).putCustomAttribute("Version", Build.VERSION.RELEASE).putCustomAttribute("xDrip", getVersionDetails()).putCustomAttribute("Percentage", capture_percentage));
                            }
                        }
                    } else {
                        Log.d(TAG, "Sensor not running for more than 24 hours yet");
                    }
                } else {
                    Log.d(TAG, "No sensor active");
                }
                Log.d(TAG, "SEND EVENT DONE");
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "Got exception sending Capture Report");
    }
}
Also used : CustomEvent(com.crashlytics.android.answers.CustomEvent) StatsResult(com.eveningoutpost.dexdrip.stats.StatsResult) Sensor(com.eveningoutpost.dexdrip.Models.Sensor)

Example 2 with StatsResult

use of com.eveningoutpost.dexdrip.stats.StatsResult in project xDrip by NightscoutFoundation.

the class Home method extraStatusLine.

@NonNull
public static String extraStatusLine() {
    final StringBuilder extraline = new StringBuilder();
    final Calibration lastCalibration = Calibration.lastValid();
    if (Pref.getBoolean("status_line_calibration_long", false) && lastCalibration != null) {
        if (extraline.length() != 0)
            extraline.append(' ');
        extraline.append("slope = ");
        extraline.append(String.format("%.2f", lastCalibration.slope));
        extraline.append(' ');
        extraline.append("inter = ");
        extraline.append(String.format("%.2f", lastCalibration.intercept));
    }
    if (Pref.getBoolean("status_line_calibration_short", false) && lastCalibration != null) {
        if (extraline.length() != 0)
            extraline.append(' ');
        extraline.append("s:");
        extraline.append(String.format("%.2f", lastCalibration.slope));
        extraline.append(' ');
        extraline.append("i:");
        extraline.append(String.format("%.2f", lastCalibration.intercept));
    }
    if (Pref.getBoolean("status_line_avg", false) || Pref.getBoolean("status_line_a1c_dcct", false) || Pref.getBoolean("status_line_a1c_ifcc", false) || Pref.getBoolean("status_line_in", false) || Pref.getBoolean("status_line_high", false) || Pref.getBoolean("status_line_low", false) || Pref.getBoolean("status_line_stdev", false) || Pref.getBoolean("status_line_carbs", false) || Pref.getBoolean("status_line_insulin", false) || Pref.getBoolean("status_line_royce_ratio", false) || Pref.getBoolean("status_line_accuracy", false) || Pref.getBoolean("status_line_capture_percentage", false) || Pref.getBoolean("status_line_pump_reservoir", false)) {
        final StatsResult statsResult = new StatsResult(Pref.getInstance(), Pref.getBooleanDefaultFalse("extra_status_stats_24h"));
        if (Pref.getBoolean("status_line_avg", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getAverageUnitised());
        }
        if (Pref.getBoolean("status_line_a1c_dcct", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getA1cDCCT());
        }
        if (Pref.getBoolean("status_line_a1c_ifcc", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getA1cIFCC());
        }
        if (Pref.getBoolean("status_line_in", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getInPercentage());
        }
        if (Pref.getBoolean("status_line_high", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getHighPercentage());
        }
        if (Pref.getBoolean("status_line_low", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getLowPercentage());
        }
        if (Pref.getBoolean("status_line_stdev", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getStdevUnitised());
        }
        if (Pref.getBoolean("status_line_carbs", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            // extraline.append("Carbs: " + statsResult.getTotal_carbs());
            extraline.append("Carbs:" + Math.round(statsResult.getTotal_carbs()));
        }
        if (Pref.getBoolean("status_line_insulin", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append("U:" + JoH.qs(statsResult.getTotal_insulin(), 2));
        }
        if (Pref.getBoolean("status_line_royce_ratio", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append("C/I:" + JoH.qs(statsResult.getRatio(), 2));
        }
        if (Pref.getBoolean("status_line_capture_percentage", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getCapturePercentage(false));
        }
        if (Pref.getBoolean("status_line_accuracy", false)) {
            final long accuracy_period = DAY_IN_MS * 3;
            if (extraline.length() != 0)
                extraline.append(' ');
            final String accuracy_report = Accuracy.evaluateAccuracy(accuracy_period);
            if ((accuracy_report != null) && (accuracy_report.length() > 0)) {
                extraline.append(accuracy_report);
            } else {
                final String accuracy = BloodTest.evaluateAccuracy(accuracy_period);
                extraline.append(((accuracy != null) ? " " + accuracy : ""));
            }
        }
        if (Pref.getBoolean("status_line_pump_reservoir", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(PumpStatus.getBolusIoBString());
            extraline.append(PumpStatus.getReservoirString());
            extraline.append(PumpStatus.getBatteryString());
        }
    }
    if (Pref.getBoolean("extra_status_calibration_plugin", false)) {
        // make sure do this only once
        final CalibrationAbstract plugin = getCalibrationPluginFromPreferences();
        if (plugin != null) {
            final CalibrationAbstract.CalibrationData pcalibration = plugin.getCalibrationData();
            // not tested on the widget yet
            if (extraline.length() > 0)
                extraline.append("\n");
            if (pcalibration != null)
                extraline.append("(" + plugin.getAlgorithmName() + ") s:" + JoH.qs(pcalibration.slope, 2) + " i:" + JoH.qs(pcalibration.intercept, 2));
            BgReading bgReading = BgReading.last();
            if (bgReading != null) {
                final boolean doMgdl = Pref.getString("units", "mgdl").equals("mgdl");
                extraline.append(" \u21D2 " + BgGraphBuilder.unitized_string(plugin.getGlucoseFromSensorValue(bgReading.age_adjusted_raw_value), doMgdl) + " " + BgGraphBuilder.unit(doMgdl));
            }
        }
        // If we are using the plugin as the primary then show xdrip original as well
        if (Pref.getBooleanDefaultFalse("display_glucose_from_plugin") || Pref.getBooleanDefaultFalse("use_pluggable_alg_as_primary")) {
            // make sure do this only once
            final CalibrationAbstract plugin_xdrip = getCalibrationPlugin(PluggableCalibration.Type.xDripOriginal);
            if (plugin_xdrip != null) {
                final CalibrationAbstract.CalibrationData pcalibration = plugin_xdrip.getCalibrationData();
                if (extraline.length() > 0)
                    // not tested on the widget yet
                    extraline.append("\n");
                if (pcalibration != null)
                    extraline.append("(" + plugin_xdrip.getAlgorithmName() + ") s:" + JoH.qs(pcalibration.slope, 2) + " i:" + JoH.qs(pcalibration.intercept, 2));
                BgReading bgReading = BgReading.last();
                if (bgReading != null) {
                    final boolean doMgdl = Pref.getString("units", "mgdl").equals("mgdl");
                    extraline.append(" \u21D2 " + BgGraphBuilder.unitized_string(plugin_xdrip.getGlucoseFromSensorValue(bgReading.age_adjusted_raw_value), doMgdl) + " " + BgGraphBuilder.unit(doMgdl));
                }
            }
        }
    }
    if (Pref.getBoolean("status_line_time", false)) {
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
        if (extraline.length() != 0)
            extraline.append(' ');
        extraline.append(sdf.format(new Date()));
    }
    return extraline.toString();
}
Also used : CalibrationAbstract(com.eveningoutpost.dexdrip.calibrations.CalibrationAbstract) Calibration(com.eveningoutpost.dexdrip.Models.Calibration) PluggableCalibration(com.eveningoutpost.dexdrip.calibrations.PluggableCalibration) BgReading(com.eveningoutpost.dexdrip.Models.BgReading) SimpleDateFormat(java.text.SimpleDateFormat) StatsResult(com.eveningoutpost.dexdrip.stats.StatsResult) Date(java.util.Date) NonNull(android.support.annotation.NonNull)

Example 3 with StatsResult

use of com.eveningoutpost.dexdrip.stats.StatsResult in project xDrip-plus by jamorham.

the class Home method extraStatusLine.

@NonNull
public static String extraStatusLine() {
    final StringBuilder extraline = new StringBuilder();
    final Calibration lastCalibration = Calibration.lastValid();
    if (Pref.getBoolean("status_line_calibration_long", false) && lastCalibration != null) {
        if (extraline.length() != 0)
            extraline.append(' ');
        extraline.append("slope = ");
        extraline.append(String.format("%.2f", lastCalibration.slope));
        extraline.append(' ');
        extraline.append("inter = ");
        extraline.append(String.format("%.2f", lastCalibration.intercept));
    }
    if (Pref.getBoolean("status_line_calibration_short", false) && lastCalibration != null) {
        if (extraline.length() != 0)
            extraline.append(' ');
        extraline.append("s:");
        extraline.append(String.format("%.2f", lastCalibration.slope));
        extraline.append(' ');
        extraline.append("i:");
        extraline.append(String.format("%.2f", lastCalibration.intercept));
    }
    if (Pref.getBoolean("status_line_avg", false) || Pref.getBoolean("status_line_a1c_dcct", false) || Pref.getBoolean("status_line_a1c_ifcc", false) || Pref.getBoolean("status_line_in", false) || Pref.getBoolean("status_line_high", false) || Pref.getBoolean("status_line_low", false) || Pref.getBoolean("status_line_stdev", false) || Pref.getBoolean("status_line_carbs", false) || Pref.getBoolean("status_line_insulin", false) || Pref.getBoolean("status_line_royce_ratio", false) || Pref.getBoolean("status_line_accuracy", false) || Pref.getBoolean("status_line_capture_percentage", false) || Pref.getBoolean("status_line_pump_reservoir", false)) {
        final StatsResult statsResult = new StatsResult(Pref.getInstance(), Pref.getBooleanDefaultFalse("extra_status_stats_24h"));
        if (Pref.getBoolean("status_line_avg", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getAverageUnitised());
        }
        if (Pref.getBoolean("status_line_a1c_dcct", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getA1cDCCT());
        }
        if (Pref.getBoolean("status_line_a1c_ifcc", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getA1cIFCC());
        }
        if (Pref.getBoolean("status_line_in", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getInPercentage());
        }
        if (Pref.getBoolean("status_line_high", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getHighPercentage());
        }
        if (Pref.getBoolean("status_line_low", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getLowPercentage());
        }
        if (Pref.getBoolean("status_line_stdev", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getStdevUnitised());
        }
        if (Pref.getBoolean("status_line_carbs", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            // extraline.append("Carbs: " + statsResult.getTotal_carbs());
            extraline.append("Carbs:" + Math.round(statsResult.getTotal_carbs()));
        }
        if (Pref.getBoolean("status_line_insulin", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append("U:" + JoH.qs(statsResult.getTotal_insulin(), 2));
        }
        if (Pref.getBoolean("status_line_royce_ratio", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append("C/I:" + JoH.qs(statsResult.getRatio(), 2));
        }
        if (Pref.getBoolean("status_line_capture_percentage", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(statsResult.getCapturePercentage(false));
        }
        if (Pref.getBoolean("status_line_accuracy", false)) {
            final long accuracy_period = DAY_IN_MS * 3;
            if (extraline.length() != 0)
                extraline.append(' ');
            final String accuracy_report = Accuracy.evaluateAccuracy(accuracy_period);
            if ((accuracy_report != null) && (accuracy_report.length() > 0)) {
                extraline.append(accuracy_report);
            } else {
                final String accuracy = BloodTest.evaluateAccuracy(accuracy_period);
                extraline.append(((accuracy != null) ? " " + accuracy : ""));
            }
        }
        if (Pref.getBoolean("status_line_pump_reservoir", false)) {
            if (extraline.length() != 0)
                extraline.append(' ');
            extraline.append(PumpStatus.getBolusIoBString());
            extraline.append(PumpStatus.getReservoirString());
            extraline.append(PumpStatus.getBatteryString());
        }
    }
    if (Pref.getBoolean("extra_status_calibration_plugin", false)) {
        // make sure do this only once
        final CalibrationAbstract plugin = getCalibrationPluginFromPreferences();
        if (plugin != null) {
            final CalibrationAbstract.CalibrationData pcalibration = plugin.getCalibrationData();
            // not tested on the widget yet
            if (extraline.length() > 0)
                extraline.append("\n");
            if (pcalibration != null)
                extraline.append("(" + plugin.getAlgorithmName() + ") s:" + JoH.qs(pcalibration.slope, 2) + " i:" + JoH.qs(pcalibration.intercept, 2));
            BgReading bgReading = BgReading.last();
            if (bgReading != null) {
                final boolean doMgdl = Pref.getString("units", "mgdl").equals("mgdl");
                extraline.append(" \u21D2 " + BgGraphBuilder.unitized_string(plugin.getGlucoseFromSensorValue(bgReading.age_adjusted_raw_value), doMgdl) + " " + BgGraphBuilder.unit(doMgdl));
            }
        }
        // If we are using the plugin as the primary then show xdrip original as well
        if (Pref.getBooleanDefaultFalse("display_glucose_from_plugin") || Pref.getBooleanDefaultFalse("use_pluggable_alg_as_primary")) {
            // make sure do this only once
            final CalibrationAbstract plugin_xdrip = getCalibrationPlugin(PluggableCalibration.Type.xDripOriginal);
            if (plugin_xdrip != null) {
                final CalibrationAbstract.CalibrationData pcalibration = plugin_xdrip.getCalibrationData();
                if (extraline.length() > 0)
                    // not tested on the widget yet
                    extraline.append("\n");
                if (pcalibration != null)
                    extraline.append("(" + plugin_xdrip.getAlgorithmName() + ") s:" + JoH.qs(pcalibration.slope, 2) + " i:" + JoH.qs(pcalibration.intercept, 2));
                BgReading bgReading = BgReading.last();
                if (bgReading != null) {
                    final boolean doMgdl = Pref.getString("units", "mgdl").equals("mgdl");
                    extraline.append(" \u21D2 " + BgGraphBuilder.unitized_string(plugin_xdrip.getGlucoseFromSensorValue(bgReading.age_adjusted_raw_value), doMgdl) + " " + BgGraphBuilder.unit(doMgdl));
                }
            }
        }
    }
    if (Pref.getBoolean("status_line_time", false)) {
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
        if (extraline.length() != 0)
            extraline.append(' ');
        extraline.append(sdf.format(new Date()));
    }
    return extraline.toString();
}
Also used : CalibrationAbstract(com.eveningoutpost.dexdrip.calibrations.CalibrationAbstract) Calibration(com.eveningoutpost.dexdrip.Models.Calibration) PluggableCalibration(com.eveningoutpost.dexdrip.calibrations.PluggableCalibration) BgReading(com.eveningoutpost.dexdrip.Models.BgReading) SimpleDateFormat(java.text.SimpleDateFormat) StatsResult(com.eveningoutpost.dexdrip.stats.StatsResult) Date(java.util.Date) NonNull(android.support.annotation.NonNull)

Example 4 with StatsResult

use of com.eveningoutpost.dexdrip.stats.StatsResult in project xDrip-plus by jamorham.

the class BGHistory method setupStatistics.

private void setupStatistics(long from, long to) {
    if (Pref.getBoolean("show_history_stats", true)) {
        StatsResult statsResult = new StatsResult(PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()), from, to);
        StringBuilder sb = new StringBuilder();
        sb.append(statsResult.getAverageUnitised());
        sb.append(' ');
        sb.append(statsResult.getA1cDCCT());
        sb.append(" | ");
        sb.append(statsResult.getA1cIFCC(true));
        sb.append('\n');
        sb.append(statsResult.getInPercentage());
        sb.append(' ');
        sb.append(statsResult.getHighPercentage());
        sb.append(' ');
        sb.append(statsResult.getLowPercentage());
        sb.append(' ');
        sb.append(statsResult.getStdevUnitised());
        sb.append(' ');
        sb.append(statsResult.getGVI());
        DecimalFormat df = new DecimalFormat(getResources().getString(R.string.format_decimal_treatments));
        if (Pref.getBoolean("status_line_insulin", true)) {
            sb.append('\n');
            double insulin = statsResult.getTotal_insulin();
            sb.append(getResources().getString(R.string.label_show_insulin, df.format(insulin)));
        }
        if (Pref.getBoolean("status_line_carbs", true)) {
            sb.append(' ');
            double carbs = statsResult.getTotal_carbs();
            sb.append(getResources().getString(R.string.label_show_carbs, df.format(carbs)));
        }
        if (Pref.getBoolean("status_line_royce_ratio", false)) {
            sb.append(' ');
            double ratio = statsResult.getRatio();
            sb.append(getResources().getString(R.string.label_show_royceratio, df.format(ratio)));
        }
        if (Pref.getBoolean("use_pebble_health", true)) {
            sb.append('\n');
            int steps = statsResult.getTotal_steps();
            sb.append(getResources().getString(R.string.label_show_steps, steps));
            if (steps > 0) {
                Double km = (((double) steps) / 2000.0d) * 1.6d;
                Double mi = (((double) steps) / 2000.0d) * 1.0d;
                sb.append((km > 0.0 ? " " + getResources().getString(R.string.label_show_steps_km, df.format(km)) : "") + (mi > 0.0 ? " " + getResources().getString(R.string.label_show_steps_mi, df.format(mi)) : ""));
            }
        }
        sb.append('\n');
        sb.append(statsResult.getCapturePercentage(true));
        sb.append(' ');
        statisticsTextView.setText(sb);
        statisticsTextView.setVisibility(View.VISIBLE);
    } else {
        statisticsTextView.setVisibility(View.GONE);
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) StatsResult(com.eveningoutpost.dexdrip.stats.StatsResult)

Example 5 with StatsResult

use of com.eveningoutpost.dexdrip.stats.StatsResult in project xDrip by NightscoutFoundation.

the class BGHistory method setupStatistics.

private void setupStatistics(long from, long to) {
    if (Pref.getBoolean("show_history_stats", true)) {
        StatsResult statsResult = new StatsResult(PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()), from, to);
        StringBuilder sb = new StringBuilder();
        sb.append(statsResult.getAverageUnitised());
        sb.append(' ');
        sb.append(statsResult.getA1cDCCT());
        sb.append(" | ");
        sb.append(statsResult.getA1cIFCC(true));
        sb.append('\n');
        sb.append(statsResult.getInPercentage());
        sb.append(' ');
        sb.append(statsResult.getHighPercentage());
        sb.append(' ');
        sb.append(statsResult.getLowPercentage());
        sb.append(' ');
        sb.append(statsResult.getStdevUnitised());
        sb.append(' ');
        sb.append(statsResult.getGVI());
        DecimalFormat df = new DecimalFormat(getResources().getString(R.string.format_decimal_treatments));
        if (Pref.getBoolean("status_line_insulin", true)) {
            sb.append('\n');
            double insulin = statsResult.getTotal_insulin();
            sb.append(getResources().getString(R.string.label_show_insulin, df.format(insulin)));
        }
        if (Pref.getBoolean("status_line_carbs", true)) {
            sb.append(' ');
            double carbs = statsResult.getTotal_carbs();
            sb.append(getResources().getString(R.string.label_show_carbs, df.format(carbs)));
        }
        if (Pref.getBoolean("status_line_royce_ratio", false)) {
            sb.append(' ');
            double ratio = statsResult.getRatio();
            sb.append(getResources().getString(R.string.label_show_royceratio, df.format(ratio)));
        }
        if (Pref.getBoolean("use_pebble_health", true)) {
            sb.append('\n');
            int steps = statsResult.getTotal_steps();
            sb.append(getResources().getString(R.string.label_show_steps, steps));
            if (steps > 0) {
                Double km = (((double) steps) / 2000.0d) * 1.6d;
                Double mi = (((double) steps) / 2000.0d) * 1.0d;
                sb.append((km > 0.0 ? " " + getResources().getString(R.string.label_show_steps_km, df.format(km)) : "") + (mi > 0.0 ? " " + getResources().getString(R.string.label_show_steps_mi, df.format(mi)) : ""));
            }
        }
        sb.append('\n');
        sb.append(statsResult.getCapturePercentage(true));
        sb.append(' ');
        statisticsTextView.setText(sb);
        statisticsTextView.setVisibility(View.VISIBLE);
    } else {
        statisticsTextView.setVisibility(View.GONE);
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) StatsResult(com.eveningoutpost.dexdrip.stats.StatsResult)

Aggregations

StatsResult (com.eveningoutpost.dexdrip.stats.StatsResult)8 NonNull (android.support.annotation.NonNull)4 Calibration (com.eveningoutpost.dexdrip.Models.Calibration)4 CustomEvent (com.crashlytics.android.answers.CustomEvent)2 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)2 Sensor (com.eveningoutpost.dexdrip.Models.Sensor)2 CalibrationAbstract (com.eveningoutpost.dexdrip.calibrations.CalibrationAbstract)2 PluggableCalibration (com.eveningoutpost.dexdrip.calibrations.PluggableCalibration)2 DecimalFormat (java.text.DecimalFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2