Skip to content

Commit

Permalink
accessing points list mapbox#1716
Browse files Browse the repository at this point in the history
  • Loading branch information
hallahan committed Jul 16, 2015
1 parent 062a942 commit 8589cee
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions android/cpp/jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jfieldID polylineAlphaId = nullptr;
jfieldID polylineVisibleId = nullptr;
jfieldID polylineColorId = nullptr;
jfieldID polylineWidthId = nullptr;
jfieldID polylinePointsId = nullptr;

jclass latLngZoomClass = nullptr;
jmethodID latLngZoomConstructorId = nullptr;
Expand Down Expand Up @@ -501,6 +502,15 @@ jlong JNICALL nativeAddPolyline(JNIEnv *env, jobject obj, jlong nativeMapViewPtr
return -1;
}

jobject points = env->GetObjectField(polyline, polylinePointsId);
if (points == nullptr) {
if (env->ThrowNew(nullPointerExceptionClass, "List cannot be null.") < 0) {
env->ExceptionDescribe();
return -1;
}
return -1;
}

return (jlong)width;
}

Expand Down Expand Up @@ -897,6 +907,12 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_ERR;
}

polylinePointsId = env->GetFieldID(polylineClass, "points", "Ljava/util/List;");
if (polylineWidthId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}

latLngZoomClass = env->FindClass("com/mapbox/mapboxgl/geometry/LatLngZoom");
if (latLngZoomClass == nullptr) {
env->ExceptionDescribe();
Expand Down

0 comments on commit 8589cee

Please sign in to comment.