[Android] jni: add ArrayList JNI helpers

Edward Wang git at videolan.org
Mon Oct 28 04:14:41 CET 2013


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sun Oct 27 20:49:34 2013 -0400| [10abf29cd6eb3191f963b4727f7a2cfccf82449e] | committer: Edward Wang

jni: add ArrayList JNI helpers

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=10abf29cd6eb3191f963b4727f7a2cfccf82449e
---

 vlc-android/jni/libvlcjni-util.c |   14 ++++++++++++++
 vlc-android/jni/utils.h          |    4 ++++
 2 files changed, 18 insertions(+)

diff --git a/vlc-android/jni/libvlcjni-util.c b/vlc-android/jni/libvlcjni-util.c
index e46e54d..37a8ed4 100644
--- a/vlc-android/jni/libvlcjni-util.c
+++ b/vlc-android/jni/libvlcjni-util.c
@@ -115,6 +115,20 @@ void setString(JNIEnv *env, jobject item, const char* field, const char* text) {
     (*env)->SetObjectField(env, item, fieldId, jstr);
 }
 
+void arrayListGetIDs(JNIEnv *env, jclass* p_class, jmethodID* p_add, jmethodID* p_remove) {
+    *p_class = (*env)->FindClass(env, "java/util/ArrayList");
+    if(p_add)
+        *p_add = (*env)->GetMethodID(env, *p_class, "add", "(Ljava/lang/Object;)Z");
+    if(p_remove)
+        *p_remove = (*env)->GetMethodID(env, *p_class, "remove", "(I)Ljava/lang/Object;");
+}
+
+void arrayListStringAdd(JNIEnv *env, jclass class, jmethodID methodID, jobject arrayList, const char* str) {
+    jstring jstr = (*env)->NewStringUTF(env, str);
+    (*env)->CallBooleanMethod(env, arrayList, methodID, jstr);
+    (*env)->DeleteLocalRef(env, jstr);
+}
+
 // Returns the libvlc_media_list_t of a MediaList object
 libvlc_media_list_t* getMediaListFromJava(JNIEnv *env, jobject obj) {
     return (libvlc_media_list_t*)(intptr_t)getLong(env, obj, "mMediaListInstance");
diff --git a/vlc-android/jni/utils.h b/vlc-android/jni/utils.h
index 8d8ef36..03f64ce 100644
--- a/vlc-android/jni/utils.h
+++ b/vlc-android/jni/utils.h
@@ -39,6 +39,10 @@ void setFloat(JNIEnv *env, jobject item, const char* field, jfloat value);
 
 void setString(JNIEnv *env, jobject item, const char* field, const char* text);
 
+void arrayListGetIDs(JNIEnv *env, jclass* p_class, jmethodID* p_add, jmethodID* p_remove);
+
+void arrayListStringAdd(JNIEnv *env, jclass class, jmethodID methodID, jobject arrayList, const char* str);
+
 jobject getEventHandlerReference(JNIEnv *env, jobject thiz, jobject eventHandler);
 
 void debug_log(void *data, int level, const libvlc_log_t *ctx, const char *fmt, va_list ap);



More information about the Android mailing list