Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3039] Android: DP unit for imageView causes crash

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T02:00:45.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0 M08
ComponentsAndroid
Labels2.2, android, defect, enterprise, release-1.6.0, reported-1.6.0, rplist
ReporterRick Blalock
AssigneeDon Thorp
Created2011-04-15T03:35:15.000+0000
Updated2011-04-17T02:00:45.000+0000

Description

Unsure if this is a feature request or defect.

Breakdown is assigning height / width of an imageView using 'dp's crashes.

Enterprise ticket here: http://developer.appcelerator.com/helpdesk/view/70571">http://developer.appcelerator.com/helpdesk/view/70571

using 'dip' does not work either.

Reproducible code:

var win = Ti.UI.createWindow({
    backgroundColor:'red',
});
 
 
var a =  Titanium.UI.createImageView({
            height:'48dp',
            width:'48dp',
            top:'12dp',
            left:'18dp',
            image:'icon_default_white_48.png',
            defaultImage:'icon_default_white_48.png',
        });
 
win.add(a);
win.open();

Comments

  1. Andreas sandberg 2011-04-15

    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)

  2. Bill Dawson 2011-04-15

    The TextField issue is similar in the sense that it happens with 'dp', but it actually has a different root cause so I put it in its own ticket: #3047

  3. Bill Dawson 2011-04-15

    (from [6f78b58b06affa14ab0ab8188ea98f6969e415ba]) For dp and % units, view's parent is required, and imageview needs it 'earlier' that most other views so that image scaling can occur. Modify ImageView.getParent to find the parent view via the parent's proxy in case the imageview view hasn't yet been added to the parent view. [#3039 state:fixed-in-qa] https://github.com/appcelerator/titanium_mobile/commit/6f78b58b06affa14ab0ab8188ea98f6969e415ba"> https://github.com/appcelerator/titanium_mobile/commit/6f78b58b06af...

  4. Opie Cyrus 2011-04-15

    verified on emulator 2.2.

    Creating the image view with dp does not result in exception.

JSON Source