problem
When setting *borderColor* of a proxy to null, out supported platforms all have different behaviors:
ios
The borderColor is given the default solid color, which is black
mobileweb
The borderColor is made transparent
android
A force close happens and this error log is generated
W/dalvikvm( 765): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/TiApplication( 765): (main) [22789,22790] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.1.1,2013/06/15 16:10,f7592c1
E/TiApplication( 765): java.lang.NullPointerException
E/TiApplication( 765): at org.appcelerator.titanium.view.TiUIView.handleBorderProperty(TiUIView.java:1023)
E/TiApplication( 765): at org.appcelerator.titanium.view.TiUIView.propertyChanged(TiUIView.java:619)
E/TiApplication( 765): at ti.modules.titanium.ui.widget.TiUILabel.propertyChanged(TiUILabel.java:168)
E/TiApplication( 765): at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21)
E/TiApplication( 765): at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1011)
E/TiApplication( 765): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:316)
E/TiApplication( 765): at android.os.Handler.dispatchMessage(Handler.java:95)
E/TiApplication( 765): at android.os.Looper.loop(Looper.java:130)
E/TiApplication( 765): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/TiApplication( 765): at java.lang.reflect.Method.invokeNative(Native Method)
E/TiApplication( 765): at java.lang.reflect.Method.invoke(Method.java:507)
E/TiApplication( 765): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/TiApplication( 765): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/TiApplication( 765): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 765): FATAL EXCEPTION: main
E/AndroidRuntime( 765): java.lang.NullPointerException
E/AndroidRuntime( 765): at org.appcelerator.titanium.view.TiUIView.handleBorderProperty(TiUIView.java:1023)
E/AndroidRuntime( 765): at org.appcelerator.titanium.view.TiUIView.propertyChanged(TiUIView.java:619)
E/AndroidRuntime( 765): at ti.modules.titanium.ui.widget.TiUILabel.propertyChanged(TiUILabel.java:168)
E/AndroidRuntime( 765): at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21)
E/AndroidRuntime( 765): at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1011)
E/AndroidRuntime( 765): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:316)
E/AndroidRuntime( 765): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime( 765): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 765): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 765): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 765): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 765): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 765): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 765): at dalvik.system.NativeStart.main(Native Method)
expected
Whether the borderColor is turned to solid black or transparent, it needs to be uniform across platforms. Also, there should be no errors when setting borderColor to null.
test case
var win = Ti.UI.createWindow({
backgroundColor: '#fff',
modal: false,
exitOnClose: true
});
var label = Ti.UI.createLabel({
text: 'just a test label',
borderColor: '#0f0',
// note: borderWidth is required to cause the android exception
borderWidth: 2
});
label.addEventListener('click', function(e) {
label.borderColor = null;
});
win.add(label);
win.open();
PR :- https://github.com/appcelerator/titanium_mobile/pull/4472
Verified the fix with: Appc-Studio: 3.2.0.201310100354 Sdk:3.2.0.v20131009134844 alloy:1.2.2 npm:1.3.2 titanium:3.2.0 titanium-code-processor:1.0.3 Device:Google Nexus 7(v4.3),ipodTouch1(v7.0) Xcode: 5 BorderColor when set to null for label in iOS turns black and in Android turns transparent.