diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index f9d3d34592..b9e1eabf1b 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -1017,19 +1017,20 @@ Java_com_mapswithme_maps_Framework_nativeSetMapObjectListener(JNIEnv * env, jcla "(Lcom/mapswithme/maps/bookmarks/data/MapObject;)V"); // void onDismiss(boolean switchFullScreenMode); jmethodID const dismissId = jni::GetMethodID(env, g_mapObjectListener, "onDismiss", "(Z)V"); - frm()->SetPlacePageListenners([activatedId](place_page::Info const & info) + auto const fillPlacePage = [activatedId](place_page::Info const & info) { JNIEnv * env = jni::GetEnv(); g_framework->SetPlacePageInfo(info); jni::TScopedLocalRef mapObject(env, usermark_helper::CreateMapObject(env, info)); env->CallVoidMethod(g_mapObjectListener, activatedId, mapObject.get()); - }, [dismissId](bool switchFullScreenMode) + }; + auto const closePlacePage = [dismissId](bool switchFullScreenMode) { JNIEnv * env = jni::GetEnv(); g_framework->SetPlacePageInfo({}); env->CallVoidMethod(g_mapObjectListener, dismissId, switchFullScreenMode); - }, - {} /* onUpdate */); + }; + frm()->SetPlacePageListenners(fillPlacePage, closePlacePage, fillPlacePage); } JNIEXPORT void JNICALL diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h index deeab7fbe7..1cf03598fa 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h @@ -44,6 +44,7 @@ class Info; - (void)dismissPlacePage; - (void)showPlacePage:(place_page::Info const &)info; +- (void)updatePlacePage:(place_page::Info const &)info; - (void)showPlacePageReview:(place_page::Info const &)info; - (void)addPlace:(BOOL)isBusiness hasPoint:(BOOL)hasPoint point:(m2::PointD const &)point; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 27b237759c..238ff02a9b 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -130,6 +130,10 @@ extern NSString * const kAlohalyticsTapEventKey; }); } +- (void)updatePlacePage:(place_page::Info const &)info { + [self.placePageManager update:info]; +} + - (void)showPlacePageReview:(place_page::Info const &)info { network_policy::CallPartnersApi([self, info](auto const & /* canUseNetwork */) { diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 5130c19be4..86be86755d 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -136,6 +136,10 @@ NSString * const kHotelFacilitiesSegue = @"Map2FacilitiesSegue"; [self.controlsManager showPlacePage:info]; } +- (void)onMapObjectUpdated:(place_page::Info const &)info { + [self.controlsManager updatePlacePage:info]; +} + - (void)checkMaskedPointer:(UITouch *)touch withEvent:(df::TouchEvent &)e { int64_t id = reinterpret_cast(touch); @@ -392,10 +396,9 @@ NSString * const kHotelFacilitiesSegue = @"Map2FacilitiesSegue"; self.listeners = [NSHashTable> weakObjectsHashTable]; Framework & f = GetFramework(); // TODO: Review and improve this code. - f.SetPlacePageListenners( - [self](place_page::Info const & info) { [self onMapObjectSelected:info]; }, - [self](bool switchFullScreen) { [self onMapObjectDeselected:switchFullScreen]; }, - {} /* onUpdate */); + f.SetPlacePageListenners([self](place_page::Info const &info) { [self onMapObjectSelected:info]; }, + [self](bool switchFullScreen) { [self onMapObjectDeselected:switchFullScreen]; }, + [self](place_page::Info const &info) { [self onMapObjectUpdated:info]; }); // TODO: Review and improve this code. f.SetMyPositionModeListener([self](location::EMyPositionMode mode, bool routingActive) { // TODO: Two global listeners are subscribed to the same event from the core. diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm index ac788c1b8c..338dc46dbd 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm @@ -129,6 +129,16 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page: [self processCountryEvent:[self.data countryId]]; } +- (void)update:(place_page::Info const &)info { + if (!self.layout || !self.data) + return; + + self.data = [[MWMPlacePageData alloc] initWithPlacePageInfo:info]; + [self.data fillSections]; + [self setupSpeedAndDistance]; + [self.layout checkCellsVisible]; +} + - (BOOL)isPPShown { return self.data != nil; } diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h b/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h index a09cb7d0e4..5d60c62295 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h @@ -50,6 +50,7 @@ struct HotelFacility; @protocol MWMPlacePageProtocol - (void)show:(place_page::Info const &)info; +- (void)update:(place_page::Info const &)info; - (void)showReview:(place_page::Info const &)info; - (BOOL)isPPShown; - (void)dismiss; diff --git a/map/framework.cpp b/map/framework.cpp index 051ba461f0..84624c2693 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2456,7 +2456,8 @@ void Framework::UpdatePlacePageInfoForCurrentSelection() SetPlacePageLocation(info); - ActivateMapSelection(false, obj, info); + if (m_onPlacePageUpdate) + m_onPlacePageUpdate(info); } void Framework::InvalidateUserMarks()