Mercurial > dwindows
diff 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 |
line wrap: on
line diff
--- a/android/dw.cpp Sat Jan 01 18:47:38 2022 +0000 +++ b/android/dw.cpp Sun Jan 02 19:06:04 2022 +0000 @@ -4028,22 +4028,24 @@ jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetDataStart", "(Landroid/widget/ListView;I)J"); // Call the method on the object - jlong data = env->CallLongMethod(_dw_obj, containerGetDataStart, handle, (int)flags); + jlong data = env->CallLongMethod(_dw_obj, containerGetDataStart, handle, (jint)flags); if(!_dw_jni_check_exception(env)) retval = (char *)data; } else { // 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 containerGetDataStart = env->GetMethodID(clazz, "containerGetTitleStart", + jmethodID containerGetTitleStart = env->GetMethodID(clazz, "containerGetTitleStart", "(Landroid/widget/ListView;I)Ljava/lang/String;"); // Call the method on the object - jstring jstr = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerGetDataStart, handle, (int)flags), _DW_REFERENCE_NONE); - if(jstr) - retval = (char *)env->GetStringUTFChars(jstr, nullptr); + jstring jstr = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerGetTitleStart, handle, (jint)flags), _DW_REFERENCE_NONE); + char *str; + + if(jstr && (str = (char *)env->GetStringUTFChars(jstr, nullptr))) + retval = strdup(str); } } - return nullptr; + return retval; } /* @@ -4070,22 +4072,24 @@ jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetDataNext", "(Landroid/widget/ListView;I)J"); // Call the method on the object - jlong data = env->CallLongMethod(_dw_obj, containerGetDataStart, handle, (int)flags); + jlong data = env->CallLongMethod(_dw_obj, containerGetDataStart, handle, (jint)flags); if(!_dw_jni_check_exception(env)) retval = (char *)data; } else { // 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 containerGetDataStart = env->GetMethodID(clazz, "containerGetTitleNext", + jmethodID containerGetTitleNext = env->GetMethodID(clazz, "containerGetTitleNext", "(Landroid/widget/ListView;I)Ljava/lang/String;"); // Call the method on the object - jstring jstr = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerGetDataStart, handle, (int)flags), _DW_REFERENCE_NONE); - if(jstr) - retval = (char *)env->GetStringUTFChars(jstr, nullptr); + jstring jstr = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerGetTitleNext, handle, (jint)flags), _DW_REFERENCE_NONE); + char *str; + + if(jstr && (str = (char *)env->GetStringUTFChars(jstr, nullptr))) + retval = strdup(str); } } - return nullptr; + return retval; } /*