diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/AndroidCalculatorEditorView.java b/android-app-core/src/main/java/org/solovyev/android/calculator/AndroidCalculatorEditorView.java index 9ddec3e8..f7811707 100644 --- a/android-app-core/src/main/java/org/solovyev/android/calculator/AndroidCalculatorEditorView.java +++ b/android-app-core/src/main/java/org/solovyev/android/calculator/AndroidCalculatorEditorView.java @@ -49,9 +49,6 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe private volatile boolean viewStateChange = false; - @Nonnull - private final Object viewLock = new Object(); - @Nonnull private final Handler uiHandler = new Handler(); @@ -155,7 +152,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe @Override public void setState(@Nonnull final CalculatorEditorViewState viewState) { - synchronized (viewLock) { + synchronized (this) { final CharSequence text = prepareText(viewState.getText(), highlightText); @@ -163,7 +160,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe @Override public void run() { final AndroidCalculatorEditorView editorView = AndroidCalculatorEditorView.this; - synchronized (viewLock) { + synchronized (AndroidCalculatorEditorView.this) { try { editorView.viewStateChange = true; editorView.viewState = viewState; @@ -181,7 +178,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe @Override protected void onSelectionChanged(int selStart, int selEnd) { - synchronized (viewLock) { + synchronized (this) { if (!viewStateChange) { // external text change => need to notify editor super.onSelectionChanged(selStart, selEnd); @@ -195,7 +192,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe } public void handleTextChange(Editable s) { - synchronized (viewLock) { + synchronized (this) { if (!viewStateChange) { // external text change => need to notify editor Locator.getInstance().getEditor().setText(String.valueOf(s)); diff --git a/android-app/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java b/android-app/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java index b74cfa84..7be4a8ed 100644 --- a/android-app/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java +++ b/android-app/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java @@ -24,6 +24,11 @@ public class AndroidCalculatorEditorViewTest { CalculatorTestUtils.initViews(context);*/ } + @Test + public void testCreation() throws Exception { + new AndroidCalculatorEditorView(CalculatorApplication.getInstance()); + } + @Test public void testAsyncWork() throws Exception { /* final int threadNum = 10;