Don't lose cursor position on device rotation
This commit is contained in:
parent
cc1a7817eb
commit
5b7205b299
@ -79,10 +79,14 @@ public class EditorView extends EditTextCompat {
|
|||||||
if (this.editor == editor) {
|
if (this.editor == editor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.editor = editor;
|
|
||||||
if (editor != null) {
|
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());
|
setState(editor.getState());
|
||||||
}
|
}
|
||||||
|
// update editor at the end to avoid side-effects of #requestFocus() and #setState()
|
||||||
|
this.editor = editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user