forked from organicmaps/organicmaps
[android] More codereview fixes.
This commit is contained in:
parent
8f1ea9bf60
commit
38f49d21f0
5 changed files with 25 additions and 23 deletions
|
@ -30,17 +30,11 @@ namespace jni
|
|||
}
|
||||
|
||||
jstring ToJavaString(JNIEnv * env, char const * s);
|
||||
|
||||
inline jstring ToJavaString(JNIEnv * env, string const & s)
|
||||
{
|
||||
return ToJavaString(env, s.c_str());
|
||||
}
|
||||
|
||||
inline jstring ToJavaString(string const & s)
|
||||
{
|
||||
return ToJavaString(GetEnv(), s.c_str());
|
||||
}
|
||||
|
||||
string DescribeException();
|
||||
|
||||
shared_ptr<jobject> make_global_ref(jobject obj);
|
||||
|
|
|
@ -590,19 +590,20 @@ namespace android
|
|||
m2::PointD pxPivot;
|
||||
BookmarkAndCategory bmAndCat;
|
||||
|
||||
bool const apiPointActivated = NativeFramework()->GetMapApiPoint(pt, m_activePoint);
|
||||
url_scheme::ApiPoint apiPoint;
|
||||
bool const apiPointActivated = NativeFramework()->GetMapApiPoint(pt, apiPoint);
|
||||
if (m_apiPointActivatedListener)
|
||||
m_apiPointActivatedListener(apiPointActivated, m_activePoint.m_lat,
|
||||
m_activePoint.m_lon,
|
||||
m_activePoint.m_title,
|
||||
m_activePoint.m_url);
|
||||
m_apiPointActivatedListener(apiPointActivated, apiPoint.m_lat,
|
||||
apiPoint.m_lon,
|
||||
apiPoint.m_title,
|
||||
apiPoint.m_url);
|
||||
|
||||
|
||||
if (apiPointActivated)
|
||||
{
|
||||
m2::PointD pivot(MercatorBounds::LonToX(m_activePoint.m_lon),
|
||||
MercatorBounds::LatToY(m_activePoint.m_lat));
|
||||
ActivatePopup(pivot, m_activePoint.m_title, IMAGE_ARROW);
|
||||
m2::PointD pivot(MercatorBounds::LonToX(apiPoint.m_lon),
|
||||
MercatorBounds::LatToY(apiPoint.m_lat));
|
||||
ActivatePopup(pivot, apiPoint.m_title, "", IMAGE_ARROW);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -612,7 +613,7 @@ namespace android
|
|||
case ::Framework::BOOKMARK:
|
||||
{
|
||||
Bookmark const * pBM = m_work.GetBmCategory(bmAndCat.first)->GetBookmark(bmAndCat.second);
|
||||
ActivatePopup(pBM->GetOrg(), pBM->GetName(), IMAGE_ARROW);
|
||||
ActivatePopup(pBM->GetOrg(), pBM->GetName(), "", IMAGE_ARROW);
|
||||
return;
|
||||
}
|
||||
case ::Framework::POI:
|
||||
|
@ -842,8 +843,8 @@ extern "C"
|
|||
"onApiPointActivated",
|
||||
"(ZDDLjava/lang/String;Ljava/lang/String;)V");
|
||||
|
||||
jstring j_name = jni::ToJavaString(name);
|
||||
jstring j_id = jni::ToJavaString(id);
|
||||
jstring j_name = jni::ToJavaString(jniEnv, name);
|
||||
jstring j_id = jni::ToJavaString(jniEnv, id);
|
||||
jniEnv->CallVoidMethod(*obj.get(), methodID, activated, lat, lon, j_name, j_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,8 +41,7 @@ namespace android
|
|||
int m_mask;
|
||||
|
||||
bool m_doLoadState;
|
||||
//Api point
|
||||
url_scheme::ApiPoint m_activePoint;
|
||||
//Api
|
||||
typedef function<void (bool, double, double, string, string)> TOnApiPointActivatedListener;
|
||||
TOnApiPointActivatedListener m_apiPointActivatedListener;
|
||||
|
||||
|
|
|
@ -1431,8 +1431,7 @@ bool Framework::SetViewportByURL(string const & url, url_api::Request & request)
|
|||
request.m_viewportLat = newPoint.m_lat = info.m_lat;
|
||||
request.m_viewportLon = newPoint.m_lon = info.m_lon;
|
||||
request.m_viewportZoomLevel = info.m_zoom;
|
||||
|
||||
ShowRectExVisibleScale(info.GetViewport());
|
||||
SetViewPortSync(info.GetViewport());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1446,7 +1445,7 @@ bool Framework::SetViewportByURL(string const & url, url_api::Request & request)
|
|||
point.m_name = m_stringsBundle.GetString("dropped_pin");
|
||||
|
||||
m2::PointD const center(MercatorBounds::LonToX(request.m_viewportLon), MercatorBounds::LatToY(request.m_viewportLat));
|
||||
ShowRectExVisibleScale(scales::GetRectForLevel(request.m_viewportZoomLevel, center, 1));
|
||||
SetViewPortSync(scales::GetRectForLevel(request.m_viewportZoomLevel, center, 1));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1458,13 +1457,21 @@ bool Framework::SetViewportByURL(string const & url, url_api::Request & request)
|
|||
//Can do better consider nav bar size
|
||||
m2::RectD view(MercatorBounds::LonToX(z.minX()), MercatorBounds::LatToY(z.minY()),
|
||||
MercatorBounds::LonToX(z.maxX()), MercatorBounds::LatToY(z.maxY()));
|
||||
ShowRectExVisibleScale(view);
|
||||
SetViewPortSync(view);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Framework::SetViewPortSync(m2::RectD const & rect)
|
||||
{
|
||||
// This is tricky way to syncronize work and
|
||||
// rendring threads.
|
||||
m2::AnyRectD aRect(rect);
|
||||
m_animator.ChangeViewport(aRect, aRect, 0.0);
|
||||
}
|
||||
|
||||
m2::RectD Framework::GetCurrentViewport() const
|
||||
{
|
||||
return m_navigator.Screen().ClipRect();
|
||||
|
|
|
@ -459,6 +459,7 @@ public:
|
|||
private:
|
||||
url_scheme::ParsedMapApi m_ParsedMapApi;
|
||||
void DrawMapApiPoints(shared_ptr<PaintEvent> const & e);
|
||||
void SetViewPortSync(m2::RectD const & rect);
|
||||
|
||||
public:
|
||||
void MapApiSetUriAndParse(string const & url);
|
||||
|
|
Loading…
Add table
Reference in a new issue