[TIMOB-24175] Hyperloop: Android - Can't get value from "Editable" class because toString method is overridden
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-12-01T18:50:30.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Hyperloop 2.0.1 |
| Components | Android, Hyperloop |
| Labels | Hyperloop, android, qe-hyperloop |
| Reporter | Rodolfo Perottoni |
| Assignee | Gary Mathews |
| Created | 2016-11-25T06:46:59.000+0000 |
| Updated | 2017-01-26T18:23:37.000+0000 |
Description
I'm currently implementing a Hyperloop lib that uses the native EditText widget.
The EditText widget holds its value in an instance of the *Editable* class. When you want to get this value, all you have to do is:
yourEditText.getText(); // an implicit call to toString() is done here when you try to log this value
The problem that I'm facing is that the *Editable* implementation of *toString()* is not accessible with Hyperloop.
*Example:*
Create a Hyperloop enabled project and require the *android.text.Editable* class in any controller:
var Editable = require('android.text.Editable');
Build and run the project. Go to the */build/hyperloop/android/js* folder and look for the *android.text.Editable* file. You'll notice that the generated *toString()* method is not calling the native *toString()* function like this:
...
this.$native.callNativeFunction({ /* something here */ })
...
Instead, this is what's being generated:
Editable.toString = function() {
return "[object " + this.className + "]";
};
This basically blocks you from using any widget/component that stores its data in an *Editable* instance, since the value of *toString()* will always be *[object android.text.Editable]*
master: https://github.com/appcelerator/hyperloop.next/pull/106 2_0_X: https://github.com/appcelerator/hyperloop.next/pull/107
Verified as fixed, Values from an
editableclass are now accessible. Tested on: {noformat} macOS Sierra 10.12.2 Nexus 5X (6.0.1) Pixel Xl (7.1.1) android emulator (4.4.2, 6.0) Ti SDK: 6.1.0.v20170126073441 Hyperloop: 2.0.1 Appc CLI: 6.1.0 Appc NPM: 4.2.8 Node v4.6.0 {noformat} *Closing Ticket.*