From 2a1fe205eef55c6e4730d05e598294387fff22b1 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 13 Jun 2017 12:17:54 +0200 Subject: [PATCH] optimize nsclient logging --- .../plugins/NSClientInternal/NSClientInternalPlugin.java | 6 +++--- .../NSClientInternal/events/EventNSClientNewLog.java | 5 +++++ .../androidaps/plugins/Overview/OverviewFragment.java | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java index a37d5442ca..4b3e059b6e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java @@ -189,11 +189,11 @@ public class NSClientInternalPlugin implements PluginBase { private void updateLog() { try { - Spanned newTextLog = Html.fromHtml(""); + String newTextLog = ""; for (EventNSClientNewLog log : listLog) { - newTextLog = (Spanned) TextUtils.concat(newTextLog, log.toHtml()); + newTextLog = newTextLog + log.toPreparedHtml(); } - textLog = newTextLog; + textLog = Html.fromHtml(newTextLog); MainApp.bus().post(new EventNSClientUpdateGUI()); } catch (OutOfMemoryError e) { ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), "Out of memory!\nStop using this phone !!!", R.raw.error); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java index 7f576fde7e..3af3333d65 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java @@ -27,4 +27,9 @@ public class EventNSClientNewLog { Spanned line = Html.fromHtml(timeFormat.format(date) + " " + action + " " + logText + "
"); return line; } + + public String toPreparedHtml() { + SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); + return timeFormat.format(date) + " " + action + " " + logText + "
"; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 48550727c3..cea7d639b6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -1155,7 +1155,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } // ****** GRAPH ******* - log.debug("updateGUI checkpoint 1"); + //log.debug("updateGUI checkpoint 1"); // allign to hours Calendar calendar = Calendar.getInstance(); @@ -1286,7 +1286,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, absoluteBasalsLineSeries.setCustomPaint(absolutePaint); } - log.debug("updateGUI checkpoint 2"); + //log.debug("updateGUI checkpoint 2"); // **** IOB COB DEV graph **** class DeviationDataPoint extends DataPoint { @@ -1404,12 +1404,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } else { iobGraph.setVisibility(View.GONE); } - log.debug("updateGUI checkpoint 3"); + //log.debug("updateGUI checkpoint 3"); // remove old data from graph bgGraph.getSecondScale().getSeries().clear(); bgGraph.getSeries().clear(); - log.debug("updateGUI checkpoint 4"); + //log.debug("updateGUI checkpoint 4"); // **** Area **** DoubleDataPoint[] areaDataPoints = new DoubleDataPoint[]{