private void displayCurrentInfoFromReading(BgReading lastBgReading, boolean predictive) { double estimate = 0; if ((new Date().getTime()) - (60000 * 11) - lastBgReading.timestamp > 0) { notificationText.setText("Signal Missed"); if (!predictive) { estimate = lastBgReading.calculated_value; } else { estimate = BgReading.estimated_bg(lastBgReading.timestamp + (6000 * 7)); } currentBgValueText.setText(bgGraphBuilder.unitized_string(estimate)); currentBgValueText.setPaintFlags( currentBgValueText.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); dexbridgeBattery.setPaintFlags( dexbridgeBattery.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } else { if (notificationText.getText().length() == 0) { notificationText.setTextColor(Color.WHITE); } if (!predictive) { estimate = lastBgReading.calculated_value; String stringEstimate = bgGraphBuilder.unitized_string(estimate); String slope_arrow = lastBgReading.slopeArrow(); if (lastBgReading.hide_slope) { slope_arrow = ""; } currentBgValueText.setText(stringEstimate + " " + slope_arrow); } else { estimate = BgReading.activePrediction(); String stringEstimate = bgGraphBuilder.unitized_string(estimate); currentBgValueText.setText(stringEstimate + " " + BgReading.activeSlopeArrow()); } } int minutes = (int) (System.currentTimeMillis() - lastBgReading.timestamp) / (60 * 1000); notificationText.append("\n" + minutes + ((minutes == 1) ? " Minute ago" : " Minutes ago")); List<BgReading> bgReadingList = BgReading.latest(2); if (bgReadingList != null && bgReadingList.size() == 2) { // same logic as in xDripWidget (refactor that to BGReadings to avoid redundancy / later // inconsistencies)? if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) { notificationText.append(" "); } else { notificationText.append("\n"); } notificationText.append(bgGraphBuilder.unitizedDeltaString(true, true)); } if (bgGraphBuilder.unitized(estimate) <= bgGraphBuilder.lowMark) { currentBgValueText.setTextColor(Color.parseColor("#C30909")); } else if (bgGraphBuilder.unitized(estimate) >= bgGraphBuilder.highMark) { currentBgValueText.setTextColor(Color.parseColor("#FFBB33")); } else { currentBgValueText.setTextColor(Color.WHITE); } }