forked from organicmaps/organicmaps
[android] Fixed crashes for SearchResults without FeatureID inside.
This commit is contained in:
parent
6b4ee29d1a
commit
e2b56e5486
1 changed files with 19 additions and 11 deletions
|
@ -33,7 +33,7 @@ jmethodID g_suggestConstructor;
|
|||
jclass g_descriptionClass;
|
||||
jmethodID g_descriptionConstructor;
|
||||
|
||||
jobject ToJavaResult(Result result, bool hasPosition, double lat, double lon)
|
||||
jobject ToJavaResult(Result & result, bool hasPosition, double lat, double lon)
|
||||
{
|
||||
JNIEnv * env = jni::GetEnv();
|
||||
|
||||
|
@ -47,7 +47,18 @@ jobject ToJavaResult(Result result, bool hasPosition, double lat, double lon)
|
|||
}
|
||||
env->ReleaseIntArrayElements(ranges.get(), rawArr, 0);
|
||||
|
||||
ms::LatLon const ll = MercatorBounds::ToLatLon(result.GetFeatureCenter());
|
||||
ms::LatLon ll = ms::LatLon::Zero();
|
||||
string distance;
|
||||
if (result.HasPoint())
|
||||
{
|
||||
ll = MercatorBounds::ToLatLon(result.GetFeatureCenter());
|
||||
if (hasPosition)
|
||||
{
|
||||
double dummy;
|
||||
(void) g_framework->NativeFramework()->GetDistanceAndAzimut(result.GetFeatureCenter(), lat, lon, 0, distance, dummy);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.IsSuggest())
|
||||
{
|
||||
jni::TScopedLocalRef name(env, jni::ToJavaString(env, result.GetString()));
|
||||
|
@ -56,20 +67,17 @@ jobject ToJavaResult(Result result, bool hasPosition, double lat, double lon)
|
|||
ASSERT(ret, ());
|
||||
return ret;
|
||||
}
|
||||
g_framework->NativeFramework()->LoadSearchResultMetadata(result);
|
||||
|
||||
string distance;
|
||||
if (hasPosition)
|
||||
search::AddressInfo info;
|
||||
if (result.GetResultType() == Result::RESULT_FEATURE)
|
||||
{
|
||||
double dummy;
|
||||
(void) g_framework->NativeFramework()->GetDistanceAndAzimut(result.GetFeatureCenter(), lat, lon, 0, distance, dummy);
|
||||
::Framework * frm = g_framework->NativeFramework();
|
||||
frm->LoadSearchResultMetadata(result);
|
||||
frm->GetSearchResultAddress(result);
|
||||
}
|
||||
|
||||
|
||||
auto const address = g_framework->NativeFramework()->GetSearchResultAddress(result);
|
||||
|
||||
jni::TScopedLocalRef featureType(env, jni::ToJavaString(env, result.GetFeatureType()));
|
||||
jni::TScopedLocalRef region(env, jni::ToJavaString(env, address.FormatAddress(search::AddressInfo::SEARCH_RESULT)));
|
||||
jni::TScopedLocalRef region(env, jni::ToJavaString(env, info.FormatAddress(search::AddressInfo::SEARCH_RESULT)));
|
||||
jni::TScopedLocalRef dist(env, jni::ToJavaString(env, distance));
|
||||
jni::TScopedLocalRef cuisine(env, jni::ToJavaString(env, result.GetCuisine()));
|
||||
jni::TScopedLocalRef desc(env, env->NewObject(g_descriptionClass, g_descriptionConstructor,
|
||||
|
|
Loading…
Add table
Reference in a new issue