Java Code Examples for com.eveningoutpost.dexdrip.Models.BgReading#slopeArrow()
The following examples show how to use
com.eveningoutpost.dexdrip.Models.BgReading#slopeArrow() .
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: 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 2
Source File: Notifications.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public Notification createOngoingNotification(Context context) { mContext = context; long end = System.currentTimeMillis() + (60000 * 5); long start = end - (60000 * 60*3) - (60000 * 10); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(mContext, start, end); ReadPerfs(mContext); Intent intent = new Intent(mContext, Home.class); List<BgReading> lastReadings = BgReading.latest(2); BgReading lastReading = null; if (lastReadings != null && lastReadings.size() >= 2) { lastReading = lastReadings.get(0); } TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext); stackBuilder.addParentStack(Home.class); stackBuilder.addNextIntent(intent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent( 0, PendingIntent.FLAG_UPDATE_CURRENT ); NotificationCompat.Builder b = new NotificationCompat.Builder(mContext); //b.setOngoing(true); b.setCategory(NotificationCompat.CATEGORY_STATUS); String titleString = lastReading == null ? "BG Reading Unavailable" : (lastReading.displayValue(mContext) + " " + lastReading.slopeArrow()); b.setContentTitle(titleString) .setContentText("xDrip Data collection service is running.") .setSmallIcon(R.drawable.ic_action_communication_invert_colors_on) .setUsesChronometer(false); if (lastReading != null) { b.setWhen(lastReading.timestamp); String deltaString = "Delta: " + bgGraphBuilder.unitizedDeltaString(true, true); b.setContentText(deltaString); iconBitmap = new BgSparklineBuilder(mContext) .setHeight(64) .setWidth(64) .setStart(System.currentTimeMillis() - 60000 * 60 * 3) .setBgGraphBuilder(bgGraphBuilder) .build(); b.setLargeIcon(iconBitmap); NotificationCompat.BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle(); notifiationBitmap = new BgSparklineBuilder(mContext) .setBgGraphBuilder(bgGraphBuilder) .showHighLine() .showLowLine() .build(); bigPictureStyle.bigPicture(notifiationBitmap) .setSummaryText(deltaString) .setBigContentTitle(titleString); b.setStyle(bigPictureStyle); } b.setContentIntent(resultPendingIntent); return b.build(); }
Example 3
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); } } }