use of com.eveningoutpost.dexdrip.Models.BgReading in project xDrip-plus by jamorham.
the class Home method displayCurrentInfo.
private void displayCurrentInfo() {
DecimalFormat df = new DecimalFormat("#");
df.setMaximumFractionDigits(0);
final boolean isDexbridge = CollectionServiceStarter.isDexBridgeOrWifiandDexBridge();
// final boolean hasBtWixel = DexCollectionType.hasBtWixel();
final boolean isLimitter = CollectionServiceStarter.isLimitter();
// if (isDexbridge||isLimitter||hasBtWixel||is_follower) {
if (DexCollectionType.hasBattery()) {
final int bridgeBattery = Pref.getInt("bridge_battery", 0);
if (bridgeBattery < 1) {
// dexbridgeBattery.setText(R.string.waiting_for_packet);
dexbridgeBattery.setVisibility(View.INVISIBLE);
} else {
if (isDexbridge) {
dexbridgeBattery.setText(getString(R.string.xbridge_battery) + ": " + bridgeBattery + "%");
} else if (isLimitter) {
final String limitterName = DexCollectionService.getBestLimitterHardwareName();
if (limitterName.equals(DexCollectionService.LIMITTER_NAME)) {
dexbridgeBattery.setText(getString(R.string.limitter_battery) + ": " + bridgeBattery + "%");
} else {
dexbridgeBattery.setText(limitterName + " " + getString(R.string.battery) + ": " + bridgeBattery + "%");
}
} else {
dexbridgeBattery.setText("Bridge battery" + ": " + bridgeBattery + ((bridgeBattery < 200) ? "%" : "mV"));
}
}
if (bridgeBattery < 50)
dexbridgeBattery.setTextColor(Color.YELLOW);
if (bridgeBattery < 25)
dexbridgeBattery.setTextColor(Color.RED);
else
dexbridgeBattery.setTextColor(Color.GREEN);
dexbridgeBattery.setVisibility(View.VISIBLE);
} else {
dexbridgeBattery.setVisibility(View.INVISIBLE);
}
if (DexCollectionType.hasWifi()) {
final int bridgeBattery = Pref.getInt("parakeet_battery", 0);
if (bridgeBattery > 0) {
if (bridgeBattery < 50) {
parakeetBattery.setText(getString(R.string.parakeet_battery) + ": " + bridgeBattery + "%");
if (bridgeBattery < 40) {
parakeetBattery.setTextColor(Color.RED);
} else {
parakeetBattery.setTextColor(Color.YELLOW);
}
parakeetBattery.setVisibility(View.VISIBLE);
} else {
parakeetBattery.setVisibility(View.INVISIBLE);
}
}
} else {
parakeetBattery.setVisibility(View.INVISIBLE);
}
if (!Pref.getBoolean("display_bridge_battery", true)) {
dexbridgeBattery.setVisibility(View.INVISIBLE);
parakeetBattery.setVisibility(View.INVISIBLE);
}
final int sensor_age = Pref.getInt("nfc_sensor_age", 0);
if ((sensor_age > 0) && (DexCollectionType.hasLibre())) {
final String age_problem = (Pref.getBooleanDefaultFalse("nfc_age_problem") ? " \u26A0\u26A0\u26A0" : "");
if (Pref.getBoolean("nfc_show_age", true)) {
sensorAge.setText("Age: " + JoH.qs(((double) sensor_age) / 1440, 1) + "d" + age_problem);
} else {
try {
final double expires = JoH.tolerantParseDouble(Pref.getString("nfc_expiry_days", "14.5")) - ((double) sensor_age) / 1440;
sensorAge.setText(((expires >= 0) ? ("Expires: " + JoH.qs(expires, 1) + "d") : "EXPIRED! ") + age_problem);
} catch (Exception e) {
Log.e(TAG, "expiry calculation: " + e);
sensorAge.setText("Expires: " + "???");
}
}
sensorAge.setVisibility(View.VISIBLE);
if (sensor_age < 1440) {
sensorAge.setTextColor(Color.YELLOW);
} else if (sensor_age < (1440 * 12)) {
sensorAge.setTextColor(Color.GREEN);
} else {
sensorAge.setTextColor(Color.RED);
}
} else {
sensorAge.setVisibility(View.GONE);
}
if (blockTouches) {
sensorAge.setText("SCANNING.. DISPLAY LOCKED!");
sensorAge.setVisibility(View.VISIBLE);
sensorAge.setTextColor(Color.GREEN);
}
if ((currentBgValueText.getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) > 0) {
currentBgValueText.setPaintFlags(currentBgValueText.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
dexbridgeBattery.setPaintFlags(dexbridgeBattery.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
if (get_follower()) {
GcmActivity.requestPing();
}
}
final BgReading lastBgReading = BgReading.lastNoSenssor();
boolean predictive = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("predictive_bg", false);
if (isBTShare) {
predictive = false;
}
if (lastBgReading != null) {
// detect broken data from G5 or other sources
if ((lastBgReading.raw_data != 0) && (lastBgReading.raw_data * 2 == lastBgReading.filtered_data)) {
if (JoH.ratelimit("g5-corrupt-data-warning", 1200)) {
final String msg = "filtered data is exactly double raw sensor data which looks wrong! (Transmitter maybe dead)" + lastBgReading.raw_data;
toaststaticnext(msg);
}
}
displayCurrentInfoFromReading(lastBgReading, predictive);
} else {
display_delta = "";
}
if (Pref.getBoolean("extra_status_line", false)) {
extraStatusLineText.setText(extraStatusLine());
extraStatusLineText.setVisibility(View.VISIBLE);
} else {
extraStatusLineText.setText("");
extraStatusLineText.setVisibility(View.GONE);
}
}
Aggregations