{ "id": "138431", "key": "TIMOB-17889", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "20115", "name": "Release 7.3.0", "archived": false, "released": true, "releaseDate": "2018-08-17" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-05-08T16:19:16.000+0000", "created": "2014-10-23T03:58:42.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "Ticonvert", "android", "toBoolean" ], "versions": [], "issuelinks": [], "assignee": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-07-05T16:20:25.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h2. Problem\r\n\r\nHave tracked down a pesky problem where setting the visible property of a TiLabel >> TiView to 0 (type integer) crashed the application. (see log below)\r\n\r\nPulled SDK and updated the method to have a case where it handles an input of type Integer. Built the SDK and ran the App. All fixed. Example below of what I added. I don't know Java but it gives you an idea of what to look at.\r\n\r\nh2. Logs\r\n\r\n{code:lang=none|title=console}\r\n[ERROR] : AndroidRuntime: FATAL EXCEPTION: main\r\n[ERROR] : AndroidRuntime: java.lang.IllegalArgumentException: Unable to convert java.lang.Integer to boolean.\r\n[ERROR] : AndroidRuntime: \tat org.appcelerator.titanium.util.TiConvert.toBoolean(TiConvert.java:357)\r\n[ERROR] : AndroidRuntime: \tat org.appcelerator.titanium.view.TiUIView.propertyChanged(TiUIView.java:723)\r\n[ERROR] : AndroidRuntime: \tat ti.modules.titanium.ui.widget.TiUILabel.propertyChanged(TiUILabel.java:280)\r\n[ERROR] : AndroidRuntime: \tat org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21)\r\n[ERROR] : AndroidRuntime: \tat org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1059)\r\n[ERROR] : AndroidRuntime: \tat org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:347)\r\n[ERROR] : AndroidRuntime: \tat android.os.Handler.dispatchMessage(Handler.java:95)\r\n[ERROR] : AndroidRuntime: \tat android.os.Looper.loop(Looper.java:137)\r\n[ERROR] : AndroidRuntime: \tat android.app.ActivityThread.main(ActivityThread.java:4745)\r\n[ERROR] : AndroidRuntime: \tat java.lang.reflect.Method.invokeNative(Native Method)\r\n[ERROR] : AndroidRuntime: \tat java.lang.reflect.Method.invoke(Method.java:511)\r\n[ERROR] : AndroidRuntime: \tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)\r\n[ERROR] : AndroidRuntime: \tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)\r\n[ERROR] : AndroidRuntime: \tat dalvik.system.NativeStart.main(Native Method)\r\n{code}\r\n\r\nh2. Changes\r\norg.appcelerator.titanium.util.TiConvert.toBoolean(TiConvert.java:357)\r\n{code:lang=none|title=console}\r\npublic static boolean toBoolean(Object value)\r\n\t{\r\n\t\tif (value instanceof Boolean) {\r\n\t\t\treturn (Boolean) value;\r\n\t\t} else if (value instanceof String) {\r\n\t\t\treturn Boolean.parseBoolean(((String) value));\r\n\t\t} \r\n\t\t// -- added handling for Integer\r\n\t\telse if (value instanceof Integer) {\r\n\t\t\tint numeric = (Integer) value;\r\n\t\t\treturn numeric > 0;\r\n\t\t} \r\n\t\t// /-- added handling for Integer\r\n\t\telse {\r\n\t\t\tthrow new IllegalArgumentException(\"Unable to convert \" + (value == null ? \"null\" : value.getClass().getName()) + \" to boolean.\");\r\n\t\t}\r\n\t}\r\n{code}", "attachment": [], "flagged": false, "summary": "TiConvert toBoolean doesnt handle type Interger", "creator": { "name": "Campbell", "key": "campbell", "displayName": "Campbell Anderson", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "Campbell", "key": "campbell", "displayName": "Campbell Anderson", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK 3.4.0.GA - building for Android", "closedSprints": [ { "id": 126, "state": "closed", "name": "2018 Sprint 05 SDK", "startDate": "2018-02-25T19:38:08.926Z", "endDate": "2018-03-11T18:38:00.000Z", "completeDate": "2018-03-11T22:06:01.520Z", "originBoardId": 100 } ], "comment": { "comments": [ { "id": "429937", "author": { "name": "cerw", "key": "cerw", "displayName": "Petr Cervenka", "active": true, "timeZone": "Asia/Shanghai" }, "body": "Having same issues.. ", "updateAuthor": { "name": "cerw", "key": "cerw", "displayName": "Petr Cervenka", "active": true, "timeZone": "Asia/Shanghai" }, "created": "2017-11-01T03:39:51.000+0000", "updated": "2017-11-01T03:39:51.000+0000" }, { "id": "435167", "author": { "name": "rfarfan", "key": "rfarfan", "displayName": "Rodrigo Farfán", "active": true, "timeZone": "Europe/Madrid" }, "body": "Hi there. This issue is very important to be solved as in JS boolean expressions can be generated with other types than boolean and strings. In many cases, using JS, we set conditional statements based on integers and even if an object is null or not. Is absolutely unpaired, I mean, that it should be fixed so that we can use JS in all its extents.", "updateAuthor": { "name": "rfarfan", "key": "rfarfan", "displayName": "Rodrigo Farfán", "active": true, "timeZone": "Europe/Madrid" }, "created": "2018-03-04T19:06:12.000+0000", "updated": "2018-03-04T19:06:12.000+0000" }, { "id": "435217", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "master: https://github.com/appcelerator/titanium_mobile/pull/9907", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-03-05T23:52:25.000+0000", "updated": "2018-03-05T23:52:25.000+0000" }, { "id": "437445", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "FR Passed.\r\nWaiting for merge to be enabled.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-05-07T23:09:51.000+0000", "updated": "2018-05-07T23:09:51.000+0000" }, { "id": "437469", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR merged.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-05-08T16:19:11.000+0000", "updated": "2018-05-08T16:19:11.000+0000" }, { "id": "437943", "author": { "name": "rfarfan", "key": "rfarfan", "displayName": "Rodrigo Farfán", "active": true, "timeZone": "Europe/Madrid" }, "body": "Sorry, but I still miss a\r\n\r\n{code:java}\r\nelse if (value == null) {\r\n return false;\r\n}\r\n{code}\r\n\r\nbefore the IllegalArgumentException throwing. We need to pair \"Java World\" as much as possible to \"JavaScript World\".", "updateAuthor": { "name": "rfarfan", "key": "rfarfan", "displayName": "Rodrigo Farfán", "active": true, "timeZone": "Europe/Madrid" }, "created": "2018-05-25T08:39:59.000+0000", "updated": "2018-05-25T08:40:16.000+0000" }, { "id": "439014", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix in SDK 7.3.0.v20180703051211.\r\nClosing.\r\n\r\nStudio Ver: 5.1.0.201806291005\r\nSDK Ver: 7.3.0.v20180703051211\r\nOS Ver: 4.2.13\r\nXcode Ver: 7.0.4\r\nAppc NPM: 1.1.3\r\nAppc CLI: 10.13.5\r\nDaemon Ver: Xcode 9.4.1\r\nTi CLI Ver: 5.1.1\r\nAlloy Ver: 1.12.0\r\nNode Ver: 8.9.1\r\nNPM Ver: 5.5.1\r\nJava Ver: 10.0.1\r\nDevices: ⇨ google Nexus 5 --- Android 6.0.1\r\n ⇨ google Nexus 6P --- Android 8.1.0\r\nEmulator: ⇨ Android 4.1.2\r\n", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-07-05T16:20:19.000+0000", "updated": "2018-07-05T16:20:19.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }