diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 3940fe0622..6fd1ed8af1 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -625,42 +625,45 @@ Java_com_mapswithme_maps_Framework_nativeSetMapObjectListener(JNIEnv * env, jcla }); } -JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeRestoreMapObject(JNIEnv * env, - jclass clazz, - jobject jMapObject) +JNIEXPORT void JNICALL +Java_com_mapswithme_maps_Framework_nativeRestoreMapObject(JNIEnv * env, jclass clazz, + jobject jMapObject) { - jmethodID const getMapObjectTypeId = jni::GetMethodID(env, jMapObject, "getMapObjectType", "()I"); + static jmethodID const getMapObjectTypeId = + jni::GetMethodID(env, jMapObject, "getMapObjectType", "()I"); place_page::Info info; jint type = env->CallIntMethod(jMapObject, getMapObjectTypeId); switch (type) { - case 2: - { - jmethodID const getCategoryId = jni::GetMethodID(env, jMapObject, "getCategoryId", "()I"); - jmethodID const getBookmarkId = jni::GetMethodID(env, jMapObject, "getBookmarkId", "()I"); - jint categoryId = env->CallIntMethod(jMapObject, getCategoryId); - jint bookmarkId = env->CallIntMethod(jMapObject, getBookmarkId); - BookmarkAndCategory bnc = BookmarkAndCategory(bookmarkId, categoryId); - BookmarkCategory * pCat = frm()->GetBmCategory(categoryId); - Bookmark const * pBmk = static_cast(pCat->GetUserMark(bookmarkId)); - frm()->FillBookmarkInfo(*pBmk, bnc, info); - break; - } - case 3: - { - frm()->FillMyPositionInfo(info); - break; - } - default: - { - jmethodID const getLatId = jni::GetMethodID(env, jMapObject, "getLat", "()D"); - jmethodID const getLonId = jni::GetMethodID(env, jMapObject, "getLon", "()D"); - jdouble lat = env->CallDoubleMethod(jMapObject, getLatId); - jdouble lon = env->CallDoubleMethod(jMapObject, getLonId); - frm()->FillPoiInfo(m2::PointD(MercatorBounds::FromLatLon(lat, lon)), info); - break; - } + case usermark_helper::kBookmark: + { + static jmethodID const getCategoryId = + jni::GetMethodID(env, jMapObject, "getCategoryId", "()I"); + static jmethodID const getBookmarkId = + jni::GetMethodID(env, jMapObject, "getBookmarkId", "()I"); + jint categoryId = env->CallIntMethod(jMapObject, getCategoryId); + jint bookmarkId = env->CallIntMethod(jMapObject, getBookmarkId); + BookmarkAndCategory bnc = BookmarkAndCategory(bookmarkId, categoryId); + BookmarkCategory * pCat = frm()->GetBmCategory(categoryId); + Bookmark const * pBmk = static_cast(pCat->GetUserMark(bookmarkId)); + frm()->FillBookmarkInfo(*pBmk, bnc, info); + break; + } + case usermark_helper::kMyPosition: + { + frm()->FillMyPositionInfo(info); + break; + } + default: + { + static jmethodID const getLatId = jni::GetMethodID(env, jMapObject, "getLat", "()D"); + static jmethodID const getLonId = jni::GetMethodID(env, jMapObject, "getLon", "()D"); + jdouble lat = env->CallDoubleMethod(jMapObject, getLatId); + jdouble lon = env->CallDoubleMethod(jMapObject, getLonId); + frm()->FillPoiInfo(m2::PointD(MercatorBounds::FromLatLon(lat, lon)), info); + break; + } } g_framework->SetPlacePageInfo(info);