diff options
| author | JosJuice <josjuice@gmail.com> | 2020-06-25 19:38:02 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2020-09-16 18:38:52 +0200 |
| commit | d9f3e382fe1b2f1c7d9de54cefa920b4f0502af6 (patch) | |
| tree | 7903bb4afe8dc13c5e11da10e5565f2c199f443d /Source/Android/jni/MainAndroid.cpp | |
| parent | 7d6debb90793dbd34df49d779ea2c34e432094d8 (diff) | |
Android: Add a progress dialog for disc image conversion
Diffstat (limited to 'Source/Android/jni/MainAndroid.cpp')
| -rw-r--r-- | Source/Android/jni/MainAndroid.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index bef78a49b5..4bb72ff2f6 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -27,6 +27,7 @@ #include "Common/IniFile.h" #include "Common/Logging/LogManager.h" #include "Common/MsgHandler.h" +#include "Common/ScopeGuard.h" #include "Common/Version.h" #include "Common/WindowSystemInfo.h" @@ -668,7 +669,7 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_InstallW JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ConvertDiscImage( JNIEnv* env, jobject obj, jstring jInPath, jstring jOutPath, jint jPlatform, jint jFormat, - jint jBlockSize, jint jCompression, jint jCompressionLevel, jboolean jScrub) + jint jBlockSize, jint jCompression, jint jCompressionLevel, jboolean jScrub, jobject jCallback) { const std::string in_path = GetJString(env, jInPath); const std::string out_path = GetJString(env, jOutPath); @@ -687,7 +688,14 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ConvertD if (!blob_reader) return static_cast<jboolean>(false); - const auto callback = [](const std::string& text, float percent) { return true; }; + jobject jCallbackGlobal = env->NewGlobalRef(jCallback); + Common::ScopeGuard scope_guard([jCallbackGlobal, env] { env->DeleteGlobalRef(jCallbackGlobal); }); + + const auto callback = [&jCallbackGlobal](const std::string& text, float completion) { + JNIEnv* env = IDCache::GetEnvForThread(); + return static_cast<bool>(env->CallBooleanMethod( + jCallbackGlobal, IDCache::GetCompressCallbackRun(), ToJString(env, text), completion)); + }; bool success = false; |
