diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java index 0c31077a..d2a2b117 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/PLaunchApp.java @@ -145,9 +145,7 @@ public class PLaunchApp { mAccount = acc; mVersion = verInfo; - UIKit.runOnUIThread(() -> { - UIKit.launchMinecraftSurface(); - }); + UIKit.launchMinecraftSurface(); }).start(); } diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java index 16ec4aae..e5c8d53b 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java @@ -47,9 +47,7 @@ public class UIKit { public static void updateProgressSafe(final float progress, final String message) { System.out.println(message); - runOnUIThread(() -> { - updateProgress(progress, ((int) progress)*100 + "% - " + message); - }); + updateProgress(progress, ((int) progress)*100 + "% - " + message); } static { @@ -57,7 +55,7 @@ public class UIKit { } public static native int launchUI(String[] uiArgs); - public static native void runOnUIThread(UIKitCallback callback); + // public static native void runOnUIThread(UIKitCallback callback); // Update progress public static native void updateProgress(float progress, String message); diff --git a/Natives/ios_uikit_bridge.h b/Natives/ios_uikit_bridge.h index c2b81bc5..2fa0eb78 100644 --- a/Natives/ios_uikit_bridge.h +++ b/Natives/ios_uikit_bridge.h @@ -1,6 +1,5 @@ #pragma once #include "jni.h" -void UIKit_runOnUIThread(jobject callback); void UIKit_updateProgress(float progress, char* message); void UIKit_launchMinecraftSurfaceVC(); diff --git a/Natives/ios_uikit_bridge.m b/Natives/ios_uikit_bridge.m index 24b5147b..7443da02 100644 --- a/Natives/ios_uikit_bridge.m +++ b/Natives/ios_uikit_bridge.m @@ -7,26 +7,18 @@ #include "ios_uikit_bridge.h" #include "utils.h" -void UIKit_runOnUIThread(jobject callback) { +void UIKit_updateProgress(float progress, char* message) { dispatch_async(dispatch_get_main_queue(), ^{ - JNIEnv *env; - (*runtimeJavaVMPtr)->GetEnv(runtimeJavaVMPtr, &env, JNI_VERSION_1_4); - jclass clazz = (*env)->GetObjectClass(env, callback); - jmethodID method = (*env)->GetMethodID(env, clazz, "onCallback", "()V"); - (*env)->CallVoidMethod( - env, callback, method - ); + install_progress_bar.progress = progress; + install_progress_text.text = [NSString stringWithUTF8String:message]; }); } -void UIKit_updateProgress(float progress, char* message) { - install_progress_bar.progress = progress; - install_progress_text.text = [NSString stringWithUTF8String:message]; -} - void UIKit_launchMinecraftSurfaceVC() { - LauncherViewController *rootController = (LauncherViewController*)[[(AppDelegate*) [[UIApplication sharedApplication]delegate] window] rootViewController]; - UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MinecraftSurface" bundle:nil]; - SurfaceViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"MinecraftSurfaceVC"]; - [rootController presentViewController:vc animated:YES completion:nil]; + dispatch_async(dispatch_get_main_queue(), ^{ + LauncherViewController *rootController = (LauncherViewController*)[[(AppDelegate*) [[UIApplication sharedApplication]delegate] window] rootViewController]; + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MinecraftSurface" bundle:nil]; + SurfaceViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"MinecraftSurfaceVC"]; + [rootController presentViewController:vc animated:YES completion:nil]; + }); }