{ "id": "167454", "key": "TIMOB-24658", "fields": { "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "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": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-09-25T18:55:09.000+0000", "created": "2017-05-04T16:24:29.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "android", "hyperloop", "hyperloop-examples" ], "versions": [], "issuelinks": [], "assignee": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-09-25T18:55:12.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": "13715", "name": "Hyperloop", "description": "Hyperloop project" } ], "description": "*Problem*\r\nI am trying to reference an image file in Hyperloop to instantiate a native Android object (for example, a Drawable).\r\n\r\nI am currently using Titanium Hyperloop to create a custom Android class that I wish to port over to my app built on Appcelerator. From the Hyperloop documentation, I can reference the native Android Drawable with:\r\n\r\n{code:java}\r\nDrawable = require('android.graphics.drawable.Drawable')\r\n{code}\r\n\r\nNow, I wish to instantiate a Drawable object through the native Drawable.createFromPath() constructor but my problem is that Titanium is not recognizing the path name to my image in my resources folder in my app directory. For example, the path to my image file is:\r\n\r\n{my_app}/assets/images/myImage.png\r\n\r\nAny paths I try to pass into the constructor give a \"No such file or directory\" exception. How do I work with Titanium Hyperloop to construct a native Android Drawable object?\r\n\r\n*Test Case*\r\n\r\n{code:java}\r\nvar Drawable = require('android.graphics.drawable.Drawable');\r\nvar imagePath = '/images/myImage.png';\r\n\t\r\nvar mImage = Drawable.createFromPath(imagePath);\r\n{code}\r\n\r\n*Log*\r\n\"No such file or directory\" exception\r\n\r\n*Community Discussion*\r\n[http://stackoverflow.com/questions/43726570/titanium-hyperloop-how-to-instantiate-native-android-drawable]\r\n", "attachment": [], "flagged": false, "summary": "Hyperloop: Android - How to instantiate native Android Drawable?", "creator": { "name": "jzuniga", "key": "jzuniga", "displayName": "Jose Zuniga", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jzuniga", "key": "jzuniga", "displayName": "Jose Zuniga", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK Version: 6.0.1.GA\r\nPlatform: Android\r\nDevice Details: Android Alcatel One Touch 6045I\r\nHost OS: macOS Sierra 10.12.4\r\nTitanium Studio Version 4.8.1.201612050850-8k9iFNRFT6e5O-XsWq7Uu7ESQDTs", "closedSprints": [ { "id": 951, "state": "closed", "name": "2017 Sprint 20 SDK", "startDate": "2017-09-24T17:50:18.277Z", "endDate": "2017-10-08T17:50:00.000Z", "completeDate": "2017-10-09T20:38:07.840Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "419118", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~gmathews] I guess the native developer needs to specify a more advanced path to that method right? Since the relative path needs to be mapped to the exact (drawable) directory. [~jzuniga] Maybe only the file name? Or check where the images are copied to in the resulting apk and check the Android docs on how to resolve to that path.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-05-04T17:59:18.000+0000", "updated": "2017-05-04T17:59:18.000+0000" }, { "id": "419466", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "You would need to use the full path, or you could use a stream:\r\n{code:js}\r\nvar Drawable = require('android.graphics.drawable.Drawable'),\r\n Activity = require('android.app.Activity'),\r\n activity = new Activity(Ti.Android.currentActivity),\r\n context = activity.getApplicationContext(),\r\n assetStream = context.getAssets().open('Resources/assets/images/a.png');\r\n\r\nif (assetStream) {\r\n alert('drawable: ' + Drawable.createFromStream(assetStream, null));\r\n assetStream.close();\r\n}\r\n{code}", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-05-10T14:20:38.000+0000", "updated": "2017-05-10T14:20:38.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }