android-calculatorpp-114: "Calculator while typing" option is ignored
Fixes#114
This commit is contained in:
parent
f1d944a297
commit
9d99863752
@ -104,6 +104,11 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
|
||||
return calculator.evaluate(operation, expression, sequenceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCalculateOnFly() {
|
||||
return calculator.isCalculateOnFly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConversionPossible(@Nonnull Generic generic, @Nonnull NumeralBase from, @Nonnull NumeralBase to) {
|
||||
return calculator.isConversionPossible(generic, from, to);
|
||||
|
@ -64,6 +64,8 @@ public interface Calculator extends CalculatorEventContainer, HistoryControl<Cal
|
||||
@Nonnull String expression,
|
||||
@Nonnull Long sequenceId);
|
||||
|
||||
boolean isCalculateOnFly();
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
|
@ -211,6 +211,11 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener {
|
||||
this.calculateOnFly = calculateOnFly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCalculateOnFly() {
|
||||
return calculateOnFly;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private CalculatorConversionEventData newConversionEventData(@Nonnull Long sequenceId,
|
||||
@Nonnull Generic value,
|
||||
|
@ -102,6 +102,13 @@ public enum CalculatorSpecialButton {
|
||||
equals("=") {
|
||||
@Override
|
||||
public void onClick(@Nonnull CalculatorKeyboard keyboard) {
|
||||
final Calculator calculator = Locator.getInstance().getCalculator();
|
||||
if (!calculator.isCalculateOnFly()) {
|
||||
// no automatic calculations are => equals button must be used to calculate
|
||||
calculator.evaluate();
|
||||
return;
|
||||
}
|
||||
|
||||
final CalculatorDisplayViewState displayViewState = Locator.getInstance().getDisplay().getViewState();
|
||||
if (displayViewState.isValid()) {
|
||||
final CharSequence text = displayViewState.getText();
|
||||
|
Loading…
Reference in New Issue
Block a user