app/internal/window: [android] move switching to main thread to Go

There's runOnMain alread; use that for show|hideTextInput instead
of an ad-hoc switch.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-01-10 13:14:43 +01:00
parent f311a54ffb
commit acef4e6e2d
2 changed files with 7 additions and 15 deletions
-8
View File
@@ -174,21 +174,13 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal
} }
void showTextInput() { void showTextInput() {
post(new Runnable() {
@Override public void run() {
GioView.this.requestFocus(); GioView.this.requestFocus();
imm.showSoftInput(GioView.this, 0); imm.showSoftInput(GioView.this, 0);
} }
});
}
void hideTextInput() { void hideTextInput() {
post(new Runnable() {
@Override public void run() {
imm.hideSoftInputFromWindow(getWindowToken(), 0); imm.hideSoftInputFromWindow(getWindowToken(), 0);
} }
});
}
@Override protected boolean fitSystemWindows(Rect insets) { @Override protected boolean fitSystemWindows(Rect insets) {
onWindowInsets(nhandle, insets.top, insets.right, insets.bottom, insets.left); onWindowInsets(nhandle, insets.top, insets.right, insets.bottom, insets.left);
+1 -1
View File
@@ -537,10 +537,10 @@ func Java_org_gioui_GioView_onTouchEvent(env *C.JNIEnv, class C.jclass, handle C
} }
func (w *window) ShowTextInput(show bool) { func (w *window) ShowTextInput(show bool) {
runOnMain(func(env *C.JNIEnv) {
if w.view == 0 { if w.view == 0 {
return return
} }
runInJVM(javaVM(), func(env *C.JNIEnv) {
if show { if show {
callVoidMethod(env, w.view, gioView.showTextInput) callVoidMethod(env, w.view, gioView.showTextInput)
} else { } else {