From acef4e6e2dc7b4065393d09c418e5191ecf2dea5 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 10 Jan 2021 13:14:43 +0100 Subject: [PATCH] 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 --- app/internal/window/GioView.java | 14 +++----------- app/internal/window/os_android.go | 8 ++++---- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/app/internal/window/GioView.java b/app/internal/window/GioView.java index 46153226..7ed9f052 100644 --- a/app/internal/window/GioView.java +++ b/app/internal/window/GioView.java @@ -174,20 +174,12 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal } void showTextInput() { - post(new Runnable() { - @Override public void run() { - GioView.this.requestFocus(); - imm.showSoftInput(GioView.this, 0); - } - }); + GioView.this.requestFocus(); + imm.showSoftInput(GioView.this, 0); } void hideTextInput() { - post(new Runnable() { - @Override public void run() { - imm.hideSoftInputFromWindow(getWindowToken(), 0); - } - }); + imm.hideSoftInputFromWindow(getWindowToken(), 0); } @Override protected boolean fitSystemWindows(Rect insets) { diff --git a/app/internal/window/os_android.go b/app/internal/window/os_android.go index a81f9fb4..67f168f9 100644 --- a/app/internal/window/os_android.go +++ b/app/internal/window/os_android.go @@ -537,10 +537,10 @@ func Java_org_gioui_GioView_onTouchEvent(env *C.JNIEnv, class C.jclass, handle C } func (w *window) ShowTextInput(show bool) { - if w.view == 0 { - return - } - runInJVM(javaVM(), func(env *C.JNIEnv) { + runOnMain(func(env *C.JNIEnv) { + if w.view == 0 { + return + } if show { callVoidMethod(env, w.view, gioView.showTextInput) } else {