avoid concurrent button press crash in TimeListEdit

This commit is contained in:
AdrianLxM 2021-01-10 03:41:54 +01:00
parent ddb6e1c007
commit 4c25272969

View file

@ -192,7 +192,7 @@ public class TimeListEdit {
int before, int count) { int before, int count) {
} }
}); });
numberPickers1[position].setTag(tagPrefix +"-1-" + position); numberPickers1[position].setTag(tagPrefix + "-1-" + position);
numberPickers2[position].setTextWatcher(new TextWatcher() { numberPickers2[position].setTextWatcher(new TextWatcher() {
@Override @Override
@ -212,7 +212,7 @@ public class TimeListEdit {
int before, int count) { int before, int count) {
} }
}); });
numberPickers2[position].setTag(tagPrefix +"-2-" + position); numberPickers2[position].setTag(tagPrefix + "-2-" + position);
layout.addView(childView); layout.addView(childView);
} }
@ -245,7 +245,7 @@ public class TimeListEdit {
if (i == 0) next = ONEHOURINSECONDS; if (i == 0) next = ONEHOURINSECONDS;
fillSpinner(timeSpinner, secondFromMidnight(i), previous, next); 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); editText2.setParams(value2(i), min, max, step, formatter, false, null);
if (data2 == null) { if (data2 == null) {
@ -372,10 +372,12 @@ public class TimeListEdit {
} }
private void addItem(int index, int timeAsSeconds, double value1, double value2) { private void addItem(int index, int timeAsSeconds, double value1, double value2) {
if (itemsCount() > inflatedUntil) { synchronized (this) {
layout.removeView(finalAdd); if (itemsCount() > inflatedUntil) {
inflateRow(++inflatedUntil); layout.removeView(finalAdd);
layout.addView(finalAdd); inflateRow(++inflatedUntil);
layout.addView(finalAdd);
}
} }
try { try {
// shift data // shift data