user exceptions fixed
This commit is contained in:
parent
061a559778
commit
6e09225366
@ -144,7 +144,8 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe
|
|||||||
editorView.viewStateChange = true;
|
editorView.viewStateChange = true;
|
||||||
editorView.viewState = viewState;
|
editorView.viewState = viewState;
|
||||||
editorView.setText(text, BufferType.EDITABLE);
|
editorView.setText(text, BufferType.EDITABLE);
|
||||||
editorView.setSelection(viewState.getSelection());
|
final int selection = CalculatorEditorImpl.correctSelection(viewState.getSelection(), editorView.getText());
|
||||||
|
editorView.setSelection(selection);
|
||||||
} finally {
|
} finally {
|
||||||
editorView.viewStateChange = false;
|
editorView.viewStateChange = false;
|
||||||
}
|
}
|
||||||
|
@ -269,11 +269,11 @@ public class CalculatorEditorImpl implements CalculatorEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int correctSelection(int selection, @NotNull String text) {
|
public static int correctSelection(int selection, @NotNull CharSequence text) {
|
||||||
return correctSelection(selection, text.length());
|
return correctSelection(selection, text.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
private int correctSelection(int selection, int textLength) {
|
public static int correctSelection(int selection, int textLength) {
|
||||||
int result = Math.max(selection, 0);
|
int result = Math.max(selection, 0);
|
||||||
result = Math.min(result, textLength);
|
result = Math.min(result, textLength);
|
||||||
return result;
|
return result;
|
||||||
|
@ -114,6 +114,7 @@ public class CalculatorHistoryImpl implements CalculatorHistory {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<CalculatorHistoryState> getStates(boolean includeIntermediateStates) {
|
public List<CalculatorHistoryState> getStates(boolean includeIntermediateStates) {
|
||||||
|
synchronized (history) {
|
||||||
if (includeIntermediateStates) {
|
if (includeIntermediateStates) {
|
||||||
return getStates();
|
return getStates();
|
||||||
} else {
|
} else {
|
||||||
@ -141,6 +142,7 @@ public class CalculatorHistoryImpl implements CalculatorHistory {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isIntermediate(@NotNull String laterEditorText,
|
private boolean isIntermediate(@NotNull String laterEditorText,
|
||||||
@NotNull String editorText) {
|
@NotNull String editorText) {
|
||||||
|
Loading…
Reference in New Issue
Block a user