diff android/dw.cpp @ 2709:3cb5aa73dace

Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 22 Nov 2021 02:18:08 +0000
parents 3a7dcc0ae08b
children 98cc4476b376
line wrap: on
line diff
--- a/android/dw.cpp	Fri Nov 19 18:48:41 2021 +0000
+++ b/android/dw.cpp	Mon Nov 22 02:18:08 2021 +0000
@@ -3893,6 +3893,19 @@
  */
 void API dw_container_scroll(HWND handle, int direction, long rows)
 {
+    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 containerScroll = env->GetMethodID(clazz, "containerScroll",
+                                                     "(Landroid/widget/ListView;II)V");
+        // Call the method on the object
+        env->CallVoidMethod(_dw_obj, containerScroll, handle, direction, (jint)rows);
+        _dw_jni_check_exception(env);
+    }
 }
 
 /*
@@ -3987,6 +4000,21 @@
  */
 void API dw_container_cursor(HWND handle, const char *text)
 {
+    JNIEnv *env;
+
+    if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    {
+        // Generate a string
+        jstring jstr = text ? env->NewStringUTF(text) : nullptr;
+        // 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 containerCursor = env->GetMethodID(clazz, "containerCursor",
+                                                               "(Landroid/widget/ListView;Ljava/lang/String;)V");
+        // Call the method on the object
+        env->CallVoidMethod(_dw_obj, containerCursor, handle, jstr);
+        _dw_jni_check_exception(env);
+    }
 }
 
 /*
@@ -3997,6 +4025,19 @@
  */
 void API dw_container_cursor_by_data(HWND handle, void *data)
 {
+    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 containerCursorByData = env->GetMethodID(clazz, "containerCursorByData",
+                                                              "(Landroid/widget/ListView;J)V");
+        // Call the method on the object
+        env->CallVoidMethod(_dw_obj, containerCursorByData, handle, (jlong)data);
+        _dw_jni_check_exception(env);
+    }
 }
 
 /*