Don't lose cursor position on device rotation

This commit is contained in:
serso 2016-03-10 14:20:43 +01:00
parent cc1a7817eb
commit 5b7205b299

View File

@ -79,10 +79,14 @@ public class EditorView extends EditTextCompat {
if (this.editor == editor) {
return;
}
this.editor = editor;
if (editor != null) {
// avoid losing cursor position on focus restore. First request focus, then set cursor
// position. Consequent requestFocus() should be no-op
requestFocus();
setState(editor.getState());
}
// update editor at the end to avoid side-effects of #requestFocus() and #setState()
this.editor = editor;
}
@Override