fix for display clearing
This commit is contained in:
parent
47aa4b55c3
commit
e1d356de8a
@ -11,4 +11,4 @@
|
|||||||
a:id="@+id/calculatorDisplay"
|
a:id="@+id/calculatorDisplay"
|
||||||
style="@style/display_style"
|
style="@style/display_style"
|
||||||
a:scrollHorizontally="true"
|
a:scrollHorizontally="true"
|
||||||
a:scrollbars="horizontal"/>
|
a:scrollbars="none"/>
|
@ -141,7 +141,11 @@ public enum CalculatorModel implements CursorControl, HistoryControl<CalculatorH
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final static MutableObject<Runnable> pendingOperation = new MutableObject<Runnable>();
|
private final static MutableObject<Runnable> pendingOperation = new MutableObject<Runnable>();
|
||||||
|
|
||||||
private void evaluate(boolean delayEvaluate, @NotNull final String expression, @NotNull final JsclOperation operation, @Nullable CalculatorHistoryState historyState) {
|
private void evaluate(boolean delayEvaluate,
|
||||||
|
@NotNull final String expression,
|
||||||
|
@NotNull final JsclOperation operation,
|
||||||
|
@Nullable CalculatorHistoryState historyState) {
|
||||||
|
|
||||||
final CalculatorHistoryState localHistoryState;
|
final CalculatorHistoryState localHistoryState;
|
||||||
if (historyState == null) {
|
if (historyState == null) {
|
||||||
this.display.setText("");
|
this.display.setText("");
|
||||||
@ -201,7 +205,9 @@ public enum CalculatorModel implements CursorControl, HistoryControl<CalculatorH
|
|||||||
try {
|
try {
|
||||||
Log.d(CalculatorModel.class.getName(), "Trying to evaluate '" + operation + "': " + expression /*+ StringUtils.fromStackTrace(Thread.currentThread().getStackTrace())*/);
|
Log.d(CalculatorModel.class.getName(), "Trying to evaluate '" + operation + "': " + expression /*+ StringUtils.fromStackTrace(Thread.currentThread().getStackTrace())*/);
|
||||||
final CalculatorEngine.Result result = calculatorEngine.evaluate(operation, expression);
|
final CalculatorEngine.Result result = calculatorEngine.evaluate(operation, expression);
|
||||||
if (currentRunner == pendingOperation.getObject()) {
|
|
||||||
|
// todo serso: second condition might replaced with expression.equals(this.editor.getText().toString()) ONLY if expression will be formatted with text highlighter
|
||||||
|
if (currentRunner == pendingOperation.getObject() && this.editor.getText().length() > 0) {
|
||||||
display.setText(result.getResult());
|
display.setText(result.getResult());
|
||||||
} else {
|
} else {
|
||||||
display.setText("");
|
display.setText("");
|
||||||
@ -231,7 +237,7 @@ public enum CalculatorModel implements CursorControl, HistoryControl<CalculatorH
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if (!StringUtils.isEmpty(editor.getText()) || !StringUtils.isEmpty(editor.getText())) {
|
if (!StringUtils.isEmpty(editor.getText()) || !StringUtils.isEmpty(display.getText())) {
|
||||||
editor.getText().clear();
|
editor.getText().clear();
|
||||||
display.setText("");
|
display.setText("");
|
||||||
saveHistoryState();
|
saveHistoryState();
|
||||||
|
Loading…
Reference in New Issue
Block a user