[android] Remove dependency on SplashActivity from MwmApplication.init()

Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
Roman Tsisyk 2023-09-29 09:00:34 +03:00 committed by Viktor Govako
parent 043df09ec8
commit a4961b5e99
3 changed files with 11 additions and 11 deletions

View file

@ -27,17 +27,17 @@ extern "C"
flavorName, buildType, isTablet);
}
// static void nativeInitFramework();
// static void nativeInitFramework(@NonNull Runnable onComplete);
JNIEXPORT void JNICALL
Java_app_organicmaps_MwmApplication_nativeInitFramework(JNIEnv * env, jclass clazz, jobject listener)
Java_app_organicmaps_MwmApplication_nativeInitFramework(JNIEnv * env, jclass clazz, jobject onComplete)
{
if (!g_framework)
{
g_framework = std::make_unique<android::Framework>([listener = jni::make_global_ref(listener)]()
g_framework = std::make_unique<android::Framework>([onComplete = jni::make_global_ref(onComplete)]()
{
JNIEnv * env = jni::GetEnv();
jmethodID const methodId = jni::GetMethodID(env, *listener, "processNavigation", "()V");
env->CallVoidMethod(*listener, methodId);
jmethodID const methodId = jni::GetMethodID(env, *onComplete, "run", "()V");
env->CallVoidMethod(*onComplete, methodId);
});
}
}

View file

@ -164,10 +164,10 @@ public class MwmApplication extends Application implements Application.ActivityL
* @throws IOException - if failed to create directories. Caller must handle
* the exception and do nothing with native code if initialization is failed.
*/
public boolean init(SplashActivity listener) throws IOException
public boolean init(@NonNull Runnable onComplete) throws IOException
{
initNativePlatform();
return initNativeFramework(listener);
return initNativeFramework(onComplete);
}
private void initNativePlatform() throws IOException
@ -214,12 +214,12 @@ public class MwmApplication extends Application implements Application.ActivityL
StorageUtils.requireDirectory(tempPath);
}
private boolean initNativeFramework(SplashActivity listener)
private boolean initNativeFramework(@NonNull Runnable onComplete)
{
if (mFrameworkInitialized)
return false;
nativeInitFramework(listener);
nativeInitFramework(onComplete);
MapManager.nativeSubscribe(mStorageCallbacks);
@ -285,7 +285,7 @@ public class MwmApplication extends Application implements Application.ActivityL
private native void nativeInitPlatform(String apkPath, String writablePath, String privatePath,
String tmpPath, String flavorName, String buildType,
boolean isTablet);
private static native void nativeInitFramework(SplashActivity listener);
private static native void nativeInitFramework(@NonNull Runnable onComplete);
private static native void nativeProcessTask(long taskPointer);
private static native void nativeAddLocalization(String name, String value);
private static native void nativeOnTransit(boolean foreground);

View file

@ -145,7 +145,7 @@ public class SplashActivity extends AppCompatActivity
boolean asyncContinue = false;
try
{
asyncContinue = app.init(this);
asyncContinue = app.init(this::processNavigation);
} catch (IOException e)
{
showFatalErrorDialog(R.string.dialog_error_storage_title, R.string.dialog_error_storage_message);