[TIMOB-8546] Android: handle invalid values on width and height gracefully
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-05-30T14:34:58.000+0000 |
Affected Version/s | Release 2.0.0 |
Fix Version/s | Release 2.1.0 |
Components | Android |
Labels | core, module_media, qe-testadded |
Reporter | Opie Cyrus |
Assignee | Max Stepanov |
Created | 2012-04-04T15:48:41.000+0000 |
Updated | 2012-07-13T16:28:10.000+0000 |
Description
when invalid values are set for width and height an exception occurs when trying to convert the values into TiDimension:
var imageView = Ti.UI.createImageView({
width:win.width,
height:win.height,
image:event.media
});
win.add(imageView);
* this would be when win.width is undefined. This test case can be found in the KS camera test.
Resulting error:
04-04 16:26:45.345 21220 21220 E TiApplication: (main) [9299,18498] Sending event: exception on thread: main msg:java.lang.ClassCastException: org.appcelerator.kroll.KrollRuntime$1; Titanium 2.1.0,2012/04/04 15:16,161fb52
04-04 16:26:45.345 21220 21220 E TiApplication: java.lang.ClassCastException: org.appcelerator.kroll.KrollRuntime$1
04-04 16:26:45.345 21220 21220 E TiApplication: at org.appcelerator.titanium.util.TiConvert.toTiDimension(TiConvert.java:550)
04-04 16:26:45.345 21220 21220 E TiApplication: at org.appcelerator.titanium.util.TiConvert.toTiDimension(TiConvert.java:561)
04-04 16:26:45.345 21220 21220 E TiApplication: at ti.modules.titanium.ui.widget.TiUIImageView.processProperties(TiUIImageView.java:806)
04-04 16:26:45.345 21220 21220 E TiApplication: at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:737)
04-04 16:26:45.345 21220 21220 E TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:530)
04-04 16:26:45.345 21220 21220 E TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:522)
04-04 16:26:45.345 21220 21220 E TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:500)
04-04 16:26:45.345 21220 21220 E TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:616)
04-04 16:26:45.345 21220 21220 E TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:307)
04-04 16:26:45.345 21220 21220 E TiApplication: at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:110)
04-04 16:26:45.345 21220 21220 E TiApplication: at ti.modules.titanium.ui.ActivityWindowProxy.handleMessage(ActivityWindowProxy.java:93)
04-04 16:26:45.345 21220 21220 E TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95)
04-04 16:26:45.345 21220 21220 E TiApplication: at android.os.Looper.loop(Looper.java:143)
04-04 16:26:45.345 21220 21220 E TiApplication: at android.app.ActivityThread.main(ActivityThread.java:4701)
04-04 16:26:45.345 21220 21220 E TiApplication: at java.lang.reflect.Method.invokeNative(Native Method)
04-04 16:26:45.345 21220 21220 E TiApplication: at java.lang.reflect.Method.invoke(Method.java:521)
04-04 16:26:45.345 21220 21220 E TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-04 16:26:45.345 21220 21220 E TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-04 16:26:45.345 21220 21220 E TiApplication: at dalvik.system.NativeStart.main(Native Method)
04-04 16:26:45.353 1401 21298 I MediaScanner: process file: /sdcard/dcim/Camera/tia70621.jpg
04-04 16:26:45.361 1401 21298 D DlnaMediaParser: getJPEGProfileName: 4
04-04 16:26:45.494 1401 1428 D MediaProvider: current image thumbnail number created successfully is:2
04-04 16:26:45.728 1238 1257 D BatteryTempPolicy: updateBatteryTemp temperature = 380, Threshhold = 3
04-04 16:26:45.767 16521 16521 E GlobalUnplugService: plugged = true,mBatteryPlugged=true
We should gracefully handle invalid values when they are set or processed either by throwing exceptions to let the developer know of the problem or defaulting to valid values. Requires parity discussion.
Fixed by PR 2030
For QE
Verified fix with Titanium Studio, build: 2.1.0.201206221045 Titanium SDK: 2.1.0.v20120622174154 Device: Nexus S 4.0.4