forked from organicmaps/organicmaps
[android] Renamed map object listener code to user mark activation listener
This commit is contained in:
parent
3b6e7d3ecd
commit
23cf5e5060
3 changed files with 18 additions and 15 deletions
|
@ -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<dp::GraphicsContextFactory> 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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Add table
Reference in a new issue