diff options
author | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-07-02 16:36:16 -0700 |
---|---|---|
committer | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-07-02 16:36:16 -0700 |
commit | f6a336cf56d5d653b05c12fb7f71b5da595e49d4 (patch) | |
tree | 0c92274b81918a3442aab23f51524ed29ce90b21 /hello_world/src | |
parent | 8a50b716f5d335d0c060eb096032fc2d214dc635 (diff) | |
download | godot-android-samples-f6a336cf56d5d653b05c12fb7f71b5da595e49d4.tar.gz godot-android-samples-f6a336cf56d5d653b05c12fb7f71b5da595e49d4.tar.bz2 godot-android-samples-f6a336cf56d5d653b05c12fb7f71b5da595e49d4.zip |
Update the 'Hello World' Android plugin to match the new Godot 4.2 format
See https://github.com/godotengine/godot/pull/78958 for reference.
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); } }); } |