android-calculatorpp-69 No operation for *E (E, 1E etc) in hex mode
This commit is contained in:
parent
3f2cf60d6f
commit
9c7e47cfef
@ -199,6 +199,7 @@ public enum CalculatorModel implements CursorControl, HistoryControl<CalculatorH
|
|||||||
if (historyState == null) {
|
if (historyState == null) {
|
||||||
CalculatorHistory.instance.addState(localHistoryState);
|
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);
|
new Handler().postDelayed(pendingOperation.getObject(), EVAL_DELAY_MILLIS);
|
||||||
} else {
|
} else {
|
||||||
pendingOperation.getObject().run();
|
pendingOperation.getObject().run();
|
||||||
|
@ -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
|
* @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) {
|
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) {
|
private boolean spaceBefore(@NotNull MathType.Result mathTypeResult) {
|
||||||
@ -57,15 +61,17 @@ public abstract class AbstractNumberBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSignAfterE(@NotNull MathType.Result mathTypeResult) {
|
private boolean isSignAfterE(@NotNull MathType.Result mathTypeResult) {
|
||||||
if ("-".equals(mathTypeResult.getMatch()) || "+".equals(mathTypeResult.getMatch())) {
|
if (!isHexMode()) {
|
||||||
final StringBuilder localNb = numberBuilder;
|
if ("-".equals(mathTypeResult.getMatch()) || "+".equals(mathTypeResult.getMatch())) {
|
||||||
if (localNb != null && localNb.length() > 0) {
|
final StringBuilder localNb = numberBuilder;
|
||||||
if (localNb.charAt(localNb.length() - 1) == MathType.POWER_10) {
|
if (localNb != null && localNb.length() > 0) {
|
||||||
return true;
|
if (localNb.charAt(localNb.length() - 1) == MathType.POWER_10) {
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHexMode() {
|
public boolean isHexMode() {
|
||||||
|
@ -9,14 +9,11 @@ package org.solovyev.android.calculator.model;
|
|||||||
import jscl.MathContext;
|
import jscl.MathContext;
|
||||||
import jscl.MathEngine;
|
import jscl.MathEngine;
|
||||||
import jscl.NumeralBase;
|
import jscl.NumeralBase;
|
||||||
import jscl.math.function.IConstant;
|
|
||||||
import jscl.math.numeric.Real;
|
import jscl.math.numeric.Real;
|
||||||
import jscl.text.*;
|
import jscl.text.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.solovyev.android.calculator.math.MathType;
|
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 org.solovyev.common.utils.MutableObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -98,6 +98,7 @@ public class TextHighlighterTest {
|
|||||||
me.setNumeralBase(NumeralBase.hex);
|
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("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());
|
Assert.assertEquals("6F", textHighlighter.process("6F").toString());
|
||||||
|
Loading…
Reference in New Issue
Block a user