[android] Added 'has place page info' checks everywhere before calling GetPlacePageInfo method

This commit is contained in:
Александр Зацепин 2020-02-06 14:05:39 +03:00 committed by Daria Volvenkova
parent 49d1a60b7e
commit 3632afb9f6
3 changed files with 31 additions and 0 deletions

View file

@ -845,6 +845,10 @@ std::string Framework::GetPromoCityUrl(JNIEnv * env, jobject policy, jdouble lat
void Framework::LogLocalAdsEvent(local_ads::EventType type, double lat, double lon, uint16_t accuracy)
{
::Framework * frm = g_framework->NativeFramework();
if (!frm->HasPlacePageInfo())
return;
auto const & info = g_framework->GetPlacePageInfo();
auto const & featureID = info.GetID();
auto const & mwmInfo = featureID.m_mwmId.GetInfo();
@ -1818,6 +1822,10 @@ Java_com_mapswithme_maps_Framework_nativeIsDownloadedMapAtScreenCenter(JNIEnv *,
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_Framework_nativeGetActiveObjectFormattedCuisine(JNIEnv * env, jclass)
{
::Framework * frm = g_framework->NativeFramework();
if (!frm->HasPlacePageInfo())
return {};
return jni::ToJavaString(env, g_framework->GetPlacePageInfo().FormatCuisines());
}

View file

@ -245,18 +245,30 @@ Java_com_mapswithme_maps_editor_Editor_nativeSaveEditedFeature(JNIEnv *, jclass)
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeShouldShowEditPlace(JNIEnv *, jclass)
{
::Framework * frm = g_framework->NativeFramework();
if (!frm->HasPlacePageInfo())
return static_cast<jboolean>(false);
return g_framework->GetPlacePageInfo().ShouldShowEditPlace();
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeShouldShowAddPlace(JNIEnv *, jclass)
{
::Framework * frm = g_framework->NativeFramework();
if (!frm->HasPlacePageInfo())
return static_cast<jboolean>(false);
return g_framework->GetPlacePageInfo().ShouldShowAddPlace();
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeShouldShowAddBusiness(JNIEnv *, jclass)
{
::Framework * frm = g_framework->NativeFramework();
if (!frm->HasPlacePageInfo())
return static_cast<jboolean>(false);
return g_framework->GetPlacePageInfo().ShouldShowAddBusiness();
}
@ -417,6 +429,9 @@ JNIEXPORT void JNICALL
Java_com_mapswithme_maps_editor_Editor_nativeStartEdit(JNIEnv *, jclass)
{
::Framework * frm = g_framework->NativeFramework();
if (!frm->HasPlacePageInfo())
return;
place_page::Info const & info = g_framework->GetPlacePageInfo();
CHECK(frm->GetEditableMapObject(info.GetID(), g_editableMapObject), ("Invalid feature in the place page."));
}

View file

@ -13,6 +13,10 @@ namespace
{
void RegisterEventIfPossible(eye::MapObject::Event::Type const type)
{
::Framework * frm = g_framework->NativeFramework();
if (!frm->HasPlacePageInfo())
return;
auto & info = g_framework->GetPlacePageInfo();
auto const userPos = g_framework->NativeFramework()->GetCurrentPosition();
@ -21,6 +25,10 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type)
void RegisterTransitionToBooking()
{
::Framework * frm = g_framework->NativeFramework();
if (!frm->HasPlacePageInfo())
return;
auto & info = g_framework->GetPlacePageInfo();
eye::Eye::Event::TransitionToBooking(info.GetMercator());
}