comparison android/dw.cpp @ 2754:e256bd8628ba

Andrdoi: Attempt to fix a number of issues querying containers. Always returning nullptr from the query functions made it always fail. Varaibles were incorrectly named and I had incorrectly assumed the SparseBooleanArray only returned checked items. This is not the case, it only returns items that were changed. So we now take this array and create a copy but only including the items that are checked so the code works as intended.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 02 Jan 2022 19:06:04 +0000
parents ee1cfa7d645e
children 94af460bb954
comparison
equal deleted inserted replaced
2753:2ac361d3a837 2754:e256bd8628ba
4026 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 4026 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
4027 // Get the method that you want to call 4027 // Get the method that you want to call
4028 jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetDataStart", 4028 jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetDataStart",
4029 "(Landroid/widget/ListView;I)J"); 4029 "(Landroid/widget/ListView;I)J");
4030 // Call the method on the object 4030 // Call the method on the object
4031 jlong data = env->CallLongMethod(_dw_obj, containerGetDataStart, handle, (int)flags); 4031 jlong data = env->CallLongMethod(_dw_obj, containerGetDataStart, handle, (jint)flags);
4032 if(!_dw_jni_check_exception(env)) 4032 if(!_dw_jni_check_exception(env))
4033 retval = (char *)data; 4033 retval = (char *)data;
4034 } else { 4034 } else {
4035 // First get the class that contains the method you need to call 4035 // First get the class that contains the method you need to call
4036 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 4036 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
4037 // Get the method that you want to call 4037 // Get the method that you want to call
4038 jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetTitleStart", 4038 jmethodID containerGetTitleStart = env->GetMethodID(clazz, "containerGetTitleStart",
4039 "(Landroid/widget/ListView;I)Ljava/lang/String;"); 4039 "(Landroid/widget/ListView;I)Ljava/lang/String;");
4040 // Call the method on the object 4040 // Call the method on the object
4041 jstring jstr = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerGetDataStart, handle, (int)flags), _DW_REFERENCE_NONE); 4041 jstring jstr = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerGetTitleStart, handle, (jint)flags), _DW_REFERENCE_NONE);
4042 if(jstr) 4042 char *str;
4043 retval = (char *)env->GetStringUTFChars(jstr, nullptr); 4043
4044 if(jstr && (str = (char *)env->GetStringUTFChars(jstr, nullptr)))
4045 retval = strdup(str);
4044 } 4046 }
4045 } 4047 }
4046 return nullptr; 4048 return retval;
4047 } 4049 }
4048 4050
4049 /* 4051 /*
4050 * Continues an existing query of a container. 4052 * Continues an existing query of a container.
4051 * Parameters: 4053 * Parameters:
4068 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 4070 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
4069 // Get the method that you want to call 4071 // Get the method that you want to call
4070 jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetDataNext", 4072 jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetDataNext",
4071 "(Landroid/widget/ListView;I)J"); 4073 "(Landroid/widget/ListView;I)J");
4072 // Call the method on the object 4074 // Call the method on the object
4073 jlong data = env->CallLongMethod(_dw_obj, containerGetDataStart, handle, (int)flags); 4075 jlong data = env->CallLongMethod(_dw_obj, containerGetDataStart, handle, (jint)flags);
4074 if(!_dw_jni_check_exception(env)) 4076 if(!_dw_jni_check_exception(env))
4075 retval = (char *)data; 4077 retval = (char *)data;
4076 } else { 4078 } else {
4077 // First get the class that contains the method you need to call 4079 // First get the class that contains the method you need to call
4078 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 4080 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
4079 // Get the method that you want to call 4081 // Get the method that you want to call
4080 jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetTitleNext", 4082 jmethodID containerGetTitleNext = env->GetMethodID(clazz, "containerGetTitleNext",
4081 "(Landroid/widget/ListView;I)Ljava/lang/String;"); 4083 "(Landroid/widget/ListView;I)Ljava/lang/String;");
4082 // Call the method on the object 4084 // Call the method on the object
4083 jstring jstr = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerGetDataStart, handle, (int)flags), _DW_REFERENCE_NONE); 4085 jstring jstr = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerGetTitleNext, handle, (jint)flags), _DW_REFERENCE_NONE);
4084 if(jstr) 4086 char *str;
4085 retval = (char *)env->GetStringUTFChars(jstr, nullptr); 4087
4088 if(jstr && (str = (char *)env->GetStringUTFChars(jstr, nullptr)))
4089 retval = strdup(str);
4086 } 4090 }
4087 } 4091 }
4088 return nullptr; 4092 return retval;
4089 } 4093 }
4090 4094
4091 /* 4095 /*
4092 * Cursors the item with the text speficied, and scrolls to that item. 4096 * Cursors the item with the text speficied, and scrolls to that item.
4093 * Parameters: 4097 * Parameters: