diff android/dw.cpp @ 2852:5018df4f952e

Win/Android/Template: Add return values to dw_window_set_bitmap(_from_data). Also update the readme regarding this change.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 15 Nov 2022 00:34:20 +0000
parents da90bf6d0564
children de1a0cd26691
line wrap: on
line diff
--- a/android/dw.cpp	Mon Nov 14 22:00:47 2022 +0000
+++ b/android/dw.cpp	Tue Nov 15 00:34:20 2022 +0000
@@ -6197,10 +6197,15 @@
  *                 Windows and a pixmap on Unix, pass
  *                 nullptr if you use the id param)
  *       len: Length of data passed
- */
-void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, const char *data, int len)
-{
-    JNIEnv *env;
+ * Returns:
+ *        DW_ERROR_NONE on success.
+ *        DW_ERROR_UNKNOWN if the parameters were invalid.
+ *        DW_ERROR_GENERAL if the bitmap was unable to be loaded.
+ */
+int API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, const char *data, int len)
+{
+    JNIEnv *env;
+    int retval = DW_ERROR_UNKNOWN;
 
     if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
     {
@@ -6215,14 +6220,15 @@
         jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
         // Get the method that you want to call
         jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmapFromData",
-                                                             "(Landroid/view/View;I[BI)V");
-        // Call the method on the object
-        env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)cid, bytearray, len);
+                                                             "(Landroid/view/View;I[BI)I");
+        // Call the method on the object
+        retval = env->CallIntMethod(_dw_obj, windowSetBitmapFromData, handle, (int)cid, bytearray, len);
         _dw_jni_check_exception(env);
         // Clean up after the array now that we are finished
         //if(bytearray)
             //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0);
     }
+    return retval;
 }
 
 /*
@@ -6234,10 +6240,15 @@
  *       filename: a path to a file (Bitmap on OS/2 or
  *                 Windows and a pixmap on Unix, pass
  *                 nullptr if you use the id param)
- */
-void API dw_window_set_bitmap(HWND handle, unsigned long resid, const char *filename)
-{
-    JNIEnv *env;
+ * Returns:
+ *        DW_ERROR_NONE on success.
+ *        DW_ERROR_UNKNOWN if the parameters were invalid.
+ *        DW_ERROR_GENERAL if the bitmap was unable to be loaded.
+ */
+int API dw_window_set_bitmap(HWND handle, unsigned long resid, const char *filename)
+{
+    JNIEnv *env;
+    int retval = DW_ERROR_UNKNOWN;
 
     if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
     {
@@ -6250,13 +6261,14 @@
         jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
         // Get the method that you want to call
         jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmap",
-                                                             "(Landroid/view/View;ILjava/lang/String;)V");
-        // Call the method on the object
-        env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)resid, jstr);
+                                                             "(Landroid/view/View;ILjava/lang/String;)I");
+        // Call the method on the object
+        retval = env->CallIntMethod(_dw_obj, windowSetBitmapFromData, handle, (int)resid, jstr);
         _dw_jni_check_exception(env);
         if(jstr)
             env->DeleteLocalRef(jstr);
     }
+    return retval;
 }
 
 /*