Review fixes.

This commit is contained in:
Daria Volvenkova 2017-07-20 16:01:20 +03:00 committed by Aleksandr Zatsepin
parent a82308341a
commit 8b7b392cbb
9 changed files with 28 additions and 20 deletions

View file

@ -643,7 +643,7 @@ Java_com_mapswithme_maps_Framework_nativeGetNameAndAddress(JNIEnv * env, jclass
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_Framework_nativeClearApiPoints(JNIEnv * env, jclass clazz)
{
UserMarkNotifyGuard guard(frm()->GetBookmarkManager(), UserMarkType::API_MARK);
UserMarkNotificationGuard guard(frm()->GetBookmarkManager(), UserMarkType::API_MARK);
guard.m_controller.Clear();
}

View file

@ -55,7 +55,7 @@ static NSString * const kKeyPath = @"subviews";
[Statistics logEvent:kStatEventName(kStatAPI, kStatBack)];
Framework & f = GetFramework();
f.DeactivateMapSelection(true);
UserMarkNotifyGuard guard(f.GetBookmarkManager(), UserMarkType::API_MARK);
UserMarkNotificationGuard guard(f.GetBookmarkManager(), UserMarkType::API_MARK);
guard.m_controller.Clear();
self.isVisible = NO;
NSURL * url = [NSURL URLWithString:@(f.GetApiDataHolder().GetGlobalBackUrl().c_str())];

View file

@ -265,12 +265,12 @@ UserMarkContainer * BookmarkManager::FindUserMarksContainer(UserMarkType type)
return iter->get();
}
UserMarkNotifyGuard::UserMarkNotifyGuard(BookmarkManager & mng, UserMarkType type)
UserMarkNotificationGuard::UserMarkNotificationGuard(BookmarkManager & mng, UserMarkType type)
: m_controller(mng.GetUserMarksController(type))
{
}
UserMarkNotifyGuard::~UserMarkNotifyGuard()
UserMarkNotificationGuard::~UserMarkNotificationGuard()
{
m_controller.NotifyChanges();
}

View file

@ -81,11 +81,11 @@ private:
UserMarkContainer * FindUserMarksContainer(UserMarkType type);
};
class UserMarkNotifyGuard
class UserMarkNotificationGuard
{
public:
UserMarkNotifyGuard(BookmarkManager & mng, UserMarkType type);
~UserMarkNotifyGuard();
UserMarkNotificationGuard(BookmarkManager & mng, UserMarkType type);
~UserMarkNotificationGuard();
UserMarksController & m_controller;
};

View file

@ -1779,7 +1779,7 @@ void Framework::FillSearchResultsMarks(search::Results const & results)
void Framework::FillSearchResultsMarks(search::Results::ConstIter begin,
search::Results::ConstIter end)
{
UserMarkNotifyGuard guard(m_bmManager, UserMarkType::SEARCH_MARK);
UserMarkNotificationGuard guard(m_bmManager, UserMarkType::SEARCH_MARK);
guard.m_controller.SetIsVisible(true);
guard.m_controller.SetIsDrawable(true);
@ -1808,7 +1808,7 @@ void Framework::FillSearchResultsMarks(search::Results::ConstIter begin,
void Framework::ClearSearchResultsMarks()
{
UserMarkNotifyGuard(m_bmManager, UserMarkType::SEARCH_MARK).m_controller.Clear();
UserMarkNotificationGuard(m_bmManager, UserMarkType::SEARCH_MARK).m_controller.Clear();
}
bool Framework::GetDistanceAndAzimut(m2::PointD const & point,
@ -2196,7 +2196,7 @@ url_scheme::ParsedMapApi::ParsingResult Framework::ParseAndSetApiURL(string cons
// Clear every current API-mark.
{
UserMarkNotifyGuard guard(m_bmManager, UserMarkType::API_MARK);
UserMarkNotificationGuard guard(m_bmManager, UserMarkType::API_MARK);
guard.m_controller.Clear();
guard.m_controller.SetIsVisible(true);
guard.m_controller.SetIsDrawable(true);

View file

@ -186,6 +186,7 @@ UNIT_TEST(Bookmarks_ExportKML)
ofstream of(BOOKMARKS_FILE_NAME);
cat.SaveToKML(of);
of.close();
cat.Clear();
TEST_EQUAL(cat.GetUserMarkCount(), 0, ());

View file

@ -46,11 +46,17 @@ namespace
string const & GetAppTitle() const { return m_api.GetAppTitle(); }
bool GoBackOnBalloonClick() const { return m_api.GoBackOnBalloonClick(); }
size_t GetPointCount() const { return UserMarkNotifyGuard(*m_m, type).m_controller.GetUserMarkCount(); }
size_t GetPointCount() const
{
return UserMarkNotificationGuard(*m_m, type).m_controller.GetUserMarkCount();
}
vector<RoutePoint> GetRoutePoints() const { return m_api.GetRoutePoints(); }
url_scheme::SearchRequest const & GetSearchRequest() const { return m_api.GetSearchRequest(); }
string const & GetGlobalBackUrl() const { return m_api.GetGlobalBackUrl(); }
int GetApiVersion() const { return m_api.GetApiVersion(); }
bool TestLatLon(int index, double lat, double lon) const
{
ms::LatLon const ll = GetMark(index)->GetLatLon();
@ -77,7 +83,7 @@ namespace
private:
ApiMarkPoint const * GetMark(int index) const
{
UserMarkNotifyGuard guard(*m_m, type);
UserMarkNotificationGuard guard(*m_m, type);
TEST_LESS(index, static_cast<int>(guard.m_controller.GetUserMarkCount()), ());
return static_cast<ApiMarkPoint const *>(guard.m_controller.GetUserMark(index));
}
@ -95,7 +101,7 @@ namespace
api.SetBookmarkManager(&fm.GetBookmarkManager());
api.SetUriAndParse(uriString);
{
UserMarkNotifyGuard guard(fm.GetBookmarkManager(), UserMarkType::API_MARK);
UserMarkNotificationGuard guard(fm.GetBookmarkManager(), UserMarkType::API_MARK);
guard.m_controller.Clear();
}

View file

@ -192,7 +192,7 @@ ParsedMapApi::ParsingResult ParsedMapApi::Parse(Uri const & uri)
return ParsingResult::Incorrect;
ASSERT(m_bmManager != nullptr, ());
UserMarkNotifyGuard guard(*m_bmManager, UserMarkType::API_MARK);
UserMarkNotificationGuard guard(*m_bmManager, UserMarkType::API_MARK);
for (auto const & p : points)
{
m2::PointD glPoint(MercatorBounds::FromLatLon(p.m_lat, p.m_lon));
@ -444,7 +444,7 @@ void ParsedMapApi::Reset()
bool ParsedMapApi::GetViewportRect(m2::RectD & rect) const
{
ASSERT(m_bmManager != nullptr, ());
UserMarkNotifyGuard guard(*m_bmManager, UserMarkType::API_MARK);
UserMarkNotificationGuard guard(*m_bmManager, UserMarkType::API_MARK);
size_t markCount = guard.m_controller.GetUserMarkCount();
if (markCount == 1 && m_zoomLevel >= 1)
@ -472,7 +472,7 @@ bool ParsedMapApi::GetViewportRect(m2::RectD & rect) const
ApiMarkPoint const * ParsedMapApi::GetSinglePoint() const
{
ASSERT(m_bmManager != nullptr, ());
UserMarkNotifyGuard guard(*m_bmManager, UserMarkType::API_MARK);
UserMarkNotificationGuard guard(*m_bmManager, UserMarkType::API_MARK);
if (guard.m_controller.GetUserMarkCount() != 1)
return nullptr;

View file

@ -95,10 +95,11 @@ RoutingManager::RoutingManager(Callbacks && callbacks, Delegate & delegate)
#ifdef SHOW_ROUTE_DEBUG_MARKS
if (m_bmManager == nullptr)
return;
UserMarkControllerGuard guard(*m_bmManager, UserMarkType::DEBUG_MARK);
guard.m_controller.SetIsVisible(true);
guard.m_controller.SetIsDrawable(true);
guard.m_controller.CreateUserMark(pt);
auto & controller = m_bmManager->GetUserMarksController(UserMarkType::DEBUG_MARK);
controller.SetIsVisible(true);
controller.SetIsDrawable(true);
controller.CreateUserMark(pt);
controller.NotifyChanges();
#endif
});