當前位置: 首頁>>代碼示例>>Java>>正文


Java BgSparklineBuilder類代碼示例

本文整理匯總了Java中com.eveningoutpost.dexdrip.UtilityModels.BgSparklineBuilder的典型用法代碼示例。如果您正苦於以下問題:Java BgSparklineBuilder類的具體用法?Java BgSparklineBuilder怎麽用?Java BgSparklineBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BgSparklineBuilder類屬於com.eveningoutpost.dexdrip.UtilityModels包,在下文中一共展示了BgSparklineBuilder類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: displayCurrentInfo

import com.eveningoutpost.dexdrip.UtilityModels.BgSparklineBuilder; //導入依賴的package包/類
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);
        }
    }
}
 
開發者ID:StephenBlackWasAlreadyTaken,項目名稱:xDrip-Experimental,代碼行數:76,代碼來源:xDripWidget.java


注:本文中的com.eveningoutpost.dexdrip.UtilityModels.BgSparklineBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。