Java Code Examples for com.eveningoutpost.dexdrip.Models.BgReading#lastNoSenssor()
The following examples show how to use
com.eveningoutpost.dexdrip.Models.BgReading#lastNoSenssor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShareFollowService.java From xDrip with GNU General Public License v3.0 | 5 votes |
static void scheduleWakeUp() { final BgReading lastBg = BgReading.lastNoSenssor(); final long last = lastBg != null ? lastBg.timestamp : 0; final long grace = Constants.SECOND_IN_MS * 10; final long next = Anticipate.next(JoH.tsl(), last, SAMPLE_PERIOD, grace) + grace; wakeup_time = next; UserError.Log.d(TAG, "Anticipate next: " + JoH.dateTimeText(next) + " last: " + JoH.dateTimeText(last)); JoH.wakeUpIntent(xdrip.getAppContext(), JoH.msTill(next), WakeLockTrampoline.getPendingIntent(ShareFollowService.class, Constants.SHFOLLOW_SERVICE_FAILOVER_ID)); }
Example 2
Source File: ShareFollowService.java From xDrip with GNU General Public License v3.0 | 5 votes |
/** * Update observedDelay if new bg reading is available */ static void updateBgReceiveDelay() { lastBg = BgReading.lastNoSenssor(); if (lastBg != null && lastBgTime != lastBg.timestamp) { bgReceiveDelay = JoH.msSince(lastBg.timestamp); lastBgTime = lastBg.timestamp; } }
Example 3
Source File: NightscoutFollowService.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { final PowerManager.WakeLock wl = JoH.getWakeLock("NSFollow-osc", 60000); try { UserError.Log.d(TAG, "WAKE UP WAKE UP WAKE UP"); // Check service should be running if (!shouldServiceRun()) { UserError.Log.d(TAG, "Stopping service due to shouldServiceRun() result"); // msg("Stopping"); stopSelf(); return START_NOT_STICKY; } buggySamsungCheck(); // Check current lastBg = BgReading.lastNoSenssor(); if (lastBg != null) { lastBgTime = lastBg.timestamp; } if (lastBg == null || JoH.msSince(lastBg.timestamp) > SAMPLE_PERIOD) { if (JoH.ratelimit("last-ns-follow-poll", 5)) { Inevitable.task("NS-Follow-Work", 200, () -> { NightscoutFollow.work(true); lastPoll = JoH.tsl(); }); } } else { UserError.Log.d(TAG, "Already have recent reading: " + JoH.msSince(lastBg.timestamp)); } scheduleWakeUp(); } finally { JoH.releaseWakeLock(wl); } return START_STICKY; }
Example 4
Source File: NightscoutFollowService.java From xDrip with GNU General Public License v3.0 | 5 votes |
/** * Update observedDelay if new bg reading is available */ static void updateBgReceiveDelay() { lastBg = BgReading.lastNoSenssor(); if (lastBg != null && lastBgTime != lastBg.timestamp) { bgReceiveDelay = JoH.msSince(lastBg.timestamp); lastBgTime = lastBg.timestamp; } }
Example 5
Source File: NightscoutFollowService.java From xDrip with GNU General Public License v3.0 | 5 votes |
static void scheduleWakeUp() { final BgReading lastBg = BgReading.lastNoSenssor(); final long last = lastBg != null ? lastBg.timestamp : 0; final long grace = Constants.SECOND_IN_MS * 10; final long next = Anticipate.next(JoH.tsl(), last, SAMPLE_PERIOD, grace) + grace; wakeup_time = next; UserError.Log.d(TAG, "Anticipate next: " + JoH.dateTimeText(next) + " last: " + JoH.dateTimeText(last)); JoH.wakeUpIntent(xdrip.getAppContext(), JoH.msTill(next), WakeLockTrampoline.getPendingIntent(NightscoutFollowService.class, Constants.NSFOLLOW_SERVICE_FAILOVER_ID)); }
Example 6
Source File: ShareFollowService.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
static void scheduleWakeUp() { final BgReading lastBg = BgReading.lastNoSenssor(); final long last = lastBg != null ? lastBg.timestamp : 0; final long grace = Constants.SECOND_IN_MS * 10; final long next = Anticipate.next(JoH.tsl(), last, SAMPLE_PERIOD, grace) + grace; wakeup_time = next; UserError.Log.d(TAG, "Anticipate next: " + JoH.dateTimeText(next) + " last: " + JoH.dateTimeText(last)); JoH.wakeUpIntent(xdrip.getAppContext(), JoH.msTill(next), WakeLockTrampoline.getPendingIntent(ShareFollowService.class, Constants.SHFOLLOW_SERVICE_FAILOVER_ID)); }
Example 7
Source File: ShareFollowService.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
/** * Update observedDelay if new bg reading is available */ static void updateBgReceiveDelay() { lastBg = BgReading.lastNoSenssor(); if (lastBg != null && lastBgTime != lastBg.timestamp) { bgReceiveDelay = JoH.msSince(lastBg.timestamp); lastBgTime = lastBg.timestamp; } }
Example 8
Source File: NightscoutFollowService.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { final PowerManager.WakeLock wl = JoH.getWakeLock("NSFollow-osc", 60000); try { UserError.Log.d(TAG, "WAKE UP WAKE UP WAKE UP"); // Check service should be running if (!shouldServiceRun()) { UserError.Log.d(TAG, "Stopping service due to shouldServiceRun() result"); // msg("Stopping"); stopSelf(); return START_NOT_STICKY; } buggySamsungCheck(); // Check current lastBg = BgReading.lastNoSenssor(); if (lastBg != null) { lastBgTime = lastBg.timestamp; } if (lastBg == null || JoH.msSince(lastBg.timestamp) > SAMPLE_PERIOD) { if (JoH.ratelimit("last-ns-follow-poll", 5)) { Inevitable.task("NS-Follow-Work", 200, () -> { NightscoutFollow.work(true); lastPoll = JoH.tsl(); }); } } else { UserError.Log.d(TAG, "Already have recent reading: " + JoH.msSince(lastBg.timestamp)); } scheduleWakeUp(); } finally { JoH.releaseWakeLock(wl); } return START_STICKY; }
Example 9
Source File: NightscoutFollowService.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
/** * Update observedDelay if new bg reading is available */ static void updateBgReceiveDelay() { lastBg = BgReading.lastNoSenssor(); if (lastBg != null && lastBgTime != lastBg.timestamp) { bgReceiveDelay = JoH.msSince(lastBg.timestamp); lastBgTime = lastBg.timestamp; } }
Example 10
Source File: NightscoutFollowService.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
static void scheduleWakeUp() { final BgReading lastBg = BgReading.lastNoSenssor(); final long last = lastBg != null ? lastBg.timestamp : 0; final long grace = Constants.SECOND_IN_MS * 10; final long next = Anticipate.next(JoH.tsl(), last, SAMPLE_PERIOD, grace) + grace; wakeup_time = next; UserError.Log.d(TAG, "Anticipate next: " + JoH.dateTimeText(next) + " last: " + JoH.dateTimeText(last)); JoH.wakeUpIntent(xdrip.getAppContext(), JoH.msTill(next), WakeLockTrampoline.getPendingIntent(NightscoutFollowService.class, Constants.NSFOLLOW_SERVICE_FAILOVER_ID)); }
Example 11
Source File: xDripWidget.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
private static void displayCurrentInfo(AppWidgetManager appWidgetManager, int appWidgetId, Context context, RemoteViews views) { BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(context); BgReading lastBgreading = BgReading.lastNoSenssor(); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); boolean showLines = settings.getBoolean("widget_range_lines", false); if (lastBgreading != null) { double estimate = 0; int height = appWidgetManager.getAppWidgetOptions(appWidgetId).getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT); int width = appWidgetManager.getAppWidgetOptions(appWidgetId).getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH); views.setImageViewBitmap(R.id.widgetGraph, new BgSparklineBuilder(context) .setBgGraphBuilder(bgGraphBuilder) .setHeight(height).setWidth(width).showHighLine(showLines).showLowLine(showLines).build()); if ((new Date().getTime()) - (60000 * 11) - lastBgreading.timestamp > 0) { estimate = lastBgreading.calculated_value; Log.d(TAG, "old value, estimate " + estimate); views.setTextViewText(R.id.widgetBg, bgGraphBuilder.unitized_string(estimate)); views.setTextViewText(R.id.widgetArrow, "--"); views.setInt(R.id.widgetBg, "setPaintFlags", Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); } else { estimate = lastBgreading.calculated_value; String stringEstimate = bgGraphBuilder.unitized_string(estimate); String slope_arrow = lastBgreading.slopeArrow(); if (lastBgreading.hide_slope) { slope_arrow = "--"; } Log.d(TAG, "newish value, estimate " + stringEstimate + slope_arrow); views.setTextViewText(R.id.widgetBg, stringEstimate); views.setTextViewText(R.id.widgetArrow, slope_arrow); views.setInt(R.id.widgetBg, "setPaintFlags", 0); } List<BgReading> bgReadingList = BgReading.latest(2); if(bgReadingList != null && bgReadingList.size() == 2) { views.setTextViewText(R.id.widgetDelta, bgGraphBuilder.unitizedDeltaString(true, true)); } else { views.setTextViewText(R.id.widgetDelta, "--"); } int timeAgo =(int) Math.floor((new Date().getTime() - lastBgreading.timestamp)/(1000*60)); if (timeAgo == 1) { views.setTextViewText(R.id.readingAge, timeAgo + " Minute ago"); } else { views.setTextViewText(R.id.readingAge, timeAgo + " Minutes ago"); } if (timeAgo > 15) { views.setTextColor(R.id.readingAge, Color.parseColor("#FFBB33")); } else { views.setTextColor(R.id.readingAge, Color.WHITE); } if(settings.getBoolean("extra_status_line", false) && settings.getBoolean("widget_status_line", false)) { views.setTextViewText(R.id.widgetStatusLine, Home.extraStatusLine(settings)); views.setViewVisibility(R.id.widgetStatusLine, View.VISIBLE); } else { views.setTextViewText(R.id.widgetStatusLine, ""); views.setViewVisibility(R.id.widgetStatusLine, View.GONE); } if (bgGraphBuilder.unitized(estimate) <= bgGraphBuilder.lowMark) { views.setTextColor(R.id.widgetBg, Color.parseColor("#C30909")); views.setTextColor(R.id.widgetDelta, Color.parseColor("#C30909")); views.setTextColor(R.id.widgetArrow, Color.parseColor("#C30909")); } else if (bgGraphBuilder.unitized(estimate) >= bgGraphBuilder.highMark) { views.setTextColor(R.id.widgetBg, Color.parseColor("#FFBB33")); views.setTextColor(R.id.widgetDelta, Color.parseColor("#FFBB33")); views.setTextColor(R.id.widgetArrow, Color.parseColor("#FFBB33")); } else { views.setTextColor(R.id.widgetBg, Color.WHITE); views.setTextColor(R.id.widgetDelta, Color.WHITE); views.setTextColor(R.id.widgetArrow, Color.WHITE); } } }
Example 12
Source File: Home.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
private void displayCurrentInfo() { DecimalFormat df = new DecimalFormat("#"); df.setMaximumFractionDigits(0); boolean isDexbridge = CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext()); boolean displayBattery = mPreferences.getBoolean("display_bridge_battery",false); int bridgeBattery = mPreferences.getInt("bridge_battery", 0); if (isDexbridge && displayBattery) { if(BgGraphBuilder.isXLargeTablet(getApplicationContext())) { this.dexbridgeBattery.setTextSize(25); } else if(BgGraphBuilder.isLargeTablet(getApplicationContext())) { this.dexbridgeBattery.setTextSize(18); } if (bridgeBattery == 0) { dexbridgeBattery.setText("xBridge Battery: Unknown, Waiting for packet"); dexbridgeBattery.setTextColor(Color.WHITE); } else { dexbridgeBattery.setText("xBridge Battery: " + bridgeBattery + "%"); } dexbridgeBattery.setTextColor(Color.parseColor("#00FF00")); if (bridgeBattery < 50 && bridgeBattery >30) dexbridgeBattery.setTextColor(Color.YELLOW); if (bridgeBattery <= 30) dexbridgeBattery.setTextColor(Color.RED); dexbridgeBattery.setVisibility(View.VISIBLE); } else { dexbridgeBattery.setText(""); dexbridgeBattery.setVisibility(View.INVISIBLE); } 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)); } BgReading lastBgReading = BgReading.lastNoSenssor(); boolean predictive = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("predictive_bg", false); if (isBTShare) { predictive = false; } if (lastBgReading != null) { displayCurrentInfoFromReading(lastBgReading, predictive); } }
Example 13
Source File: xDripWidget.java From xDrip with GNU General Public License v3.0 | 4 votes |
public static void displayCurrentInfo() { BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(mContext); BgReading lastBgreading = BgReading.lastNoSenssor(); if (lastBgreading != null) { double estimate = 0; if ((new Date().getTime()) - (60000 * 11) - lastBgreading.timestamp > 0) { estimate = lastBgreading.calculated_value; Log.d(TAG, "old value, estimate " + estimate); views.setTextViewText(R.id.widgetBg, bgGraphBuilder.unitized_string(estimate)); views.setTextViewText(R.id.widgetArrow, "--"); views.setInt(R.id.widgetBg, "setPaintFlags", Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); } else { estimate = lastBgreading.calculated_value; String stringEstimate = bgGraphBuilder.unitized_string(estimate); String slope_arrow = BgReading.slopeArrow((lastBgreading.calculated_value_slope * 60000)); if (lastBgreading.hide_slope) { slope_arrow = "--"; } Log.d(TAG, "newish value, estimate " + stringEstimate + slope_arrow); views.setTextViewText(R.id.widgetBg, stringEstimate); views.setTextViewText(R.id.widgetArrow, slope_arrow); views.setInt(R.id.widgetBg, "setPaintFlags", 0); } List<BgReading> bgReadingList = BgReading.latest(2); if(bgReadingList != null && bgReadingList.size() == 2) { views.setTextViewText(R.id.widgetDelta, bgGraphBuilder.unitizedDeltaString(lastBgreading.calculated_value - bgReadingList.get(1).calculated_value)); } else { views.setTextViewText(R.id.widgetDelta, "--"); } int timeAgo =(int) Math.floor((new Date().getTime() - lastBgreading.timestamp)/(1000*60)); if (timeAgo == 1) { views.setTextViewText(R.id.readingAge, timeAgo + " Minute ago"); } else { views.setTextViewText(R.id.readingAge, timeAgo + " Minutes ago"); } if (timeAgo > 15) { views.setTextColor(R.id.readingAge, Color.parseColor("#FFBB33")); } else { views.setTextColor(R.id.readingAge, Color.WHITE); } if (bgGraphBuilder.unitized(estimate) <= bgGraphBuilder.lowMark) { views.setTextColor(R.id.widgetBg, Color.parseColor("#C30909")); views.setTextColor(R.id.widgetDelta, Color.parseColor("#C30909")); views.setTextColor(R.id.widgetArrow, Color.parseColor("#C30909")); } else if (bgGraphBuilder.unitized(estimate) >= bgGraphBuilder.highMark) { views.setTextColor(R.id.widgetBg, Color.parseColor("#FFBB33")); views.setTextColor(R.id.widgetDelta, Color.parseColor("#FFBB33")); views.setTextColor(R.id.widgetArrow, Color.parseColor("#FFBB33")); } else { views.setTextColor(R.id.widgetBg, Color.WHITE); views.setTextColor(R.id.widgetDelta, Color.WHITE); views.setTextColor(R.id.widgetArrow, Color.WHITE); } } }