diff options
Diffstat (limited to 'hello_world/src')
-rw-r--r-- | hello_world/src/main/java/fhuyakou/godot/plugin/android/helloworld/HelloWorldPlugin.java | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/hello_world/src/main/java/fhuyakou/godot/plugin/android/helloworld/HelloWorldPlugin.java b/hello_world/src/main/java/fhuyakou/godot/plugin/android/helloworld/HelloWorldPlugin.java index fe0a319..1dfa1b2 100644 --- a/hello_world/src/main/java/fhuyakou/godot/plugin/android/helloworld/HelloWorldPlugin.java +++ b/hello_world/src/main/java/fhuyakou/godot/plugin/android/helloworld/HelloWorldPlugin.java @@ -2,10 +2,9 @@ package fhuyakou.godot.plugin.android.helloworld; import android.app.Activity; import android.view.View; -import java.util.Collections; -import java.util.List; import org.godotengine.godot.Godot; import org.godotengine.godot.plugin.GodotPlugin; +import org.godotengine.godot.plugin.UsedByGodot; public class HelloWorldPlugin extends GodotPlugin { @@ -23,12 +22,7 @@ public class HelloWorldPlugin extends GodotPlugin { } @Override - public List<String> getPluginMethods() { - return Collections.singletonList("helloWorld"); - } - - @Override - public View onMainCreateView(Activity activity) { + public View onMainCreate(Activity activity) { View view = activity.getLayoutInflater().inflate(R.layout.hello_world_view, null); helloWorldContainer = view.findViewById(R.id.hello_world_container); return view; @@ -37,16 +31,14 @@ public class HelloWorldPlugin extends GodotPlugin { /** * Show/hide, print and return "Hello World". */ + @UsedByGodot public String helloWorld() { if (helloWorldContainer != null) { - helloWorldContainer.post(new Runnable() { - @Override - public void run() { - if (helloWorldContainer.getVisibility() == View.VISIBLE) { - helloWorldContainer.setVisibility(View.GONE); - } else { - helloWorldContainer.setVisibility(View.VISIBLE); - } + helloWorldContainer.post(() -> { + if (helloWorldContainer.getVisibility() == View.VISIBLE) { + helloWorldContainer.setVisibility(View.GONE); + } else { + helloWorldContainer.setVisibility(View.VISIBLE); } }); } |