Review fixes.

This commit is contained in:
Maxim Pimenov 2019-09-30 16:03:28 +03:00 committed by Arsentiy Milchakov
parent 81295005ea
commit ec20ff0348
3 changed files with 22 additions and 24 deletions

View file

@ -1354,25 +1354,23 @@ Java_com_mapswithme_maps_Framework_nativeGetRouteFollowingInfo(JNIEnv * env, jcl
if (!lanes.empty())
{
static jclass const laneClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/routing/SingleLaneInfo");
size_t const lanesSize = lanes.size();
jLanes = env->NewObjectArray(static_cast<jsize>(lanesSize), laneClass, nullptr);
auto const lanesSize = static_cast<jsize>(lanes.size());
jLanes = env->NewObjectArray(lanesSize, laneClass, nullptr);
ASSERT(jLanes, (jni::DescribeException()));
static jmethodID const ctorSingleLaneInfoID = jni::GetConstructorID(env, laneClass, "([BZ)V");
for (size_t j = 0; j < lanesSize; ++j)
for (jsize j = 0; j < lanesSize; ++j)
{
size_t const laneSize = lanes[j].m_lane.size();
jni::TScopedLocalByteArrayRef singleLane(env,
env->NewByteArray(static_cast<jsize>(laneSize)));
auto const laneSize = static_cast<jsize>(lanes[j].m_lane.size());
jni::TScopedLocalByteArrayRef singleLane(env, env->NewByteArray(laneSize));
ASSERT(singleLane.get(), (jni::DescribeException()));
env->SetByteArrayRegion(singleLane.get(), 0, static_cast<jsize>(laneSize),
lanes[j].m_lane.data());
env->SetByteArrayRegion(singleLane.get(), 0, laneSize, lanes[j].m_lane.data());
jni::TScopedLocalRef singleLaneInfo(
env, env->NewObject(laneClass, ctorSingleLaneInfoID, singleLane.get(),
lanes[j].m_isRecommended));
ASSERT(singleLaneInfo.get(), (jni::DescribeException()));
env->SetObjectArrayElement(jLanes, static_cast<jsize>(j), singleLaneInfo.get());
env->SetObjectArrayElement(jLanes, j, singleLaneInfo.get());
}
}

View file

@ -403,15 +403,14 @@ jobjectArray BuildJavaMapResults(vector<storage::DownloaderSearchResult> const &
{
JNIEnv * env = jni::GetEnv();
size_t const count = results.size();
jobjectArray const res =
env->NewObjectArray(static_cast<jsize>(count), g_mapResultClass, nullptr);
for (size_t i = 0; i < count; i++)
auto const count = static_cast<jsize>(results.size());
jobjectArray const res = env->NewObjectArray(count, g_mapResultClass, nullptr);
for (jsize i = 0; i < count; i++)
{
jni::TScopedLocalRef country(env, jni::ToJavaString(env, results[i].m_countryId));
jni::TScopedLocalRef matched(env, jni::ToJavaString(env, results[i].m_matchedName));
jni::TScopedLocalRef item(env, env->NewObject(g_mapResultClass, g_mapResultCtor, country.get(), matched.get()));
env->SetObjectArrayElement(res, static_cast<jsize>(i), item.get());
env->SetObjectArrayElement(res, i, item.get());
}
return res;
@ -624,15 +623,14 @@ jobjectArray BuildSearchResults(Results const & results,
g_results = results;
size_t const count = g_results.GetCount();
jobjectArray const jResults =
env->NewObjectArray(static_cast<jsize>(count), g_resultClass, nullptr);
auto const count = static_cast<jsize>(g_results.GetCount());
jobjectArray const jResults = env->NewObjectArray(count, g_resultClass, nullptr);
for (size_t i = 0; i < count; i++)
for (jsize i = 0; i < count; i++)
{
jni::TScopedLocalRef jRes(env,
ToJavaResult(g_results[i], productInfo[i], hasPosition, lat, lon));
env->SetObjectArrayElement(jResults, static_cast<jsize>(i), jRes.get());
env->SetObjectArrayElement(jResults, i, jRes.get());
}
return jResults;
}

View file

@ -262,16 +262,18 @@ jobjectArray ToRatingArray(JNIEnv * env, std::vector<std::string> const & rating
jintArray ToReachableByTaxiProvidersArray(JNIEnv * env, std::vector<taxi::Provider::Type> const & types)
{
if (types.size() == 0)
auto const count = static_cast<jsize>(types.size());
if (count == 0)
return nullptr;
jint tmp[types.size()];
for (size_t i = 0; i < types.size(); ++i)
jint tmp[count];
for (size_t i = 0; i < count; ++i)
tmp[i] = static_cast<jint>(types[i]);
jintArray result = env->NewIntArray(static_cast<jsize>(types.size()));
jintArray result = env->NewIntArray(count);
ASSERT(result, ());
env->SetIntArrayRegion(result, 0, static_cast<jsize>(types.size()), tmp);
env->SetIntArrayRegion(result, 0, count, tmp);
return result;
}