From 4c2527296983ae4a8958dd331a794762ad4893c1 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 10 Jan 2021 03:41:54 +0100 Subject: [PATCH 1/2] avoid concurrent button press crash in TimeListEdit --- .../androidaps/utils/TimeListEdit.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java b/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java index fb1dfa990c..e22e8c6638 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java @@ -192,7 +192,7 @@ public class TimeListEdit { int before, int count) { } }); - numberPickers1[position].setTag(tagPrefix +"-1-" + position); + numberPickers1[position].setTag(tagPrefix + "-1-" + position); numberPickers2[position].setTextWatcher(new TextWatcher() { @Override @@ -212,7 +212,7 @@ public class TimeListEdit { int before, int count) { } }); - numberPickers2[position].setTag(tagPrefix +"-2-" + position); + numberPickers2[position].setTag(tagPrefix + "-2-" + position); layout.addView(childView); } @@ -245,7 +245,7 @@ public class TimeListEdit { if (i == 0) next = ONEHOURINSECONDS; fillSpinner(timeSpinner, secondFromMidnight(i), previous, next); - editText1.setParams(value1(i), min, max, step, formatter, false,null); + editText1.setParams(value1(i), min, max, step, formatter, false, null); editText2.setParams(value2(i), min, max, step, formatter, false, null); if (data2 == null) { @@ -372,10 +372,12 @@ public class TimeListEdit { } private void addItem(int index, int timeAsSeconds, double value1, double value2) { - if (itemsCount() > inflatedUntil) { - layout.removeView(finalAdd); - inflateRow(++inflatedUntil); - layout.addView(finalAdd); + synchronized (this) { + if (itemsCount() > inflatedUntil) { + layout.removeView(finalAdd); + inflateRow(++inflatedUntil); + layout.addView(finalAdd); + } } try { // shift data From b509d13073edf58fcbc9285406479305a6e8a5d3 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 10 Jan 2021 03:54:51 +0100 Subject: [PATCH 2/2] avoid concurrent button press crash in TimeListEdit - now for real --- .../nightscout/androidaps/utils/TimeListEdit.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java b/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java index e22e8c6638..fd72be7b93 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java @@ -372,12 +372,11 @@ public class TimeListEdit { } private void addItem(int index, int timeAsSeconds, double value1, double value2) { - synchronized (this) { - if (itemsCount() > inflatedUntil) { - layout.removeView(finalAdd); - inflateRow(++inflatedUntil); - layout.addView(finalAdd); - } + if (itemsCount() >= 24) return; + if (itemsCount() > inflatedUntil) { + layout.removeView(finalAdd); + inflateRow(++inflatedUntil); + layout.addView(finalAdd); } try { // shift data