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.viewState = viewState;
|
||||
editorView.setText(text, BufferType.EDITABLE);
|
||||
editorView.setSelection(viewState.getSelection());
|
||||
final int selection = CalculatorEditorImpl.correctSelection(viewState.getSelection(), editorView.getText());
|
||||
editorView.setSelection(selection);
|
||||
} finally {
|
||||
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());
|
||||
}
|
||||
|
||||
private int correctSelection(int selection, int textLength) {
|
||||
public static int correctSelection(int selection, int textLength) {
|
||||
int result = Math.max(selection, 0);
|
||||
result = Math.min(result, textLength);
|
||||
return result;
|
||||
|
@ -114,6 +114,7 @@ public class CalculatorHistoryImpl implements CalculatorHistory {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<CalculatorHistoryState> getStates(boolean includeIntermediateStates) {
|
||||
synchronized (history) {
|
||||
if (includeIntermediateStates) {
|
||||
return getStates();
|
||||
} else {
|
||||
@ -141,6 +142,7 @@ public class CalculatorHistoryImpl implements CalculatorHistory {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isIntermediate(@NotNull String laterEditorText,
|
||||
@NotNull String editorText) {
|
||||
|
Loading…
Reference in New Issue
Block a user