From 2eca7f0a026b35d2c8685291a6eefb2eaf190da4 Mon Sep 17 00:00:00 2001 From: Roumen Georgiev Date: Wed, 4 Apr 2018 12:13:07 +0300 Subject: [PATCH] int to double in the isOlderThan() --- .../androidaps/db/CareportalEvent.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java b/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java index b80f4f932e..643b5d066c 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java +++ b/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java @@ -5,6 +5,7 @@ import android.graphics.Color; import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; +import org.apache.commons.lang3.StringUtils; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; @@ -97,6 +98,14 @@ public class CareportalEvent implements DataPointWithLabelInterface { return diff.get(TimeUnit.DAYS) + " " + MainApp.sResources.getString(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.sResources.getString(R.string.hours); } + public boolean isOlderThan(double threshold) { + Map diff = computeDiff(date, System.currentTimeMillis()); + if(diff.get(TimeUnit.DAYS) > threshold) + return true; + else + return false; + } + public String log() { return "CareportalEvent{" + "date= " + date + @@ -184,13 +193,24 @@ public class CareportalEvent implements DataPointWithLabelInterface { try { JSONObject object = new JSONObject(json); if (object.has("notes")) - return object.getString("notes"); + return StringUtils.abbreviate(object.getString("notes"), 40); } catch (JSONException e) { log.error("Unhandled exception", e); } return Translator.translate(eventType); } + public String getNotes() { + try { + JSONObject object = new JSONObject(json); + if (object.has("notes")) + return object.getString("notes"); + } catch (JSONException e) { + log.error("Unhandled exception", e); + } + return ""; + } + @Override public long getDuration() { try { @@ -242,4 +262,10 @@ public class CareportalEvent implements DataPointWithLabelInterface { return Color.GRAY; return Color.GRAY; } + + @Override + public int getSecondColor() { + return 0; + } + }