diff android/dw.cpp @ 2774:94af460bb954

Android: Implement dw_tree_new() and verify code doesn't crash.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 24 May 2022 09:42:35 +0000
parents e256bd8628ba
children 5f77f52df8ac
line wrap: on
line diff
--- a/android/dw.cpp	Thu Apr 21 20:58:08 2022 +0000
+++ b/android/dw.cpp	Tue May 24 09:42:35 2022 +0000
@@ -3284,7 +3284,19 @@
  */
 HWND API dw_tree_new(ULONG cid)
 {
-    /* TODO: Implement the tree if possible. */
+    JNIEnv *env;
+
+    if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    {
+        // First get the class that contains the method you need to call
+        jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
+        // Get the method that you want to call
+        jmethodID treeNew = env->GetMethodID(clazz, "treeNew",
+                                             "(I)Landroidx/recyclerview/widget/RecyclerView;");
+        // Call the method on the object
+        jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, treeNew, (int)cid), _DW_REFERENCE_WEAK);
+        return result;
+    }
     return nullptr;
 }