[TIMOB-3047] Android: TextField crashes when 'dp' units used to set dimension properties
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Hold |
Resolution Date | 2011-04-15T03:35:28.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android |
Labels | android, defect, enterprise, release-1.7.0, reported-1.6.0, rplist |
Reporter | Bill Dawson |
Assignee | Bill Dawson |
Created | 2011-04-15T03:35:26.000+0000 |
Updated | 2017-03-10T19:23:39.000+0000 |
Description
(From Andreas Sandberg) Bill, here is a similar use case that also throws an exception and crashes the application:
var win = Ti.UI.createWindow({
backgroundColor:'red',
});
var a = Titanium.UI.createTextField({
height:'51dp',
top:'5dp',
paddingLeft:'10dp',
left:'10dp',
right:'54dp'
});
var fieldContainer = Ti.UI.createView({
height:a.height,
width:320,
layout:'horizontal'
});
fieldContainer.add(a);
win.add(fieldContainer);
win.open();
Stack Trace:
[TRACE] E/KrollReflectionProperty( 559): (kroll$1) [702,1358] Exception getting/setting property: height
[TRACE] E/KrollReflectionProperty( 559): java.lang.NumberFormatException: unable to parse '51dp' as integer
[TRACE] E/KrollReflectionProperty( 559): at java.lang.Integer.parse(Integer.java:433)
[TRACE] E/KrollReflectionProperty( 559): at java.lang.Integer.parseInt(Integer.java:422)
[TRACE] E/KrollReflectionProperty( 559): at java.lang.Integer.parseInt(Integer.java:382)
[TRACE] E/KrollReflectionProperty( 559): at org.appcelerator.titanium.util.TiConvert.toInt(TiConvert.java:251)
[TRACE] E/KrollReflectionProperty( 559): at org.appcelerator.titanium.proxy.TiViewProxy.getHeight(TiViewProxy.java:303)
[TRACE] E/KrollReflectionProperty( 559): at org.appcelerator.titanium.proxy.TiViewProxyBindingGen$2.dynamicGet(TiViewProxyBindingGen.java:276)
[TRACE] E/KrollReflectionProperty( 559): at org.appcelerator.kroll.KrollDynamicProperty.safeInvoke(KrollDynamicProperty.java:39)
[TRACE] E/KrollReflectionProperty( 559): at org.appcelerator.kroll.KrollDynamicProperty.get(KrollDynamicProperty.java:88)
[TRACE] E/KrollReflectionProperty( 559): at org.appcelerator.kroll.KrollProxy.getDynamicProperty(KrollProxy.java:241)
[TRACE] E/KrollReflectionProperty( 559): at org.appcelerator.kroll.KrollProxy.get(KrollProxy.java:183)
[TRACE] E/KrollReflectionProperty( 559): at org.appcelerator.kroll.KrollObject.get(KrollObject.java:33)
[TRACE] E/KrollReflectionProperty( 559): at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:1963)
[TRACE] E/KrollReflectionProperty( 559): at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1503)
[TRACE] E/KrollReflectionProperty( 559): at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1489)
Simplified failcase app.js:
Bill, I spoke with the customer and we're pushing this to 1.7.0. As you know, it requires changing method signatures and dealing with the static vs dynamic problem we found in our UI review in January.
Also slated for 1.7.0 is a general re-working of the properties that set and expose layout characteristics. For example, currently it is impossible to read that you set a width to
"auto"
. (It throws the exception that is the subject of this ticket.) One of the goals of the overhaul is that differentiate between what you set as a layout dimension ("11", "11dp", "auto", etc.) and the actual pixel dimension that resulted once the view was laid out. At that point, this ticket will not be valid anymore.To avoid duplicate effort, we're therefore putting this ticket in a hold state, since both this ticket and the general re-working (which will solve this ticket) are slated for 1.7.0.
As a temporary workaround to the exception that you're getting as described in this ticket, you can read the
.size
property of views. For example, if you setview.width = "20dp"
, you can then read the resulting width (expressed in pixels) withview.size.width
, but only after the view has been laid out (i.e., after the window has been open and all child views have been drawn.)Closing ticket.