optimize nsclient logging

This commit is contained in:
Milos Kozak 2017-06-13 12:17:54 +02:00
parent afca896f23
commit 2a1fe205ee
3 changed files with 12 additions and 7 deletions

View file

@ -189,11 +189,11 @@ public class NSClientInternalPlugin implements PluginBase {
private void updateLog() { private void updateLog() {
try { try {
Spanned newTextLog = Html.fromHtml(""); String newTextLog = "";
for (EventNSClientNewLog log : listLog) { 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()); MainApp.bus().post(new EventNSClientUpdateGUI());
} catch (OutOfMemoryError e) { } catch (OutOfMemoryError e) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), "Out of memory!\nStop using this phone !!!", R.raw.error); ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), "Out of memory!\nStop using this phone !!!", R.raw.error);

View file

@ -27,4 +27,9 @@ public class EventNSClientNewLog {
Spanned line = Html.fromHtml(timeFormat.format(date) + " <b>" + action + "</b> " + logText + "<br>"); Spanned line = Html.fromHtml(timeFormat.format(date) + " <b>" + action + "</b> " + logText + "<br>");
return line; return line;
} }
public String toPreparedHtml() {
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
return timeFormat.format(date) + " <b>" + action + "</b> " + logText + "<br>";
}
} }

View file

@ -1155,7 +1155,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} }
// ****** GRAPH ******* // ****** GRAPH *******
log.debug("updateGUI checkpoint 1"); //log.debug("updateGUI checkpoint 1");
// allign to hours // allign to hours
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
@ -1286,7 +1286,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
absoluteBasalsLineSeries.setCustomPaint(absolutePaint); absoluteBasalsLineSeries.setCustomPaint(absolutePaint);
} }
log.debug("updateGUI checkpoint 2"); //log.debug("updateGUI checkpoint 2");
// **** IOB COB DEV graph **** // **** IOB COB DEV graph ****
class DeviationDataPoint extends DataPoint { class DeviationDataPoint extends DataPoint {
@ -1404,12 +1404,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else { } else {
iobGraph.setVisibility(View.GONE); iobGraph.setVisibility(View.GONE);
} }
log.debug("updateGUI checkpoint 3"); //log.debug("updateGUI checkpoint 3");
// remove old data from graph // remove old data from graph
bgGraph.getSecondScale().getSeries().clear(); bgGraph.getSecondScale().getSeries().clear();
bgGraph.getSeries().clear(); bgGraph.getSeries().clear();
log.debug("updateGUI checkpoint 4"); //log.debug("updateGUI checkpoint 4");
// **** Area **** // **** Area ****
DoubleDataPoint[] areaDataPoints = new DoubleDataPoint[]{ DoubleDataPoint[] areaDataPoints = new DoubleDataPoint[]{