diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index e791889507..823d1f51ca 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -93,7 +93,7 @@ namespace return g_framework->NativeFramework(); } -jobject g_mapObjectListener = nullptr; +jobject g_userMarkActivationListener = nullptr; int const kUndefinedTip = -1; android::AndroidVulkanContextFactory * CastFactory(drape_ptr const & f) @@ -1016,40 +1016,43 @@ Java_com_mapswithme_maps_Framework_nativeGetParsedSearchRequest(JNIEnv * env, jc } JNIEXPORT void JNICALL -Java_com_mapswithme_maps_Framework_nativeSetMapObjectListener(JNIEnv * env, jclass clazz, jobject jListener) +Java_com_mapswithme_maps_Framework_nativeSetUserMarkActivationListener(JNIEnv *env, jclass clazz, + jobject jListener) { LOG(LINFO, ("Set global map object listener")); - g_mapObjectListener = env->NewGlobalRef(jListener); + g_userMarkActivationListener = env->NewGlobalRef(jListener); // void onUserMarkActivated(MapObject object); - jmethodID const activatedId = jni::GetMethodID(env, g_mapObjectListener, "onUserMarkActivated", + jmethodID const activatedId = jni::GetMethodID(env, g_userMarkActivationListener, + "onUserMarkActivated", "(Lcom/mapswithme/maps/widget/placepage/UserMarkInterface;)V"); // void onUserMarkDeactivated(boolean switchFullScreenMode); - jmethodID const deactivateId = jni::GetMethodID(env, g_mapObjectListener, "onUserMarkDeactivated", "(Z)V"); + jmethodID const deactivateId = jni::GetMethodID(env, g_userMarkActivationListener, + "onUserMarkDeactivated", "(Z)V"); auto const fillPlacePage = [activatedId]() { JNIEnv * env = jni::GetEnv(); auto const & info = frm()->GetCurrentPlacePageInfo(); jni::TScopedLocalRef userMarkRef(env, usermark_helper::CreateMapObject(env, info)); - env->CallVoidMethod(g_mapObjectListener, activatedId, userMarkRef.get()); + env->CallVoidMethod(g_userMarkActivationListener, activatedId, userMarkRef.get()); }; auto const closePlacePage = [deactivateId](bool switchFullScreenMode) { JNIEnv * env = jni::GetEnv(); - env->CallVoidMethod(g_mapObjectListener, deactivateId, switchFullScreenMode); + env->CallVoidMethod(g_userMarkActivationListener, deactivateId, switchFullScreenMode); }; frm()->SetPlacePageListeners(fillPlacePage, closePlacePage, fillPlacePage); } JNIEXPORT void JNICALL -Java_com_mapswithme_maps_Framework_nativeRemoveMapObjectListener(JNIEnv * env, jclass) +Java_com_mapswithme_maps_Framework_nativeRemoveUserMarkActivationListener(JNIEnv *env, jclass) { - if (g_mapObjectListener == nullptr) + if (g_userMarkActivationListener == nullptr) return; frm()->SetPlacePageListeners({} /* onOpen */, {} /* onClose */, {} /* onUpdate */); LOG(LINFO, ("Remove global map object listener")); - env->DeleteGlobalRef(g_mapObjectListener); - g_mapObjectListener = nullptr; + env->DeleteGlobalRef(g_userMarkActivationListener); + g_userMarkActivationListener = nullptr; } JNIEXPORT jstring JNICALL diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java index 6d57eb2354..0526329267 100644 --- a/android/src/com/mapswithme/maps/Framework.java +++ b/android/src/com/mapswithme/maps/Framework.java @@ -282,9 +282,9 @@ public class Framework public static native String nativeGetAddress(double lat, double lon); - public static native void nativeSetMapObjectListener(UserMarkActivationListener listener); + public static native void nativeSetUserMarkActivationListener(@NonNull UserMarkActivationListener listener); - public static native void nativeRemoveMapObjectListener(); + public static native void nativeRemoveUserMarkActivationListener(); @UiThread public static native String nativeGetOutdatedCountriesString(); diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 854e739900..571249bcc4 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -1404,7 +1404,7 @@ public class MwmActivity extends BaseMwmFragmentActivity protected void onStart() { super.onStart(); - Framework.nativeSetMapObjectListener(this); + Framework.nativeSetUserMarkActivationListener(this); BookmarkManager.INSTANCE.addLoadingListener(this); BookmarkManager.INSTANCE.addCatalogListener(this); RoutingController.get().attach(this); @@ -1418,7 +1418,7 @@ public class MwmActivity extends BaseMwmFragmentActivity protected void onStop() { super.onStop(); - Framework.nativeRemoveMapObjectListener(); + Framework.nativeRemoveUserMarkActivationListener(); BookmarkManager.INSTANCE.removeLoadingListener(this); BookmarkManager.INSTANCE.removeCatalogListener(this); LocationHelper.INSTANCE.detach(!isFinishing());