From 08add4f17e27a2130ae09bbb219e479987e18278 Mon Sep 17 00:00:00 2001 From: serso Date: Mon, 16 Feb 2015 20:51:56 +0100 Subject: [PATCH] Fix for LongClickEraser --- .../android/calculator/view/LongClickEraser.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/android-app/src/main/java/org/solovyev/android/calculator/view/LongClickEraser.java b/android-app/src/main/java/org/solovyev/android/calculator/view/LongClickEraser.java index 3fa74acd..369fc25a 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/view/LongClickEraser.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/view/LongClickEraser.java @@ -1,15 +1,19 @@ package org.solovyev.android.calculator.view; +import android.text.TextUtils; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import org.solovyev.android.calculator.Calculator; import org.solovyev.android.calculator.CalculatorEditor; +import org.solovyev.android.calculator.CalculatorEditorViewState; import org.solovyev.android.calculator.Locator; import javax.annotation.Nonnull; +import static android.text.TextUtils.isEmpty; + public final class LongClickEraser implements View.OnTouchListener { @Nonnull @@ -51,7 +55,7 @@ public final class LongClickEraser implements View.OnTouchListener { gestureDetector.onTouchEvent(event); break; } - return true; + return false; } private class Eraser implements Runnable { @@ -62,7 +66,11 @@ public final class LongClickEraser implements View.OnTouchListener { @Override public void run() { - editor.erase(); + final CalculatorEditorViewState state = editor.erase(); + if (isEmpty(state.getText())) { + stop(); + return; + } delay = Math.max(50, 2 * delay / 3); view.postDelayed(this, delay); }