android-calculatorpp-69 No operation for *E (E, 1E etc) in hex mode

This commit is contained in:
Sergey Solovyev 2012-04-21 16:05:00 +04:00
parent 3f2cf60d6f
commit 9c7e47cfef
4 changed files with 18 additions and 13 deletions

View File

@ -199,6 +199,7 @@ public enum CalculatorModel implements CursorControl, HistoryControl<CalculatorH
if (historyState == null) {
CalculatorHistory.instance.addState(localHistoryState);
}
// todo serso: this is not correct - operation is processing still in the same thread
new Handler().postDelayed(pendingOperation.getObject(), EVAL_DELAY_MILLIS);
} else {
pendingOperation.getObject().run();

View File

@ -41,7 +41,11 @@ public abstract class AbstractNumberBuilder {
* @return true if we can continue of processing of current number, if false - new number should be constructed
*/
protected boolean canContinue(@NotNull MathType.Result mathTypeResult) {
return ((mathTypeResult.getMathType().getGroupType() == MathType.MathGroupType.number && !spaceBefore(mathTypeResult) && numeralBaseCheck(mathTypeResult) && numeralBaseInTheStart(mathTypeResult.getMathType()) || isSignAfterE(mathTypeResult)));
boolean result = mathTypeResult.getMathType().getGroupType() == MathType.MathGroupType.number &&
!spaceBefore(mathTypeResult) &&
numeralBaseCheck(mathTypeResult) &&
numeralBaseInTheStart(mathTypeResult.getMathType()) || isSignAfterE(mathTypeResult);
return result;
}
private boolean spaceBefore(@NotNull MathType.Result mathTypeResult) {
@ -57,6 +61,7 @@ public abstract class AbstractNumberBuilder {
}
private boolean isSignAfterE(@NotNull MathType.Result mathTypeResult) {
if (!isHexMode()) {
if ("-".equals(mathTypeResult.getMatch()) || "+".equals(mathTypeResult.getMatch())) {
final StringBuilder localNb = numberBuilder;
if (localNb != null && localNb.length() > 0) {
@ -65,6 +70,7 @@ public abstract class AbstractNumberBuilder {
}
}
}
}
return false;
}

View File

@ -9,14 +9,11 @@ package org.solovyev.android.calculator.model;
import jscl.MathContext;
import jscl.MathEngine;
import jscl.NumeralBase;
import jscl.math.function.IConstant;
import jscl.math.numeric.Real;
import jscl.text.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.math.MathType;
import org.solovyev.common.utils.CollectionsUtils;
import org.solovyev.common.utils.Finder;
import org.solovyev.common.utils.MutableObject;
import java.util.ArrayList;

View File

@ -98,6 +98,7 @@ public class TextHighlighterTest {
me.setNumeralBase(NumeralBase.hex);
Assert.assertEquals("E", textHighlighter.process("E").toString());
Assert.assertEquals(".E", textHighlighter.process(".E").toString());
Assert.assertEquals("E+", textHighlighter.process("E+").toString());
Assert.assertEquals("E.", textHighlighter.process("E.").toString());
Assert.assertEquals(".E.", textHighlighter.process(".E.").toString());
Assert.assertEquals("6F", textHighlighter.process("6F").toString());